mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Waiman Long <longman@redhat.com>
Subject: Re: [PATCH 2/3] futex: Use RCU-based per-CPU reference counting instead of rcuref_t
Date: Tue,  8 Jul 2025 20:01:56 +0800	[thread overview]
Message-ID: <20250708120156.2938-1-hdanton@sina.com> (raw)
In-Reply-To: <20250708091626.BYR6lG2J@linutronix.de>

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?

> this does not happen. And it has to drop to zero in order to get
> replaced.
> 
> > > +	if (smp_load_acquire(&fph->state) == FR_PERCPU) {
> > > +		this_cpu_inc(*mm->futex_ref);
> > > +		return true;
> > > +	}
> > > +
> > > +	return atomic_long_inc_not_zero(&mm->futex_atomic);
> > > +}
> > > +
> > > +static bool futex_ref_put(struct futex_private_hash *fph)
> > > +{
> > > +	struct mm_struct *mm = fph->mm;
> > > +
> > > +	guard(rcu)();
> > > +
> > > +	if (smp_load_acquire(&fph->state) == FR_PERCPU) {
> > > +		this_cpu_dec(*mm->futex_ref);
> > > +		return false;
> > > +	}
> > > +
> > > +	return atomic_long_dec_and_test(&mm->futex_atomic);
> > > +}
> 
> Sebastian

  reply	other threads:[~2025-07-08 12:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07 14:36 [PATCH 0/3] futex: Use RCU-based per-CPU reference counting Sebastian Andrzej Siewior
2025-07-07 14:36 ` [PATCH 1/3] selftests/futex: Adapt the private hash test to RCU related changes Sebastian Andrzej Siewior
2025-07-08  7:41   ` Peter Zijlstra
2025-07-08  8:01     ` Sebastian Andrzej Siewior
2025-07-10  8:08       ` Sebastian Andrzej Siewior
2025-07-07 14:36 ` [PATCH 2/3] futex: Use RCU-based per-CPU reference counting instead of rcuref_t Sebastian Andrzej Siewior
2025-07-08  6:51   ` Sebastian Andrzej Siewior
2025-07-08  8:56   ` Hillf Danton
2025-07-08  9:16     ` Sebastian Andrzej Siewior
2025-07-08 12:01       ` Hillf Danton [this message]
2025-07-08 13:15         ` Sebastian Andrzej Siewior
2025-07-08 22:00           ` Hillf Danton
2025-07-08 13:09   ` Sebastian Andrzej Siewior
2025-07-08 13:43   ` Waiman Long
2025-07-08 13:47     ` Sebastian Andrzej Siewior
2025-07-08 19:06       ` Peter Zijlstra
2025-07-10 15:58         ` Waiman Long
2025-07-07 14:36 ` [PATCH 3/3] futex: Make futex_private_hash_get() static Sebastian Andrzej Siewior
2025-07-08  7:50 ` [PATCH 0/3] futex: Use RCU-based per-CPU reference counting Peter Zijlstra
2025-07-08  8:02   ` Sebastian Andrzej Siewior

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=20250708120156.2938-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=bigeasy@linutronix.de \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=peterz@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

all inboxes | Powered by JetHome®