XXX: got lost, need the start vaddr in the release paths, help? Use the mm_mpin() call to prepare the vm for a 'persistent' get_user_pages() call. Cc: Christoph Lameter Cc: Thomas Gleixner Cc: Andrew Morton Cc: Hugh Dickins Cc: Mel Gorman Cc: Mike Marciniszyn Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Signed-off-by: Peter Zijlstra --- drivers/infiniband/hw/qib/qib.h | 2 +- drivers/infiniband/hw/qib/qib_file_ops.c | 6 +++--- drivers/infiniband/hw/qib/qib_user_pages.c | 16 ++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -1376,7 +1376,7 @@ void qib_sdma_process_event(struct qib_p #define QIB_RCVHDR_ENTSIZE 32 int qib_get_user_pages(unsigned long, size_t, struct page **); -void qib_release_user_pages(struct page **, size_t); +void qib_release_user_pages(struct page **, unsigned long, size_t); int qib_eeprom_read(struct qib_devdata *, u8, void *, int); int qib_eeprom_write(struct qib_devdata *, u8, const void *, int); u32 __iomem *qib_getsendbuf_range(struct qib_devdata *, u32 *, u32, u32); --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -423,7 +423,7 @@ static int qib_tid_update(struct qib_ctx dd->pageshadow[ctxttid + tid] = NULL; } } - qib_release_user_pages(pagep, cnt); + qib_release_user_pages(pagep, /* vaddr */, cnt); } else { /* * Copy the updated array, with qib_tid's filled in, back @@ -535,7 +535,7 @@ static int qib_tid_free(struct qib_ctxtd RCVHQ_RCV_TYPE_EXPECTED, dd->tidinvalid); pci_unmap_page(dd->pcidev, phys, PAGE_SIZE, PCI_DMA_FROMDEVICE); - qib_release_user_pages(&p, 1); + qib_release_user_pages(&p, /* vaddr */, 1); } } done: @@ -1796,7 +1796,7 @@ static void unlock_expected_tids(struct dd->pageshadow[i] = NULL; pci_unmap_page(dd->pcidev, phys, PAGE_SIZE, PCI_DMA_FROMDEVICE); - qib_release_user_pages(&p, 1); + qib_release_user_pages(&p, /* vaddr */, 1); cnt++; } } --- a/drivers/infiniband/hw/qib/qib_user_pages.c +++ b/drivers/infiniband/hw/qib/qib_user_pages.c @@ -54,16 +54,12 @@ static void __qib_release_user_pages(str static int __qib_get_user_pages(unsigned long start_page, size_t num_pages, struct page **p, struct vm_area_struct **vma) { - unsigned long lock_limit; size_t got; int ret; - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; - - if (num_pages > lock_limit && !capable(CAP_IPC_LOCK)) { - ret = -ENOMEM; + ret = mm_mpin(start_page, num_pages * PAGE_SIZE); + if (ret) goto bail; - } for (got = 0; got < num_pages; got += ret) { ret = get_user_pages(current, current->mm, @@ -74,13 +70,12 @@ static int __qib_get_user_pages(unsigned goto bail_release; } - current->mm->pinned_vm += num_pages; - ret = 0; goto bail; bail_release: __qib_release_user_pages(p, got, 0); + mm_munpin(start_page, num_pages * PAGE_SIZE); bail: return ret; } @@ -143,15 +138,16 @@ int qib_get_user_pages(unsigned long sta return ret; } -void qib_release_user_pages(struct page **p, size_t num_pages) +void qib_release_user_pages(struct page **p, unsigned long start_page, size_t num_pages) { if (current->mm) /* during close after signal, mm can be NULL */ down_write(¤t->mm->mmap_sem); __qib_release_user_pages(p, num_pages, 1); + if (current->mm) { - current->mm->pinned_vm -= num_pages; + mm_munpin(start_page, num_pages * PAGE_SIZE); up_write(¤t->mm->mmap_sem); } } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/