lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220607063753.495-1-thunder.leizhen@huawei.com>
Date:   Tue, 7 Jun 2022 14:37:53 +0800
From:   Zhen Lei <thunder.leizhen@...wei.com>
To:     "Paul E . McKenney" <paulmck@...nel.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Neeraj Upadhyay <quic_neeraju@...cinc.com>,
        "Josh Triplett" <josh@...htriplett.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Joel Fernandes <joel@...lfernandes.org>, <rcu@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH v2] rcu/nocb: Delete local variable 'need_rcu_nocb_mask' in rcu_init_nohz()

...
bool need_rcu_nocb_mask = false;

//#if defined(CONFIG_NO_HZ_FULL)
if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
        need_rcu_nocb_mask = true;      <----	//Move it here
//#endif                                     |
                                             |
if (need_rcu_nocb_mask) {                    |  //Can only be true above
         ...                            -----
}

The local variable 'need_rcu_nocb_mask' is true only if CONFIG_NO_HZ_FULL
is defined. So branch "if (need_rcu_nocb_mask)" can be moved within the
scope of "#if defined(CONFIG_NO_HZ_FULL)". At this point, using variable
'need_rcu_nocb_mask' is not necessary, so delete it.

No functional changes, but the code looks a little more concise.

The kernel built with CONFIG_NO_HZ_FULL=n and CONFIG_RCU_NOCB_CPU=y ran
continuously for a whole day, no errors were reported.

Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
 kernel/rcu/tree_nocb.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

v1 --> v2:
Update commit message.

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index 46694e13398a3ee..e7fe99eb58972a6 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1154,15 +1154,10 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload);
 void __init rcu_init_nohz(void)
 {
 	int cpu;
-	bool need_rcu_nocb_mask = false;
 	struct rcu_data *rdp;
 
 #if defined(CONFIG_NO_HZ_FULL)
-	if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
-		need_rcu_nocb_mask = true;
-#endif /* #if defined(CONFIG_NO_HZ_FULL) */
-
-	if (need_rcu_nocb_mask) {
+	if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) {
 		if (!cpumask_available(rcu_nocb_mask)) {
 			if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {
 				pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n");
@@ -1171,6 +1166,7 @@ void __init rcu_init_nohz(void)
 		}
 		rcu_state.nocb_is_setup = true;
 	}
+#endif /* #if defined(CONFIG_NO_HZ_FULL) */
 
 	if (!rcu_state.nocb_is_setup)
 		return;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ