From: Davidlohr Bueso <dave@stgolabs.net>
To: jgg@ziepe.ca, akpm@linux-foundation.org
Cc: dledford@redhat.com, jgg@mellanox.com, jack@suse.cz,
willy@infradead.org, ira.weiny@intel.com,
linux-rdma@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, dave@stgolabs.net,
Davidlohr Bueso <dbueso@suse.det>
Subject: [PATCH 4/6] drivers/IB,hfi1: do not se mmap_sem
Date: Wed, 6 Feb 2019 09:59:18 -0800 [thread overview]
Message-ID: <20190206175920.31082-5-dave@stgolabs.net> (raw)
In-Reply-To: <20190206175920.31082-1-dave@stgolabs.net>
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.
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Davidlohr Bueso <dbueso@suse.det>
---
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 40a6e434190f..24b592c6522e 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 = atomic64_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);
atomic64_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);
atomic64_sub(npages, &mm->pinned_vm);
- up_write(&mm->mmap_sem);
}
}
--
2.16.4
next prev parent reply other threads:[~2019-02-06 17:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 17:59 [PATCH v3 0/6] mm: make pinned_vm atomic and simplify users Davidlohr Bueso
2019-02-06 17:59 ` [PATCH 1/6] mm: make mm->pinned_vm an atomic64 counter Davidlohr Bueso
2019-02-06 17:59 ` [PATCH 2/6] drivers/mic/scif: do not use mmap_sem Davidlohr Bueso
2019-02-06 17:59 ` [PATCH 3/6] drivers/IB,qib: optimize mmap_sem usage Davidlohr Bueso
2019-02-06 17:59 ` Davidlohr Bueso [this message]
2019-02-06 17:59 ` [PATCH 5/6] drivers/IB,usnic: reduce scope of mmap_sem Davidlohr Bueso
2019-02-06 17:59 ` [PATCH 6/6] drivers/IB,core: " Davidlohr Bueso
2019-02-07 1:31 ` [PATCH 7/6] Documentation/infiniband: update from locked to pinned_vm Davidlohr Bueso
2019-02-12 0:35 ` Weiny, Ira
2019-02-07 20:12 ` [PATCH v3 0/6] mm: make pinned_vm atomic and simplify users Jason Gunthorpe
-- strict thread matches above, loose matches on Subject: below --
2019-01-21 17:42 [PATCH v2 -next " Davidlohr Bueso
2019-01-21 17:42 ` [PATCH 4/6] drivers/IB,hfi1: do not se mmap_sem Davidlohr Bueso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190206175920.31082-5-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=dbueso@suse.det \
--cc=dledford@redhat.com \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=jgg@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).