From: Jason Gunthorpe <jgg@nvidia.com>
To: Bernard Metzler <bmt@zurich.ibm.com>
Cc: linux-rdma@vger.kernel.org, leonro@nvidia.com, apopple@nvidia.com
Subject: Re: [PATCH] RDMA/siw: Fix user page pinning accounting
Date: Mon, 30 Jan 2023 09:29:12 -0400 [thread overview]
Message-ID: <Y9fGKMP4sA7+8/m7@nvidia.com> (raw)
In-Reply-To: <20230130132804.223144-1-bmt@zurich.ibm.com>
On Mon, Jan 30, 2023 at 02:28:04PM +0100, Bernard Metzler wrote:
> To avoid racing with other user memory reservations, immediately
> account full amount of pages to be pinned.
>
> Fixes: 2251334dcac9 ("rdma/siw: application buffer management")
> Reported-by: Jason Gunthorpe <jgg@nvidia.com>
> Suggested-by: Alistair Popple <apopple@nvidia.com>
> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
> ---
> drivers/infiniband/sw/siw/siw_mem.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c
> index b2b33dd3b4fa..7cf4d927bbab 100644
> --- a/drivers/infiniband/sw/siw/siw_mem.c
> +++ b/drivers/infiniband/sw/siw/siw_mem.c
> @@ -398,7 +398,8 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)
>
> mlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
>
> - if (num_pages + atomic64_read(&mm_s->pinned_vm) > mlock_limit) {
> + if (num_pages + atomic64_add_return(num_pages, &mm_s->pinned_vm) >
> + mlock_limit) {
???
Doesn't atomic_add_return return the result of adding num_pages and
pinned_vm? Then you add it again?
Jason
next prev parent reply other threads:[~2023-01-30 13:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 13:28 [PATCH] RDMA/siw: Fix user page pinning accounting Bernard Metzler
2023-01-30 13:29 ` Jason Gunthorpe [this message]
2023-01-30 13:30 ` Bernard Metzler
2023-01-30 13:32 Bernard Metzler
2023-01-31 0:09 ` Alistair Popple
2023-01-31 11:05 ` Bernard Metzler
2023-01-31 23:10 ` Alistair Popple
2023-02-01 11:55 Bernard Metzler
2023-02-02 7:44 ` Alistair Popple
2023-02-02 10:10 Bernard Metzler
2023-02-06 12:48 ` Leon Romanovsky
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=Y9fGKMP4sA7+8/m7@nvidia.com \
--to=jgg@nvidia.com \
--cc=apopple@nvidia.com \
--cc=bmt@zurich.ibm.com \
--cc=leonro@nvidia.com \
--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.