Re: [PATCH 2/3] futex: Use RCU-based per-CPU reference counting instead of rcuref_t
From: Sebastian Andrzej Siewior
Date: Tue Jul 08 2025 - 09:17:59 EST
On 2025-07-08 20:01:56 [+0800], Hillf Danton wrote:
> On Tue, 8 Jul 2025 11:16:26 +0200 Sebastian Andrzej Siewior wrote:
> > On 2025-07-08 16:56:39 [+0800], Hillf Danton wrote:
> > > On Mon, 7 Jul 2025 16:36:22 +0200 Sebastian Andrzej Siewior wrote:
> > > > +static bool futex_ref_get(struct futex_private_hash *fph)
> > > > +{
> > > > + struct mm_struct *mm = fph->mm;
> > > > +
> > > > + guard(rcu)();
> > > > +
> > > Like regular refcount_t, it is buggy to touch fph if futex_atomic drops
> > > to 0. And more important guard(rcu) does not prevent it from dropping to 0.
> >
> > What is your intention with this? There is an inc-if-not-zero to ensure
>
> I am just simply wondering why get and put do not work without the rcu guard?
To ensure every get/ put user within this section observed the switch to
atomics. There is this call-rcu callback which performs the switch. This
one will be invoked after every user, that was user the per-CPU counter,
is gone and using the atomic one.
Sebastian