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@xxxxxxx> --- 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(¤t->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(¤t->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(¤t->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(¤t->mm->mmap_sem); + mm_read_unlock(current->mm, &mmrange); if (npgs != umem->npgs) { if (npgs >= 0) { -- 2.16.4