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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230721075716.857-2-thunder.leizhen@huaweicloud.com>
Date:   Fri, 21 Jul 2023 15:57:15 +0800
From:   thunder.leizhen@...weicloud.com
To:     "Paul E . McKenney" <paulmck@...nel.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Neeraj Upadhyay <quic_neeraju@...cinc.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Josh Triplett <josh@...htriplett.org>,
        Boqun Feng <boqun.feng@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Zqiang <qiang.zhang1211@...il.com>, rcu@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 1/2] rcu: Delete a redundant check in check_cpu_stall()

From: Zhen Lei <thunder.leizhen@...wei.com>

j = jiffies;
js = READ_ONCE(rcu_state.jiffies_stall);			(1)
if (ULONG_CMP_LT(j, js))					(2)
	return;

if (cmpxchg(&rcu_state.jiffies_stall, js, jn) == js)		(3)
	didstall = true;

if (didstall && READ_ONCE(rcu_state.jiffies_stall) == jn) {	(4)
	jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
	WRITE_ONCE(rcu_state.jiffies_stall, jn);
}

For ease of description, the pseudo code is extracted as above. First,
assume that only one CPU is operating, the condition 'didstall' is true
means that (3) succeeds. That is, the value of rcu_state.jiffies_stall
must be 'jn'.

Then, assuming that another CPU is also operating at the same time, there
are two cases:
1. That CPU sees the updated result at (1), it returns at (2).
2. That CPU does not see the updated result at (1), it fails at (3) and
   cmpxchg returns jn. So that, didstall cannot be true.

Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
 kernel/rcu/tree_stall.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index cc884cd49e026a3..371713f3f7d15d9 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -794,7 +794,7 @@ static void check_cpu_stall(struct rcu_data *rdp)
 			rcu_ftrace_dump(DUMP_ALL);
 		didstall = true;
 	}
-	if (didstall && READ_ONCE(rcu_state.jiffies_stall) == jn) {
+	if (didstall) {
 		jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
 		WRITE_ONCE(rcu_state.jiffies_stall, jn);
 	}
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ