public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: use try_cmpxchg in check_cpu_stall
@ 2023-02-28 15:51 Uros Bizjak
  2023-02-28 20:39 ` Joel Fernandes
  0 siblings, 1 reply; 25+ messages in thread
From: Uros Bizjak @ 2023-02-28 15:51 UTC (permalink / raw)
  To: rcu, linux-kernel
  Cc: Uros Bizjak, Paul E. McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Josh Triplett, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Joel Fernandes

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
check_cpu_stall.  x86 CMPXCHG instruction returns success in ZF flag, so
this change saves a compare after cmpxchg (and related move instruction in
front of cmpxchg).

No functional change intended.

Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
 kernel/rcu/tree_stall.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index b10b8349bb2a..d81c88e66b42 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -760,7 +760,7 @@ static void check_cpu_stall(struct rcu_data *rdp)
 	jn = jiffies + ULONG_MAX / 2;
 	if (rcu_gp_in_progress() &&
 	    (READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
-	    cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
+	    try_cmpxchg(&rcu_state.jiffies_stall, &js, jn)) {
 
 		/*
 		 * If a virtual machine is stopped by the host it can look to
@@ -778,7 +778,7 @@ static void check_cpu_stall(struct rcu_data *rdp)
 
 	} else if (rcu_gp_in_progress() &&
 		   ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
-		   cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
+		   try_cmpxchg(&rcu_state.jiffies_stall, &js, jn)) {
 
 		/*
 		 * If a virtual machine is stopped by the host it can look to
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2023-03-01 21:29 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 15:51 [PATCH] rcu: use try_cmpxchg in check_cpu_stall Uros Bizjak
2023-02-28 20:39 ` Joel Fernandes
2023-02-28 20:56   ` Joel Fernandes
2023-02-28 21:03   ` Steven Rostedt
2023-02-28 21:29     ` Paul E. McKenney
2023-02-28 21:41       ` Steven Rostedt
2023-02-28 21:56         ` Paul E. McKenney
2023-02-28 23:30         ` Joel Fernandes
2023-03-01  0:08           ` Steven Rostedt
2023-03-01  0:45             ` Joel Fernandes
2023-03-01 10:28             ` Uros Bizjak
2023-03-01 16:38               ` Steven Rostedt
2023-03-01 18:43                 ` Uros Bizjak
2023-03-01 18:52                   ` Steven Rostedt
2023-03-01 19:18                     ` Uros Bizjak
2023-03-01 19:43                       ` Steven Rostedt
2023-03-01 19:46                         ` Joel Fernandes
2023-03-01 19:45                       ` Joel Fernandes
2023-03-01 20:08                   ` Paul E. McKenney
2023-03-01 20:18                     ` Joel Fernandes
2023-03-01 20:18                     ` Steven Rostedt
2023-03-01 20:36                       ` Paul E. McKenney
2023-03-01 20:46                         ` Steven Rostedt
2023-03-01 21:29                           ` Paul E. McKenney
2023-03-01  9:52   ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox