Message ID | 20190115181300.27547-5-dave@stgolabs.net (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | mm: make pinned_vm atomic and simplify users | expand |
On Tue, Jan 15, 2019 at 10:12:58AM -0800, Davidlohr Bueso wrote: > This driver already uses gup_fast() and thus we can just drop > the mmap_sem protection around the pinned_vm counter. Note that > the window between when hfi1_can_pin_pages() is called and the > actual counter is incremented remains the same as mmap_sem was > _only_ used for when ->pinned_vm was touched. > > Cc: mike.marciniszyn@intel.com > Cc: dennis.dalessandro@intel.com > Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: Ira Weiny <ira.weiny@intel.com> > --- > drivers/infiniband/hw/hfi1/user_pages.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/drivers/infiniband/hw/hfi1/user_pages.c b/drivers/infiniband/hw/hfi1/user_pages.c > index df86a596d746..f0c6f219f575 100644 > --- a/drivers/infiniband/hw/hfi1/user_pages.c > +++ b/drivers/infiniband/hw/hfi1/user_pages.c > @@ -91,9 +91,7 @@ bool hfi1_can_pin_pages(struct hfi1_devdata *dd, struct mm_struct *mm, > /* Convert to number of pages */ > size = DIV_ROUND_UP(size, PAGE_SIZE); > > - down_read(&mm->mmap_sem); > pinned = atomic_long_read(&mm->pinned_vm); > - up_read(&mm->mmap_sem); > > /* First, check the absolute limit against all pinned pages. */ > if (pinned + npages >= ulimit && !can_lock) > @@ -111,9 +109,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t np > if (ret < 0) > return ret; > > - down_write(&mm->mmap_sem); > atomic_long_add(ret, &mm->pinned_vm); > - up_write(&mm->mmap_sem); > > return ret; > } > @@ -130,8 +126,6 @@ void hfi1_release_user_pages(struct mm_struct *mm, struct page **p, > } > > if (mm) { /* during close after signal, mm can be NULL */ > - down_write(&mm->mmap_sem); > atomic_long_sub(npages, &mm->pinned_vm); > - up_write(&mm->mmap_sem); > } > } > -- > 2.16.4 >
diff --git a/drivers/infiniband/hw/hfi1/user_pages.c b/drivers/infiniband/hw/hfi1/user_pages.c index df86a596d746..f0c6f219f575 100644 --- a/drivers/infiniband/hw/hfi1/user_pages.c +++ b/drivers/infiniband/hw/hfi1/user_pages.c @@ -91,9 +91,7 @@ bool hfi1_can_pin_pages(struct hfi1_devdata *dd, struct mm_struct *mm, /* Convert to number of pages */ size = DIV_ROUND_UP(size, PAGE_SIZE); - down_read(&mm->mmap_sem); pinned = atomic_long_read(&mm->pinned_vm); - up_read(&mm->mmap_sem); /* First, check the absolute limit against all pinned pages. */ if (pinned + npages >= ulimit && !can_lock) @@ -111,9 +109,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t np if (ret < 0) return ret; - down_write(&mm->mmap_sem); atomic_long_add(ret, &mm->pinned_vm); - up_write(&mm->mmap_sem); return ret; } @@ -130,8 +126,6 @@ void hfi1_release_user_pages(struct mm_struct *mm, struct page **p, } if (mm) { /* during close after signal, mm can be NULL */ - down_write(&mm->mmap_sem); atomic_long_sub(npages, &mm->pinned_vm); - up_write(&mm->mmap_sem); } }
This driver already uses gup_fast() and thus we can just drop the mmap_sem protection around the pinned_vm counter. Note that the window between when hfi1_can_pin_pages() is called and the actual counter is incremented remains the same as mmap_sem was _only_ used for when ->pinned_vm was touched. Cc: mike.marciniszyn@intel.com Cc: dennis.dalessandro@intel.com Signed-off-by: Davidlohr Bueso <dbueso@suse.de> --- drivers/infiniband/hw/hfi1/user_pages.c | 6 ------ 1 file changed, 6 deletions(-)