All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, willy@infradead.org,
	mhocko@kernel.org, mgorman@techsingularity.net,
	jglisse@redhat.com, ldufour@linux.vnet.ibm.com,
	dave@stgolabs.net, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 10/14] net: teach the mm about range locking
Date: Mon, 20 May 2019 21:52:38 -0700	[thread overview]
Message-ID: <20190521045242.24378-11-dave@stgolabs.net> (raw)
In-Reply-To: <20190521045242.24378-1-dave@stgolabs.net>

Conversion is straightforward, mmap_sem is used within the
the same function context most of the time. No change in
semantics.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 net/ipv4/tcp.c     | 5 +++--
 net/xdp/xdp_umem.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 53d61ca3ac4b..2be929dcafa8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1731,6 +1731,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
 	struct tcp_sock *tp;
 	int inq;
 	int ret;
+	DEFINE_RANGE_LOCK_FULL(mmrange);
 
 	if (address & (PAGE_SIZE - 1) || address != zc->address)
 		return -EINVAL;
@@ -1740,7 +1741,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
 
 	sock_rps_record_flow(sk);
 
-	down_read(&current->mm->mmap_sem);
+	mm_read_lock(current->mm, &mmrange);
 
 	ret = -EINVAL;
 	vma = find_vma(current->mm, address);
@@ -1802,7 +1803,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
 		frags++;
 	}
 out:
-	up_read(&current->mm->mmap_sem);
+	mm_read_unlock(current->mm, &mmrange);
 	if (length) {
 		tp->copied_seq = seq;
 		tcp_rcv_space_adjust(sk);
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 2b18223e7eb8..2bf444fb998d 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -246,16 +246,17 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem)
 	unsigned int gup_flags = FOLL_WRITE;
 	long npgs;
 	int err;
+	DEFINE_RANGE_LOCK_FULL(mmrange);
 
 	umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs),
 			    GFP_KERNEL | __GFP_NOWARN);
 	if (!umem->pgs)
 		return -ENOMEM;
 
-	down_read(&current->mm->mmap_sem);
+	mm_read_lock(current->mm, &mmrange);
 	npgs = get_user_pages(umem->address, umem->npgs,
 			      gup_flags | FOLL_LONGTERM, &umem->pgs[0], NULL);
-	up_read(&current->mm->mmap_sem);
+	mm_read_unlock(current->mm, &mmrange);
 
 	if (npgs != umem->npgs) {
 		if (npgs >= 0) {
-- 
2.16.4


  parent reply	other threads:[~2019-05-21  4:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21  4:52 [RFC PATCH 00/14] mmap_sem range locking Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 01/14] interval-tree: build unconditionally Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 02/14] Introduce range reader/writer lock Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 03/14] mm: introduce mm locking wrappers Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 04/14] mm: teach pagefault paths about range locking Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 05/14] mm: remove some BUG checks wrt mmap_sem Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 06/14] mm: teach the mm about range locking Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 07/14] fs: " Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 08/14] arch/x86: " Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 09/14] virt: " Davidlohr Bueso
2019-05-21  4:52 ` Davidlohr Bueso [this message]
2019-05-21  4:52 ` [PATCH 11/14] ipc: " Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 12/14] kernel: " Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 13/14] drivers: " Davidlohr Bueso
2019-05-21  4:52 ` [PATCH 14/14] mm: convert mmap_sem to range mmap_lock 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=20190521045242.24378-11-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=akpm@linux-foundation.org \
    --cc=dbueso@suse.de \
    --cc=jglisse@redhat.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.