All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: Fix rcu_read_unlock_strict() strict QS reporting
@ 2022-06-16 13:53 Zqiang
  2022-06-17  0:13 ` Paul E. McKenney
  0 siblings, 1 reply; 2+ messages in thread
From: Zqiang @ 2022-06-16 13:53 UTC (permalink / raw)
  To: paulmck, frederic; +Cc: rcu, linux-kernel

When running a kerenl with CONFIG_PREEMPT=n and
CONFIG_RCU_STRICT_GRACE_PERIOD=y, the QS state will be reported
directly after exiting the last level of RCU critical section and
in non irqs-disable context, but maybe the CPU's rcu_data
structure's ->cpu_no_qs.b.norm is not cleared, as a result the
rcu_report_qs_rdp() will exit early, and not report QS state.

This commit will clear CPU's rcu_data structure's ->cpu_no_qs.b.norm
before invoke rcu_report_qs_rdp().

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
 kernel/rcu/tree_plugin.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index b2c01919b92c..dc78726b993f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -824,6 +824,7 @@ void rcu_read_unlock_strict(void)
 	if (irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
 		return;
 	rdp = this_cpu_ptr(&rcu_data);
+	rdp->cpu_no_qs.b.norm = false;
 	rcu_report_qs_rdp(rdp);
 	udelay(rcu_unlock_delay);
 }
-- 
2.25.1


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

* Re: [PATCH] rcu: Fix rcu_read_unlock_strict() strict QS reporting
  2022-06-16 13:53 [PATCH] rcu: Fix rcu_read_unlock_strict() strict QS reporting Zqiang
@ 2022-06-17  0:13 ` Paul E. McKenney
  0 siblings, 0 replies; 2+ messages in thread
From: Paul E. McKenney @ 2022-06-17  0:13 UTC (permalink / raw)
  To: Zqiang; +Cc: frederic, rcu, linux-kernel

On Thu, Jun 16, 2022 at 09:53:47PM +0800, Zqiang wrote:
> When running a kerenl with CONFIG_PREEMPT=n and
> CONFIG_RCU_STRICT_GRACE_PERIOD=y, the QS state will be reported
> directly after exiting the last level of RCU critical section and
> in non irqs-disable context, but maybe the CPU's rcu_data
> structure's ->cpu_no_qs.b.norm is not cleared, as a result the
> rcu_report_qs_rdp() will exit early, and not report QS state.
> 
> This commit will clear CPU's rcu_data structure's ->cpu_no_qs.b.norm
> before invoke rcu_report_qs_rdp().
> 
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>

Good point, thank you!  Queued for review and testing with the usual
wordsmithing shown below.  As always, please check.

							Thanx, Paul

------------------------------------------------------------------------

commit cb58562318cf1fa7ad7c2c4c8d8e847c7942df66
Author: Zqiang <qiang1.zhang@intel.com>
Date:   Thu Jun 16 21:53:47 2022 +0800

    rcu: Fix rcu_read_unlock_strict() strict QS reporting
    
    Kernels built with CONFIG_PREEMPT=n and CONFIG_RCU_STRICT_GRACE_PERIOD=y
    report the quiescent state directly from the outermost rcu_read_unlock().
    However, the current CPU's rcu_data structure's ->cpu_no_qs.b.norm
    might still be set, in which case rcu_report_qs_rdp() will exit early,
    thus failing to report quiescent state.
    
    This commit therefore causes rcu_read_unlock_strict() to clear
    CPU's rcu_data structure's ->cpu_no_qs.b.norm field before invoking
    rcu_report_qs_rdp().
    
    Signed-off-by: Zqiang <qiang1.zhang@intel.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index b2c01919b92c0..dc78726b993fd 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -824,6 +824,7 @@ void rcu_read_unlock_strict(void)
 	if (irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
 		return;
 	rdp = this_cpu_ptr(&rcu_data);
+	rdp->cpu_no_qs.b.norm = false;
 	rcu_report_qs_rdp(rdp);
 	udelay(rcu_unlock_delay);
 }

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

end of thread, other threads:[~2022-06-17  0:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 13:53 [PATCH] rcu: Fix rcu_read_unlock_strict() strict QS reporting Zqiang
2022-06-17  0:13 ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.