From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>,
Boqun Feng <boqun.feng@gmail.com>,
Joel Fernandes <joel@joelfernandes.org>,
Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Neeraj Upadhyay <neeraj.upadhyay@amd.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Uladzislau Rezki <urezki@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>, rcu <rcu@vger.kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>
Subject: [PATCH 01/16] srcu: Replace WARN_ON_ONCE() with BUILD_BUG_ON() if possible
Date: Tue, 12 Nov 2024 15:51:44 +0100 [thread overview]
Message-ID: <20241112145159.23032-2-frederic@kernel.org> (raw)
In-Reply-To: <20241112145159.23032-1-frederic@kernel.org>
From: Zhen Lei <thunder.leizhen@huawei.com>
The value of ARRAY_SIZE() can be determined at compile time, so if both
sides of the equation are ARRAY_SIZE(), using BUILD_BUG_ON() can help us
catch the problem earlier.
While there are cases where unequal array sizes will work, there is no
point in allowing them, so it makes more sense to force them to be equal
using BUILD_BUG_ON().
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
kernel/rcu/srcutree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 31706e3293bc..78afaffd1b26 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -128,7 +128,7 @@ static void init_srcu_struct_data(struct srcu_struct *ssp)
* Initialize the per-CPU srcu_data array, which feeds into the
* leaves of the srcu_node tree.
*/
- WARN_ON_ONCE(ARRAY_SIZE(sdp->srcu_lock_count) !=
+ BUILD_BUG_ON(ARRAY_SIZE(sdp->srcu_lock_count) !=
ARRAY_SIZE(sdp->srcu_unlock_count));
for_each_possible_cpu(cpu) {
sdp = per_cpu_ptr(ssp->sda, cpu);
@@ -187,7 +187,7 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags)
/* Each pass through this loop initializes one srcu_node structure. */
srcu_for_each_node_breadth_first(ssp, snp) {
spin_lock_init(&ACCESS_PRIVATE(snp, lock));
- WARN_ON_ONCE(ARRAY_SIZE(snp->srcu_have_cbs) !=
+ BUILD_BUG_ON(ARRAY_SIZE(snp->srcu_have_cbs) !=
ARRAY_SIZE(snp->srcu_data_have_cbs));
for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) {
snp->srcu_have_cbs[i] = SRCU_SNP_INIT_SEQ;
--
2.46.0
next prev parent reply other threads:[~2024-11-12 14:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 14:51 [PATCH 00/16] SRCU for v6.13 Frederic Weisbecker
2024-11-12 14:51 ` Frederic Weisbecker [this message]
2024-11-12 14:51 ` [PATCH 02/16] srcu: Rename srcu_might_be_idle() to srcu_should_expedite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 03/16] srcu: Introduce srcu_gp_is_expedited() helper function Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 04/16] srcu: Renaming in preparation for additional reader flavor Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 05/16] srcu: Bit manipulation changes " Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 06/16] srcu: Standardize srcu_data pointers to "sdp" and similar Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 07/16] srcu: Improve srcu_read_lock{,_nmisafe}() comments Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 08/16] srcu: Create CPP macros for normal and NMI-safe SRCU readers Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 09/16] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 10/16] srcu: Allow inlining of __srcu_read_{,un}lock_lite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 11/16] rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 12/16] rcutorture: Add reader_flavor parameter for SRCU readers Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 13/16] rcutorture: Add srcu_read_lock_lite() support to rcutorture.reader_flavor Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 14/16] rcutorture: Add light-weight SRCU scenario Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 15/16] refscale: Add srcu_read_lock_lite() support using "srcu-lite" Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 16/16] srcu: Improve srcu_read_lock_lite() kernel-doc comment Frederic Weisbecker
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=20241112145159.23032-2-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=boqun.feng@gmail.com \
--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@amd.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=thunder.leizhen@huawei.com \
--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