linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcu: Check the validity of the boost_kthread_task pointer
@ 2022-03-24 11:15 Zqiang
  2022-03-24 16:00 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Zqiang @ 2022-03-24 11:15 UTC (permalink / raw)
  To: paulmck, frederic, quic_neeraju; +Cc: rcu, linux-kernel

The boost kthreads may spawn failed, although the probability of
creation failure is very low, in consideration of the robustness
of the code, add boost_kthread_task pointer detection.

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

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 6b9bcd45c7b2..fd642f14f31f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1125,7 +1125,8 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
 	__releases(rnp->lock)
 {
 	raw_lockdep_assert_held_rcu_node(rnp);
-	if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) {
+	if (!rnp->boost_kthread_task ||
+			(!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL)) {
 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
 		return;
 	}
-- 
2.25.1


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

* Re: [PATCH] rcu: Check the validity of the boost_kthread_task pointer
  2022-03-24 11:15 [PATCH] rcu: Check the validity of the boost_kthread_task pointer Zqiang
@ 2022-03-24 16:00 ` Paul E. McKenney
  2022-03-25  0:00   ` Zhang, Qiang1
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2022-03-24 16:00 UTC (permalink / raw)
  To: Zqiang; +Cc: frederic, quic_neeraju, rcu, linux-kernel

On Thu, Mar 24, 2022 at 07:15:15PM +0800, Zqiang wrote:
> The boost kthreads may spawn failed, although the probability of
> creation failure is very low, in consideration of the robustness
> of the code, add boost_kthread_task pointer detection.
> 
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>

Good catch!  As you say, rare, but definitely worth fixing.

I could not resist a bit of wordsmithing.  Could you please check
to see if I messed something up?

							Thanx, Paul

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

commit ad3c438e248cbc41fe30a41287621c3dbfcdf51c
Author: Zqiang <qiang1.zhang@intel.com>
Date:   Thu Mar 24 19:15:15 2022 +0800

    rcu: Check for successful spawn of ->boost_kthread_task
    
    For the spawning of the priority-boost kthreads can fail, improbable
    though this might seem.  This commit therefore refrains from attemoting
    to initiate RCU priority boosting when The ->boost_kthread_task pointer
    is NULL.
    
    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 6b9bcd45c7b2..d58f6d6073bf 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1125,7 +1125,8 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
 	__releases(rnp->lock)
 {
 	raw_lockdep_assert_held_rcu_node(rnp);
-	if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) {
+	if (!rnp->boost_kthread_task ||
+	    (!rcu_preempt_blocked_readers_cgp(rnp) && !rnp->exp_tasks)) {
 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
 		return;
 	}

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

* RE: [PATCH] rcu: Check the validity of the boost_kthread_task pointer
  2022-03-24 16:00 ` Paul E. McKenney
@ 2022-03-25  0:00   ` Zhang, Qiang1
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Qiang1 @ 2022-03-25  0:00 UTC (permalink / raw)
  To: paulmck; +Cc: frederic, quic_neeraju, rcu, linux-kernel

On Thu, Mar 24, 2022 at 07:15:15PM +0800, Zqiang wrote:
> The boost kthreads may spawn failed, although the probability of 
> creation failure is very low, in consideration of the robustness of 
> the code, add boost_kthread_task pointer detection.
> 
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>
>
>Good catch!  As you say, rare, but definitely worth fixing.
>
>I could not resist a bit of wordsmithing.  Could you please check to see if I messed something up?

Thanks wordsmithing, I think it's ok.

Thanks,
Zqiang

>
>							Thanx, Paul
>
>------------------------------------------------------------------------
>
>commit ad3c438e248cbc41fe30a41287621c3dbfcdf51c
>Author: Zqiang <qiang1.zhang@intel.com>
>Date:   Thu Mar 24 19:15:15 2022 +0800
>
>    rcu: Check for successful spawn of ->boost_kthread_task
>    
>    For the spawning of the priority-boost kthreads can fail, improbable
>    though this might seem.  This commit therefore refrains from attemoting
>    to initiate RCU priority boosting when The ->boost_kthread_task pointer
>    is NULL.
>    
>    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 6b9bcd45c7b2..d58f6d6073bf 100644
>--- a/kernel/rcu/tree_plugin.h
>+++ b/kernel/rcu/tree_plugin.h
>@@ -1125,7 +1125,8 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
> 	__releases(rnp->lock)
> {
> 	raw_lockdep_assert_held_rcu_node(rnp);
>-	if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) {
>+	if (!rnp->boost_kthread_task ||
>+	    (!rcu_preempt_blocked_readers_cgp(rnp) && !rnp->exp_tasks)) {
> 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
> 		return;
> 	}

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

end of thread, other threads:[~2022-03-25  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 11:15 [PATCH] rcu: Check the validity of the boost_kthread_task pointer Zqiang
2022-03-24 16:00 ` Paul E. McKenney
2022-03-25  0:00   ` Zhang, Qiang1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).