From: Matthew Wilcox <willy@infradead.org>
To: Mateusz Guzik <mjguzik@gmail.com>
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: Sun, 23 Nov 2025 21:45:20 +0000 [thread overview]
Message-ID: <aSOAcMSYsQ22kPid@casper.infradead.org> (raw)
In-Reply-To: <CAGudoHFjqRPao2DOF35rHrYDOAjVC+dcWJ2kGm+7JqnMNk=o2A@mail.gmail.com>
On Sun, Nov 23, 2025 at 05:39:16PM +0100, Mateusz Guzik wrote:
> I have some recollection we talked about this on irc long time ago.
>
> It is my *suspicion* this would be best served with a sparse bitmap +
> a hash table.
Maybe! I've heard other people speculate that would be a better data
structure. I know we switched away from a hash table for the page
cache, but that has a different usage pattern where it's common to go
from page N to page N+1, N+2, ... Other than ps, I don't think we often
have that pattern for PIDs.
> Such a solution was already present, but it got replaced by
> 95846ecf9dac5089 ("pid: replace pid bitmap implementation with IDR
> API").
>
> Commit message cites the following bench results:
> The following are the stats for ps, pstree and calling readdir on /proc
> for 10,000 processes.
>
> ps:
> With IDR API With bitmap
> real 0m1.479s 0m2.319s
> user 0m0.070s 0m0.060s
> sys 0m0.289s 0m0.516s
>
> pstree:
> With IDR API With bitmap
> real 0m1.024s 0m1.794s
> user 0m0.348s 0m0.612s
> sys 0m0.184s 0m0.264s
>
> proc:
> With IDR API With bitmap
> real 0m0.059s 0m0.074s
> user 0m0.000s 0m0.004s
> sys 0m0.016s 0m0.016s
>
> Impact on clone was not benchmarked afaics.
It shouldn't be too much effort for you to check out 95846ecf9dac5089
and 95846ecf9dac5089^ to run your benchmark on both? That would seem
like the cheapest way of assessing the performance of hash+bitmap
vs IDR.
> Regardless, in order to give whatever replacement a fair perf eval
> against idr, at least the following 2 bits need to get sorted out:
> - the self-induced repeat locking of pidmap_lock
> - high cost of kmalloc (to my understanding waiting for sheaves4all)
The nice thing about XArray (compared to IDR) is that there's no
requirement to preallocate. Only 1.6% of xa_alloc() calls result in
calling slab. The downside is that means that XArray needs to know
where its lock is (ie xa_lock) so that it can drop the lock in order to
allocate without using GFP_ATOMIC.
At one point I kind of had a plan to create a multi-xarray where you had
multiple xarrays that shared a single lock. Or maybe this sharding is
exactly what's needed; I haven't really analysed the pid locking to see
what's needed.
next prev parent reply other threads:[~2025-11-23 21:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-23 6:30 [PATCH 0/3] further damage-control lack of clone scalability 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 [this message]
2025-11-23 22:33 ` Mateusz Guzik
2025-11-24 4:03 ` Mateusz Guzik
2025-12-03 8:37 ` Mateusz Guzik
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=aSOAcMSYsQ22kPid@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
/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.