From: Kunwu Chan <kunwu.chan@gmail.com>
To: jiangshanlai@gmail.com, paulmck@kernel.org, josh@joshtriplett.org
Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
Kunwu Chan <kunwu.chan@gmail.com>
Subject: [PATCH v3] srcutree: Don't transition atomic SRCU to big in srcu_gp_end()
Date: Fri, 11 Sep 2026 15:21:25 +0800 [thread overview]
Message-ID: <20260911072125.2268530-1-kunwu.chan@gmail.com> (raw)
Atomic SRCU must remain in the small size state. Warn if this
invariant is violated and avoid transitioning to big in that case.
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
Changes since v2:
- Also prevent the transition when the atomic SRCU size-state
invariant is violated, per Paul McKenney's suggestion.
-v2: https://lore.kernel.org/rcu/20260910084629.3695383-1-kunwu.chan@gmail.com/
Changes since v1:
- Drop the !is_atomic guard from v1 and add WARN_ON_ONCE() instead,
per Paul McKenney's suggestion.
- v1: https://lore.kernel.org/rcu/20260907075829.2073224-8-kunwu.chan@linux.dev/
---
kernel/rcu/srcutree.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 84c022ec8e09..07db4e459b30 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1073,8 +1073,11 @@ static void srcu_gp_end(struct srcu_struct *ssp, bool is_atomic)
raw_spin_unlock_irq_rcu_node(sup);
}
- /* Transition to big if needed. */
- if (ss_state != SRCU_SIZE_SMALL && ss_state != SRCU_SIZE_BIG) {
+ /* Transition to big if needed, but never for atomic SRCU. */
+ if (ssp->srcu_reader_flavor == SRCU_READ_FLAVOR_ATOMIC &&
+ ss_state != SRCU_SIZE_SMALL) {
+ WARN_ON_ONCE(1);
+ } else if (ss_state != SRCU_SIZE_SMALL && ss_state != SRCU_SIZE_BIG) {
if (ss_state == SRCU_SIZE_ALLOC)
init_srcu_struct_nodes(ssp, GFP_KERNEL);
else
--
2.43.0
next reply other threads:[~2026-09-11 7:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 7:21 Kunwu Chan [this message]
2026-09-11 16:37 ` [PATCH v3] srcutree: Don't transition atomic SRCU to big in srcu_gp_end() Paul E. McKenney
2026-09-12 12:41 ` KunWu Chan
2026-09-13 12:47 ` Bradley Morgan
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=20260911072125.2268530-1-kunwu.chan@gmail.com \
--to=kunwu.chan@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--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