Re: [PATCH v12 15/21] futex: Allow to make the private hash immutable

From: Sebastian Andrzej Siewior
Date: Mon May 05 2025 - 03:14:55 EST


On 2025-05-02 20:01:54 [+0200], Peter Zijlstra wrote:
> On Wed, Apr 16, 2025 at 06:29:15PM +0200, Sebastian Andrzej Siewior wrote:
> > My initial testing showed that
> > perf bench futex hash
> >
> > reported less operations/sec with private hash. After using the same
> > amount of buckets in the private hash as used by the global hash then
> > the operations/sec were about the same.
> >
> > This changed once the private hash became resizable. This feature added
> > a RCU section and reference counting via atomic inc+dec operation into
> > the hot path.
> > The reference counting can be avoided if the private hash is made
> > immutable.
> > Extend PR_FUTEX_HASH_SET_SLOTS by a fourth argument which denotes if the
> > private should be made immutable. Once set (to true) the a further
> > resize is not allowed (same if set to global hash).
> > Add PR_FUTEX_HASH_GET_IMMUTABLE which returns true if the hash can not
> > be changed.
> > Update "perf bench" suite.
>
> Does the below make sense? This changes arg4 into a flags field and uses
> bit0 for immutable.
>
> (the point where I got upset is where arg4==2 was accepted :-)

I see, it makes sense. It makes sense and leaves room for later.

Sebastian