public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Maxim Samoylov <max7255@meta.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Christian Benvenuti <benve@cisco.com>,
	Bernard Metzler <bmt@zurich.ibm.com>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>
Subject: Re: [PATCH] IB: fix memlock limit handling code
Date: Wed, 27 Sep 2023 20:53:55 +0300	[thread overview]
Message-ID: <20230927175355.GQ1642130@unreal> (raw)
In-Reply-To: <f83fcbe0-308c-4485-ad96-ede52608e141@meta.com>

On Thu, Sep 21, 2023 at 04:31:44PM +0000, Maxim Samoylov wrote:
> On 18/09/2023 14:09, Leon Romanovsky wrote:
> > On Fri, Sep 15, 2023 at 01:03:53PM -0700, Maxim Samoylov wrote:
> >> This patch fixes handling for RLIM_INFINITY value uniformly across
> >> the infiniband/rdma subsystem.
> >>
> >> Currently infinity constant is treated as actual limit
> >> value, which can trigger unexpected ENOMEM errors in
> >> corner-case configurations
> > 
> > Can you please provide an example and why these corner cases are
> > important?
> > 
> 
> Actually, I’ve come up with proposing this minor patch to avoid
> confusion I got while investigating production case with
> ib_reg_user_mr() returning ENOMEM for (presumably) no particular reason.
> 
> Along with that I came across some curious repro.
> Consider the following code:
> 
> 
> addr = mmap(... , PROT_READ | PROT_WRITE,
>              MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, ... )
> 
> /* IB objects initialisation */
> 
> while (1) {
> 
> ibv_reg_mr_iova(pd, (void*)addr, LENGTH, (uint64_t)addr,
>      IBV_ACCESS_LOCAL_WRITE|IBV_ACCESS_REMOTE_WRITE|
>      IBV_ACCESS_REMOTE_READ|IBV_ACCESS_RELAXED_ORDERING);
> 
> }
> 
> 
> This cycle can work almost eternally without triggering any errors
> - until the kernel will run out of memory or we finally bail out after
> comparison against thread memlock rlimit.
> 
> As far as I understand, this means we can continuously register the same
> memory region for a single device over and over, bloating number of
> per-device MRs. Don't know for sure if it's wrong, but
> I assume it constitutes some at least logical pitfall.
> 
> Furthermore, it also bumps per-mm VmPin counter over and over without
> increasing any other memory usage metric,
> which is probably misguiding from the memory accounting perspective.
> 
> > BTW, The patch looks good to me, just need more information in commit message.
> >
> Thanks for your quick response!
> And I apologise that my answer took so long.

Please improve your commit message, remove "fix" word as this patch
doesn't really fix anything and send v2.

Thanks

> 
> > Thanks
> > 
> > 
> >>
> 

      parent reply	other threads:[~2023-09-27 17:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 20:03 [PATCH] IB: fix memlock limit handling code Maxim Samoylov
2023-09-18 12:09 ` Leon Romanovsky
2023-09-21 16:31   ` Maxim Samoylov
2023-09-21 16:49     ` Jason Gunthorpe
2023-09-27 17:53     ` Leon Romanovsky [this message]

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=20230927175355.GQ1642130@unreal \
    --to=leon@kernel.org \
    --cc=benve@cisco.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=max7255@meta.com \
    --cc=vadim.fedorenko@linux.dev \
    /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