From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH rcu 3/4] srcu: Make Tiny SRCU poll_state_synchronize_srcu() more precise
Date: Wed, 31 Aug 2022 11:14:34 -0700 [thread overview]
Message-ID: <20220831181435.2695936-3-paulmck@kernel.org> (raw)
In-Reply-To: <20220831181349.GA2695341@paulmck-ThinkPad-P17-Gen-1>
This commit applies the more-precise grace-period-state check used by
rcu_seq_done_exact() to poll_state_synchronize_srcu(). This is important
because Tiny SRCU uses a 16-bit counter, which can wrap quite quickly.
If counter wrap continues to be a problem, then expanding ->srcu_idx
and ->srcu_idx_max to 32 bits might be warranted.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/srcutiny.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index 92c002d654828..a2af24f214676 100644
--- a/kernel/rcu/srcutiny.c
+++ b/kernel/rcu/srcutiny.c
@@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);
*/
bool poll_state_synchronize_srcu(struct srcu_struct *ssp, unsigned long cookie)
{
- bool ret = USHORT_CMP_GE(READ_ONCE(ssp->srcu_idx), cookie);
+ unsigned short cur_s = READ_ONCE(ssp->srcu_idx);
barrier();
- return ret;
+ return USHORT_CMP_GE(cur_s, cookie) || USHORT_CMP_LT(cur_s, cookie - 3);
}
EXPORT_SYMBOL_GPL(poll_state_synchronize_srcu);
--
2.31.1.189.g2e36527f23
next prev parent reply other threads:[~2022-08-31 18:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 18:13 [PATCH rcu 0/7] SRCU polled grace-period updates for v6.1 Paul E. McKenney
2022-08-31 18:14 ` [PATCH rcu 1/4] rcutorture: Make "srcud" option also test polled grace-period API Paul E. McKenney
2022-08-31 18:14 ` [PATCH rcu 2/4] srcu: Add GP and maximum requested GP to Tiny SRCU rcutorture output Paul E. McKenney
2022-08-31 18:14 ` Paul E. McKenney [this message]
2022-08-31 18:14 ` [PATCH rcu 4/4] srcu: Make Tiny SRCU use full-sized grace-period counters Paul E. McKenney
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=20220831181435.2695936-3-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.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®