From: Joel Fernandes <joelagnelf@nvidia.com>
To: "paulmck@kernel.org" <paulmck@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joel@joelfernandes.org>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun.feng@gmail.com>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>,
"rcu@vger.kernel.org" <rcu@vger.kernel.org>
Subject: Re: [PATCH 2/3] rcu: Add warning to ensure rcu_seq_done_exact() is working
Date: Wed, 26 Mar 2025 22:50:13 +0000 [thread overview]
Message-ID: <E9D67C85-37FD-4BA7-990D-2BA2ED7E5963@nvidia.com> (raw)
In-Reply-To: <4a40eba2-ebd3-42a8-a25f-b7a0ff94256b@paulmck-laptop>
> On Mar 26, 2025, at 6:36 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
>
> On Mon, Mar 24, 2025 at 01:01:54PM -0400, Joel Fernandes wrote:
>> The previous patch improved the rcu_seq_done_exact() function by adding
>> a meaningful constant for the guardband.
>>
>> Ensure that this is working for the future by a quick check during
>> rcu_gp_init().
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>
> This is a good test for the guardband being way too short.
Thanks. Let me know if I could add your review tag!
>
> Are there other tests the should be run, possibly on a separate gp_seq
> used only for testing? Should the test below be under CONFIG_PROVE_RCU?
Yes, I could move it to PROVE RCU and it should be sufficient for testing.
The other test I was working on is to force the counter wrapping and hence gpwrap which is related.
Maybe we could also some testing around false negatives not happening too often (for examples with the rcu_seq_done()).
I will add more tests if I come across usecases.
Thanks!
Joel
>
> Thanx, Paul
>
>> ---
>> kernel/rcu/tree.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
>> index 659f83e71048..29ddbcbea25e 100644
>> --- a/kernel/rcu/tree.c
>> +++ b/kernel/rcu/tree.c
>> @@ -1798,6 +1798,7 @@ static noinline_for_stack bool rcu_gp_init(void)
>> struct rcu_data *rdp;
>> struct rcu_node *rnp = rcu_get_root();
>> bool start_new_poll;
>> + unsigned long old_gp_seq;
>>
>> WRITE_ONCE(rcu_state.gp_activity, jiffies);
>> raw_spin_lock_irq_rcu_node(rnp);
>> @@ -1825,7 +1826,11 @@ static noinline_for_stack bool rcu_gp_init(void)
>> */
>> start_new_poll = rcu_sr_normal_gp_init();
>> /* Record GP times before starting GP, hence rcu_seq_start(). */
>> + old_gp_seq = rcu_state.gp_seq;
>> rcu_seq_start(&rcu_state.gp_seq);
>> + /* Ensure that rcu_seq_done_exact() guardband doesn't give false positives. */
>> + WARN_ON_ONCE(rcu_seq_done_exact(&old_gp_seq, rcu_seq_snap(&rcu_state.gp_seq)));
>> +
>> ASSERT_EXCLUSIVE_WRITER(rcu_state.gp_seq);
>> trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("start"));
>> rcu_poll_gp_seq_start(&rcu_state.gp_seq_polled_snap);
>> --
>> 2.43.0
>>
next prev parent reply other threads:[~2025-03-26 22:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 17:01 [PATCH 0/3] rcu_seq_done_exact() improvements Joel Fernandes
2025-03-24 17:01 ` [PATCH 1/3] rcu: Replace magic number with meaningful constant in rcu_seq_done_exact() Joel Fernandes
2025-03-26 22:33 ` Paul E. McKenney
2025-03-26 22:42 ` Joel Fernandes
2025-03-27 17:09 ` Paul E. McKenney
2025-03-28 2:31 ` Joel Fernandes
2025-03-30 22:10 ` Frederic Weisbecker
2025-03-31 18:28 ` Paul E. McKenney
2025-03-31 21:14 ` Frederic Weisbecker
2025-03-31 21:29 ` Paul E. McKenney
2025-04-01 13:38 ` Frederic Weisbecker
2025-04-02 4:24 ` Paul E. McKenney
2025-03-24 17:01 ` [PATCH 2/3] rcu: Add warning to ensure rcu_seq_done_exact() is working Joel Fernandes
2025-03-26 22:36 ` Paul E. McKenney
2025-03-26 22:50 ` Joel Fernandes [this message]
2025-03-26 23:21 ` Paul E. McKenney
2025-03-24 17:01 ` [PATCH 3/3] rcu: Comment on the extraneous delta test on rcu_seq_done_exact() Joel Fernandes
2025-03-26 22:37 ` Paul E. McKenney
2025-03-26 22:51 ` Joel Fernandes
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=E9D67C85-37FD-4BA7-990D-2BA2ED7E5963@nvidia.com \
--to=joelagnelf@nvidia.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
/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®