mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: paulmck@kernel.org, linux-kernel@vger.kernel.org,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>,
	rcu@vger.kernel.org
Subject: Re: [PATCH v2 -rcu] srcu: Use rcu_seq_done_exact() for polling API
Date: Wed, 19 Feb 2025 18:45:07 -0500	[thread overview]
Message-ID: <a7d1297d-afea-4253-9139-8c44e953fd43@nvidia.com> (raw)
In-Reply-To: <dyzwqkaldmoi7qircj6plzp6wnghvkmrxjbaf4ejvv7xy6t4p2@ea7mpkosxju2>



On 2/19/2025 4:07 PM, Kent Overstreet wrote:
> On Wed, Feb 19, 2025 at 08:29:47AM -0500, Joel Fernandes wrote:
>>
>>
>> On 2/19/2025 8:22 AM, Paul E. McKenney wrote:
>>> On Wed, Feb 19, 2025 at 07:43:08AM -0500, Joel Fernandes wrote:
>>>> poll_state_synchronize_srcu() uses rcu_seq_done() unlike
>>>> poll_state_synchronize_rcu() which uses rcu_seq_done_exact().
>>>>
>>>> The  rcu_seq_done_exact() makes more sense for polling API, as with
>>>> this API, there is a higher chance that there is a significant delay
>>>> between the get_state..() and poll_state..() calls since a cookie
>>>> can be stored and reused at a later time. During such a delay, if
>>>> the gp_seq counter progresses more than ULONG_MAX/2 distance, then
>>>> poll_state..() may return false for a long time unwantedly.
>>>>
>>>> Fix by using the more accurate rcu_seq_done_exact() API which is
>>>> exactly what straight RCU's polling does.
>>>>
>>>> It may make sense, as future work, to add debug code here as well, where
>>>> we compare a physical timestamp between get_state..() and poll_state()
>>>> calls and yell if significant time has past but the grace period has
>>>> still not progressed.
>>>>
>>>> Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
>>>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>>>
>>> Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
>>>
>>> But we should also run this by Kent Overstreet, given that bcachefs
>>> uses this.  Should be OK, given that bcachefs uses this API in the same
>>> way that it does poll_state_synchronize_rcu(), but still...
>>
>> Thanks Paul!  Adding Kent Overstreet to the email to raise any objections.
> 
> It sounds like rcu_done_exact() is indeed what we want - bcachefs uses
> this for determining when objects may be reclaimed (as is typical with
> rcu), so we don't want objects to be stranded a "significant time past
> the grace period".

Thanks for confirming. May I add your Reviewed-by tag as well?

> 
> Is there any additional cost? I'm not seeing rcu_done_exact() in Linus's
> tree yet. Minor additional overhead would be totally fine; we use this
> from fs/bcachefs/rcu_pending.c which doesn't call it for each object.

The additional overhead should be minimal. rcu_seq_done_exact() is the function.

thanks,

 -Joel


  reply	other threads:[~2025-02-19 23:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 12:43 Joel Fernandes
2025-02-19 13:22 ` Paul E. McKenney
2025-02-19 13:29   ` Joel Fernandes
2025-02-19 21:07     ` Kent Overstreet
2025-02-19 23:45       ` Joel Fernandes [this message]
2025-02-20  0:32         ` Kent Overstreet
2025-03-05 16:46 ` Boqun Feng

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=a7d1297d-afea-4253-9139-8c44e953fd43@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=Neeraj.Upadhyay@amd.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.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®