diff mbox series

srcu: Priority check rcu_gp_is_expedited() in synchronize_srcu()

Message ID 20230704070809.31951-1-qiang.zhang1211@gmail.com (mailing list archive)
State New, archived
Headers show
Series srcu: Priority check rcu_gp_is_expedited() in synchronize_srcu() | expand

Commit Message

Z qiang July 4, 2023, 7:08 a.m. UTC
Since the atomic variable rcu_expedited_nesting is initialized to
true, so the rcu_gp_is_expedited() is always return true during
system startup until the rcu_end_inkernel_boot() is called. this
means that without setting rcupdate.rcu_normal=1 and before the
rcu_end_inkernel_boot() is executed, regardless of whether the
return value of srcu_might_be_idle() is true, call synchronize_srcu()
always fall back to synchronize_srcu_expedited(), so there is
no need to checking srcu_might_be_idle() return value.

For the rcupdate.rcu_normal=0, rcupdate.rcu_normal_after_boot=0 and
rcupdate.rcu_expedited=1 kernels, there is also no need to checking
srcu_might_be_idle() return value.

This commit therefore priority check rcu_gp_is_expedited() return value
in synchronize_srcu().

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

Comments

Paul E. McKenney July 6, 2023, 5:06 p.m. UTC | #1
On Tue, Jul 04, 2023 at 03:08:09PM +0800, Zqiang wrote:
> Since the atomic variable rcu_expedited_nesting is initialized to
> true, so the rcu_gp_is_expedited() is always return true during
> system startup until the rcu_end_inkernel_boot() is called. this
> means that without setting rcupdate.rcu_normal=1 and before the
> rcu_end_inkernel_boot() is executed, regardless of whether the
> return value of srcu_might_be_idle() is true, call synchronize_srcu()
> always fall back to synchronize_srcu_expedited(), so there is
> no need to checking srcu_might_be_idle() return value.
> 
> For the rcupdate.rcu_normal=0, rcupdate.rcu_normal_after_boot=0 and
> rcupdate.rcu_expedited=1 kernels, there is also no need to checking
> srcu_might_be_idle() return value.
> 
> This commit therefore priority check rcu_gp_is_expedited() return value
> in synchronize_srcu().
> 
> Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>

Thank you for taking the time to look into SRCU!

But are you seeing real performance issues that this addresses?

My guess is "no", given that this is nowhere near a fastpath, but I
figured that I should ask.

							Thanx, Paul

> ---
>  kernel/rcu/srcutree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index 20d7a238d675..a819f11d9b90 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -1435,7 +1435,7 @@ EXPORT_SYMBOL_GPL(synchronize_srcu_expedited);
>   */
>  void synchronize_srcu(struct srcu_struct *ssp)
>  {
> -	if (srcu_might_be_idle(ssp) || rcu_gp_is_expedited())
> +	if (rcu_gp_is_expedited() || srcu_might_be_idle(ssp))
>  		synchronize_srcu_expedited(ssp);
>  	else
>  		__synchronize_srcu(ssp, true);
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 20d7a238d675..a819f11d9b90 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1435,7 +1435,7 @@  EXPORT_SYMBOL_GPL(synchronize_srcu_expedited);
  */
 void synchronize_srcu(struct srcu_struct *ssp)
 {
-	if (srcu_might_be_idle(ssp) || rcu_gp_is_expedited())
+	if (rcu_gp_is_expedited() || srcu_might_be_idle(ssp))
 		synchronize_srcu_expedited(ssp);
 	else
 		__synchronize_srcu(ssp, true);