From: Joel Fernandes <jfern@kernel.org>
To: linux-kernel@vger.kernel.org,
"Paul E . McKenney" <paulmck@kernel.org>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Neeraj Upadhyay" <neeraj.upadhyay@kernel.org>,
"Joel Fernandes" <jfern@kernel.org>,
"Josh Triplett" <josh@joshtriplett.org>,
"Boqun Feng" <boqun@kernel.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>, "Onur Özkan" <work@onurozkan.dev>
Cc: rcu@vger.kernel.org, Yury Norov <ynorov@nvidia.com>
Subject: [PATCH for-v7.5 3/5] rcu: assert static storage for RCU sync and SRCU definitions
Date: Thu, 12 Nov 2026 19:49:42 -0500 [thread overview]
Message-ID: <20261113004946.2758197-4-jfern@kernel.org> (raw)
In-Reply-To: <20261113004946.2758197-1-jfern@kernel.org>
From: Yury Norov <ynorov@nvidia.com>
DEFINE_RCU_SYNC() contains a statically initialized wait queue. SRCU
static definitions similarly rely on persistent lockdep keys and, in
Tiny SRCU, a statically initialized work item.
Add ASSERT_STATIC_STORAGE() to DEFINE_RCU_SYNC(), both Tree SRCU
__DEFINE_SRCU() variants and Tiny SRCU's common DEFINE_SRCU() declaration.
This covers the non-static FAST and FAST_UPDOWN wrappers too. Tiny SRCU's
explicitly static declarations already enforce the required duration.
The existing per-CPU restrictions on Tree SRCU declarations still apply.
Assisted-by: OpenAI Codex
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Reviewed-by: Joel Fernandes <jfern@kernel.org>
Signed-off-by: Joel Fernandes <jfern@kernel.org>
---
include/linux/rcu_sync.h | 4 +++-
include/linux/srcutiny.h | 4 +++-
include/linux/srcutree.h | 7 +++++--
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/linux/rcu_sync.h b/include/linux/rcu_sync.h
index 3860dbb9107a..c10b6d30561a 100644
--- a/include/linux/rcu_sync.h
+++ b/include/linux/rcu_sync.h
@@ -10,6 +10,7 @@
#ifndef _LINUX_RCU_SYNC_H_
#define _LINUX_RCU_SYNC_H_
+#include <linux/compiler.h>
#include <linux/wait.h>
#include <linux/rcupdate.h>
@@ -48,6 +49,7 @@ extern void rcu_sync_dtor(struct rcu_sync *);
}
#define DEFINE_RCU_SYNC(name) \
- struct rcu_sync name = __RCU_SYNC_INITIALIZER(name)
+ struct rcu_sync name = __RCU_SYNC_INITIALIZER(name); \
+ ASSERT_STATIC_STORAGE(name)
#endif /* _LINUX_RCU_SYNC_H_ */
diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h
index 47a368f945e3..82901b45c9e1 100644
--- a/include/linux/srcutiny.h
+++ b/include/linux/srcutiny.h
@@ -11,6 +11,7 @@
#ifndef _LINUX_SRCU_TINY_H
#define _LINUX_SRCU_TINY_H
+#include <linux/compiler.h>
#include <linux/irq_work_types.h>
#include <linux/llist.h>
#include <linux/swait.h>
@@ -56,7 +57,8 @@ void srcu_defer_drain(struct irq_work *irq_work);
* Tree SRCU, which needs some per-CPU data.
*/
#define DEFINE_SRCU(name) \
- struct srcu_struct name = __SRCU_STRUCT_INIT(name, name, name, name)
+ struct srcu_struct name = __SRCU_STRUCT_INIT(name, name, name, name); \
+ ASSERT_STATIC_STORAGE(name)
#define DEFINE_STATIC_SRCU(name) \
static struct srcu_struct name = __SRCU_STRUCT_INIT(name, name, name, name)
#define DEFINE_SRCU_FAST(name) DEFINE_SRCU(name)
diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
index 93b76e543894..332d228da270 100644
--- a/include/linux/srcutree.h
+++ b/include/linux/srcutree.h
@@ -11,6 +11,7 @@
#ifndef _LINUX_SRCU_TREE_H
#define _LINUX_SRCU_TREE_H
+#include <linux/compiler.h>
#include <linux/rcu_node_tree.h>
#include <linux/completion.h>
#include <linux/irq_work_types.h>
@@ -228,13 +229,15 @@ struct srcu_struct {
fast); \
extern struct srcu_struct * const __srcu_struct_##name; \
struct srcu_struct * const __srcu_struct_##name \
- __section("___srcu_struct_ptrs") = &name
+ __section("___srcu_struct_ptrs") = &name; \
+ ASSERT_STATIC_STORAGE(name)
#else
# define __DEFINE_SRCU(name, fast, is_static) \
static DEFINE_PER_CPU(struct srcu_data, name##_srcu_data); \
static struct srcu_usage name##_srcu_usage = __SRCU_USAGE_INIT(name##_srcu_usage); \
is_static struct srcu_struct name = \
- __SRCU_STRUCT_INIT(name, name##_srcu_usage, name##_srcu_data, fast)
+ __SRCU_STRUCT_INIT(name, name##_srcu_usage, name##_srcu_data, fast); \
+ ASSERT_STATIC_STORAGE(name)
#endif
#define DEFINE_SRCU(name) __DEFINE_SRCU(name, 0, /* !static */)
#define DEFINE_STATIC_SRCU(name) __DEFINE_SRCU(name, 0, static)
--
2.54.0
next prev parent reply other threads:[~2026-11-13 0:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 0:49 [PATCH for-v7.5 0/5] RCU core patches for v7.5 Joel Fernandes
2026-11-13 0:49 ` [PATCH for-v7.5 1/5] srcu: Select IRQ_WORK for Tiny SRCU Joel Fernandes
2026-11-13 0:49 ` [PATCH for-v7.5 2/5] rcu-tasks: Avoid alloc_percpu() failure in rcu_tasks_rude_wait_gp() Joel Fernandes
2026-11-13 0:49 ` Joel Fernandes [this message]
2026-11-13 0:49 ` [PATCH for-v7.5 4/5] rcu-tasks: Use pr_debug() for callback contend/collapse messages Joel Fernandes
2026-11-13 1:01 ` Joel Fernandes
2026-11-13 0:49 ` [PATCH for-v7.5 5/5] cpuhp: Expedite RCU when toggling system-wide SMT mode 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=20261113004946.2758197-4-jfern@kernel.org \
--to=jfern@kernel.org \
--cc=boqun@kernel.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--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.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
--cc=work@onurozkan.dev \
--cc=ynorov@nvidia.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®