From: Mateusz Guzik <mjguzik@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: oleg@redhat.com, brauner@kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
linux-mm@kvack.org
Subject: Re: [PATCH 0/3] further damage-control lack of clone scalability
Date: Wed, 3 Dec 2025 09:37:47 +0100 [thread overview]
Message-ID: <CAGudoHF1wjY5tF-aKVrjOHoSunSGTrGSrmm3nnmPArVzajTNYA@mail.gmail.com> (raw)
In-Reply-To: <aSMhj2Q6BTMNSsA4@casper.infradead.org>
On Sun, Nov 23, 2025 at 4:00 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sun, Nov 23, 2025 at 07:30:51AM +0100, Mateusz Guzik wrote:
> > When spawning and killing threads in separate processes in parallel the
> > primary bottleneck on the stock kernel is pidmap_lock, largely because
> > of a back-to-back acquire in the common case.
> >
> > Benchmark code at the end.
> >
> > With this patchset alloc_pid() only takes the lock once and consequently
> > alleviates the problem. While scalability improves, the lock remains the
> > primary bottleneck by a large margin.
> >
> > I believe idr is a poor choice for the task at hand to begin with, but
> > sorting out that out beyond the scope of this patchset. At the same time
> > any replacement would be best evaluated against a state where the
> > above relock problem is fixed.
>
> Good news! The IDR is deprecated. Bad news! I'm not 100% sure that
> the XArray is quite appropriate for this usecase. I am opposed to
> introducing more IDR APIs. Have you looked at converting to the XArray?
> Or do you have a better data structure in mind than the XArray?
>
Hi Willy,
in other responses I outlined what I suspect would be a viable long
term solution, very much not idr-based.
However, that's not something I'm likely to implement anytime soon and
I doubt there is someone willing to pick up the matter.
Whatever the long term solution and who/when implements it, the
current code avoidably loses out on some performance because of at
least two lock acquires on each fork instead of one.
At the moment it is structured in a way which makes it possible to
take the lock once with minor effort.
Leaving this in the current state results in a minor risk that someone
will make changes which turn fixing the scalability issue into a
massive problem.
With my patch as-is I can suffer some pain and avoid modifying
idr_prealloc, but at the same time I don't think the modification at
hand is particularly problematic. Notably it does not change any of
the internals.
So the question is if by "opposed to introducing more IDR APIs" you
mean you are just not fond of it, or is it a straight up NAK. Per the
explanation above, I think the change is tolerable in its own right
and I provided reasoning why I'm adding it in the first place.
If the latter, I'll see about massaging this to drop locks and retry
memory alloc.
next prev parent reply other threads:[~2025-12-03 8:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-23 6:30 Mateusz Guzik
2025-11-23 6:30 ` [PATCH 1/3] idr: add idr_prealloc_many Mateusz Guzik
2025-11-23 6:30 ` [PATCH 2/3] ns: pad refcount Mateusz Guzik
2025-11-23 18:58 ` Oleg Nesterov
2025-11-23 19:47 ` Mateusz Guzik
2025-11-24 18:25 ` Oleg Nesterov
2025-11-23 6:30 ` [PATCH 3/3] pid: only take pidmap_lock once on alloc Mateusz Guzik
2025-11-23 20:09 ` Oleg Nesterov
2025-11-23 22:48 ` Mateusz Guzik
2025-11-23 15:00 ` [PATCH 0/3] further damage-control lack of clone scalability Matthew Wilcox
2025-11-23 16:39 ` Mateusz Guzik
2025-11-23 21:45 ` Matthew Wilcox
2025-11-23 22:33 ` Mateusz Guzik
2025-11-24 4:03 ` Mateusz Guzik
2025-12-03 8:37 ` Mateusz Guzik [this message]
2025-12-03 9:18 ` Mateusz Guzik
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=CAGudoHF1wjY5tF-aKVrjOHoSunSGTrGSrmm3nnmPArVzajTNYA@mail.gmail.com \
--to=mjguzik@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox