All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@mellanox.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"dledford@redhat.com" <dledford@redhat.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 6/6] drivers/IB,core: reduce scope of mmap_sem
Date: Tue, 15 Jan 2019 20:53:16 +0000	[thread overview]
Message-ID: <20190115205311.GD22031@mellanox.com> (raw)
In-Reply-To: <20190115181300.27547-7-dave@stgolabs.net>

On Tue, Jan 15, 2019 at 10:13:00AM -0800, Davidlohr Bueso wrote:
> ib_umem_get() uses gup_longterm() and relies on the lock to
> stabilze the vma_list, so we cannot really get rid of mmap_sem
> altogether, but now that the counter is atomic, we can get of
> some complexity that mmap_sem brings with only pinned_vm.
> 
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
>  drivers/infiniband/core/umem.c | 41 ++---------------------------------------
>  1 file changed, 2 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
> index bf556215aa7e..baa2412bf6fb 100644
> +++ b/drivers/infiniband/core/umem.c
> @@ -160,15 +160,12 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
>  
>  	lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
>  
> -	down_write(&mm->mmap_sem);
> -	new_pinned = atomic_long_read(&mm->pinned_vm) + npages;
> +	new_pinned = atomic_long_add_return(npages, &mm->pinned_vm);
>  	if (new_pinned > lock_limit && !capable(CAP_IPC_LOCK)) {

I thought a patch had been made for this to use check_overflow...

npages is controlled by userspace, so can we protect pinned_vm from
overflow in some way that still allows it to be atomic?

Jason

  parent reply	other threads:[~2019-01-15 20:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 18:12 [PATCH -next 0/6] mm: make pinned_vm atomic and simplify users Davidlohr Bueso
2019-01-15 18:12 ` [PATCH 1/6] mm: make mm->pinned_vm an atomic counter Davidlohr Bueso
2019-01-15 20:28   ` Ira Weiny
2019-01-15 18:12 ` [PATCH 3/6] drivers/IB,qib: do not use mmap_sem Davidlohr Bueso
2019-01-15 20:29   ` Ira Weiny
2019-01-15 18:12 ` [PATCH 4/6] drivers/IB,hfi1: do not se mmap_sem Davidlohr Bueso
2019-01-15 20:29   ` Ira Weiny
2019-01-15 18:12 ` [PATCH 5/6] drivers/IB,usnic: reduce scope of mmap_sem Davidlohr Bueso
2019-01-15 20:30   ` Ira Weiny
2019-01-17 23:41   ` Parvi Kaustubhi (pkaustub)
2019-01-15 18:13 ` [PATCH 6/6] drivers/IB,core: " Davidlohr Bueso
2019-01-15 20:30   ` Ira Weiny
2019-01-15 20:53   ` Jason Gunthorpe [this message]
2019-01-15 21:12     ` Matthew Wilcox
2019-01-15 21:17       ` Jason Gunthorpe
2019-01-16 16:00         ` Davidlohr Bueso
2019-01-16 17:02           ` Jason Gunthorpe
2019-01-16 17:06             ` Matthew Wilcox
2019-01-16 17:29               ` Jason Gunthorpe
2019-01-15 18:18 ` [PATCH -next 0/6] mm: make pinned_vm atomic and simplify users Davidlohr Bueso
     [not found] ` <20190115181300.27547-3-dave@stgolabs.net>
2019-01-15 20:28   ` [PATCH 2/6] mic/scif: do not use mmap_sem Ira Weiny
  -- strict thread matches above, loose matches on Subject: below --
2019-01-21 17:42 [PATCH v2 -next 0/6] mm: make pinned_vm atomic and simplify users Davidlohr Bueso
2019-01-21 17:42 ` [PATCH 6/6] drivers/IB,core: reduce scope of mmap_sem Davidlohr Bueso
2019-01-21 18:32   ` Jason Gunthorpe
2019-01-21 19:12     ` Davidlohr Bueso
2019-01-21 21:53   ` Christopher Lameter
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 6/6] drivers/IB,core: reduce scope of 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=20190115205311.GD22031@mellanox.com \
    --to=jgg@mellanox.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=dledford@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.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.