mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] srcu: Make srcu_might_be_idle() take early return if rcu_gp_is_normal() return true
@ 2023-07-04  8:26 Zqiang
  2023-07-06 17:08 ` Paul E. McKenney
  0 siblings, 1 reply; 10+ messages in thread
From: Zqiang @ 2023-07-04  8:26 UTC (permalink / raw)
  To: paulmck, frederic, quic_neeraju, joel, qiang.zhang1211; +Cc: rcu, linux-kernel

When invoke synchronize_srcu(), in the srcu_might_be_idle(), the current
CPU's sdp->lock will be acquired to check whether there are pending
callbacks in the sdp->srcu_cblist, if there are no pending callbacks,
probabilistically probe global state to decide whether to convert to
synchronize_srcu_expedited() call. however, for the rcupdate.rcu_normal=1
kernels and after the rcu_set_runtime_mode() is called, invoke the
rcu_gp_is_normal() is always return true, this mean that invoke the
synchronize_srcu_expedited() always fall back to synchronize_srcu(),
so there is no need to acquire sdp->lock to check sdp->srcu_cblist and
probe global state in srcu_might_be_idle().

This commit therefore make srcu_might_be_idle() return immediately if the
rcu_gp_is_normal() return true.

Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
---
 kernel/rcu/srcutree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 20d7a238d675..aea49cb60a45 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1172,6 +1172,8 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp)
 	unsigned long tlast;
 
 	check_init_srcu_struct(ssp);
+	if (rcu_gp_is_normal())
+		return false;
 	/* If the local srcu_data structure has callbacks, not idle.  */
 	sdp = raw_cpu_ptr(ssp->sda);
 	spin_lock_irqsave_rcu_node(sdp, flags);
-- 
2.17.1


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

end of thread, other threads:[~2023-07-08  6:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  8:26 [PATCH] srcu: Make srcu_might_be_idle() take early return if rcu_gp_is_normal() return true Zqiang
2023-07-06 17:08 ` Paul E. McKenney
2023-07-07 10:28   ` Z qiang
2023-07-07 16:05     ` Paul E. McKenney
2023-07-07 17:16       ` Joel Fernandes
2023-07-07 17:18         ` Joel Fernandes
2023-07-08  2:17           ` Z qiang
2023-07-08  2:11       ` Z qiang
2023-07-08  4:56         ` Paul E. McKenney
2023-07-08  6:45           ` Z qiang

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®