[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <emn7ljwqan26qlafww3gzolh3ydxgl5obbpzkoa2tlj6bjazlk@jw2ilnkbawog>
Date: Wed, 19 Feb 2025 19:32:16 -0500
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Joel Fernandes <joelagnelf@...dia.com>
Cc: paulmck@...nel.org, linux-kernel@...r.kernel.org,
Lai Jiangshan <jiangshanlai@...il.com>, Josh Triplett <josh@...htriplett.org>,
Steven Rostedt <rostedt@...dmis.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Neeraj Upadhyay <Neeraj.Upadhyay@....com>, rcu@...r.kernel.org
Subject: Re: [PATCH v2 -rcu] srcu: Use rcu_seq_done_exact() for polling API
On Wed, Feb 19, 2025 at 06:45:07PM -0500, Joel Fernandes wrote:
>
>
> 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@....com>
> >>>> Signed-off-by: Joel Fernandes <joelagnelf@...dia.com>
> >>>
> >>> Reviewed-by: Paul E. McKenney <paulmck@...nel.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?
Reviewed-by: Kent Overstreet <kent.overstreet@...ux.dev>
Powered by blists - more mailing lists