RCU Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active
@ 2019-10-04 19:49 Stefan Reiter
  2019-10-04 22:24 ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Reiter @ 2019-10-04 19:49 UTC (permalink / raw)
  To: rcu
  Cc: Stefan Reiter, Paul E. McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes, linux-kernel

Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
dump_tree") added print statements to rcu_organize_nocb_kthreads for
debugging, but incorrectly guarded them, causing the function to always
spew out its message.

This patch fixes it by guarding both pr_alert statements with dump_tree,
while also changing the second pr_alert to a pr_cont, to print the
hierarchy in a single line (assuming that's how it was supposed to
work).

Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
Signed-off-by: Stefan Reiter <stefan@pimaker.at>
---

First time contributing to the kernel, hope I'm doing this right :)

 kernel/rcu/tree_plugin.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 2defc7fe74c3..7cbf4a0f3eff 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2346,15 +2346,19 @@ static void __init rcu_organize_nocb_kthreads(void)
 			nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
 			rdp->nocb_gp_rdp = rdp;
 			rdp_gp = rdp;
-			if (!firsttime && dump_tree)
-				pr_cont("\n");
-			firsttime = false;
-			pr_alert("%s: No-CB GP kthread CPU %d:", __func__, cpu);
+			if (dump_tree) {
+				if (!firsttime)
+					pr_cont("\n");
+				firsttime = false;
+				pr_alert("%s: No-CB GP kthread CPU %d:",
+					 __func__, cpu);
+			}
 		} else {
 			/* Another CB kthread, link to previous GP kthread. */
 			rdp->nocb_gp_rdp = rdp_gp;
 			rdp_prev->nocb_next_cb_rdp = rdp;
-			pr_alert(" %d", cpu);
+			if (dump_tree)
+				pr_cont(" %d", cpu);
 		}
 		rdp_prev = rdp;
 	}
-- 
2.23.0



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

* Re: [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active
  2019-10-04 19:49 [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active Stefan Reiter
@ 2019-10-04 22:24 ` Paul E. McKenney
  2019-10-07  1:26   ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2019-10-04 22:24 UTC (permalink / raw)
  To: Stefan Reiter
  Cc: rcu, Josh Triplett, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Joel Fernandes, linux-kernel

On Fri, Oct 04, 2019 at 07:49:10PM +0000, Stefan Reiter wrote:
> Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
> dump_tree") added print statements to rcu_organize_nocb_kthreads for
> debugging, but incorrectly guarded them, causing the function to always
> spew out its message.
> 
> This patch fixes it by guarding both pr_alert statements with dump_tree,
> while also changing the second pr_alert to a pr_cont, to print the
> hierarchy in a single line (assuming that's how it was supposed to
> work).
> 
> Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
> Signed-off-by: Stefan Reiter <stefan@pimaker.at>

Queued for testing and review, thank you!

> ---
> 
> First time contributing to the kernel, hope I'm doing this right :)

Looks good so far.  Then again, I just kicked off the tests.  ;-)

							Thanx, Paul

>  kernel/rcu/tree_plugin.h | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 2defc7fe74c3..7cbf4a0f3eff 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2346,15 +2346,19 @@ static void __init rcu_organize_nocb_kthreads(void)
>  			nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
>  			rdp->nocb_gp_rdp = rdp;
>  			rdp_gp = rdp;
> -			if (!firsttime && dump_tree)
> -				pr_cont("\n");
> -			firsttime = false;
> -			pr_alert("%s: No-CB GP kthread CPU %d:", __func__, cpu);
> +			if (dump_tree) {
> +				if (!firsttime)
> +					pr_cont("\n");
> +				firsttime = false;
> +				pr_alert("%s: No-CB GP kthread CPU %d:",
> +					 __func__, cpu);
> +			}
>  		} else {
>  			/* Another CB kthread, link to previous GP kthread. */
>  			rdp->nocb_gp_rdp = rdp_gp;
>  			rdp_prev->nocb_next_cb_rdp = rdp;
> -			pr_alert(" %d", cpu);
> +			if (dump_tree)
> +				pr_cont(" %d", cpu);
>  		}
>  		rdp_prev = rdp;
>  	}
> -- 
> 2.23.0
> 
> 

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

* Re: [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active
  2019-10-04 22:24 ` Paul E. McKenney
@ 2019-10-07  1:26   ` Paul E. McKenney
  2019-10-07 17:56     ` Stefan
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2019-10-07  1:26 UTC (permalink / raw)
  To: Stefan Reiter
  Cc: rcu, Josh Triplett, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Joel Fernandes, linux-kernel

On Fri, Oct 04, 2019 at 03:24:02PM -0700, Paul E. McKenney wrote:
> On Fri, Oct 04, 2019 at 07:49:10PM +0000, Stefan Reiter wrote:
> > Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
> > dump_tree") added print statements to rcu_organize_nocb_kthreads for
> > debugging, but incorrectly guarded them, causing the function to always
> > spew out its message.
> > 
> > This patch fixes it by guarding both pr_alert statements with dump_tree,
> > while also changing the second pr_alert to a pr_cont, to print the
> > hierarchy in a single line (assuming that's how it was supposed to
> > work).
> > 
> > Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
> > Signed-off-by: Stefan Reiter <stefan@pimaker.at>
> 
> Queued for testing and review, thank you!

And here is an updated version to make the special case of a nocb GP
kthread having no other nocb CB kthreads look less strange.  Does this
work for you?

							Thanx, Paul

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

commit e6223b0705369750990c32ddc80251942e61be30
Author: Stefan Reiter <stefan@pimaker.at>
Date:   Fri Oct 4 19:49:10 2019 +0000

    rcu/nocb: Fix dump_tree hierarchy print always active
    
    Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
    dump_tree") added print statements to rcu_organize_nocb_kthreads for
    debugging, but incorrectly guarded them, causing the function to always
    spew out its message.
    
    This patch fixes it by guarding both pr_alert statements with dump_tree,
    while also changing the second pr_alert to a pr_cont, to print the
    hierarchy in a single line (assuming that's how it was supposed to
    work).
    
    Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
    Signed-off-by: Stefan Reiter <stefan@pimaker.at>
    [ paulmck: Make single-nocbs-CPU GP kthreads look less erroneous. ]
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index d5334e4..d43f4e0 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2295,6 +2295,8 @@ static void __init rcu_organize_nocb_kthreads(void)
 {
 	int cpu;
 	bool firsttime = true;
+	bool gotnocbs = false;
+	bool gotnocbscbs = true;
 	int ls = rcu_nocb_gp_stride;
 	int nl = 0;  /* Next GP kthread. */
 	struct rcu_data *rdp;
@@ -2317,21 +2319,31 @@ static void __init rcu_organize_nocb_kthreads(void)
 		rdp = per_cpu_ptr(&rcu_data, cpu);
 		if (rdp->cpu >= nl) {
 			/* New GP kthread, set up for CBs & next GP. */
+			gotnocbs = true;
 			nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
 			rdp->nocb_gp_rdp = rdp;
 			rdp_gp = rdp;
-			if (!firsttime && dump_tree)
-				pr_cont("\n");
-			firsttime = false;
-			pr_alert("%s: No-CB GP kthread CPU %d:", __func__, cpu);
+			if (dump_tree) {
+				if (!firsttime)
+					pr_cont("%s\n", gotnocbscbs
+							? "" : " (self only)");
+				gotnocbscbs = false;
+				firsttime = false;
+				pr_alert("%s: No-CB GP kthread CPU %d:",
+					 __func__, cpu);
+			}
 		} else {
 			/* Another CB kthread, link to previous GP kthread. */
+			gotnocbscbs = true;
 			rdp->nocb_gp_rdp = rdp_gp;
 			rdp_prev->nocb_next_cb_rdp = rdp;
-			pr_alert(" %d", cpu);
+			if (dump_tree)
+				pr_cont(" %d", cpu);
 		}
 		rdp_prev = rdp;
 	}
+	if (gotnocbs && dump_tree)
+		pr_cont("%s\n", gotnocbscbs ? "" : " (self only)");
 }
 
 /*

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

* Re: [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active
  2019-10-07  1:26   ` Paul E. McKenney
@ 2019-10-07 17:56     ` Stefan
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan @ 2019-10-07 17:56 UTC (permalink / raw)
  To: paulmck
  Cc: rcu, Josh Triplett, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Joel Fernandes, linux-kernel

On 07/10/2019 03:26, Paul E. McKenney wrote:
> 
> On Fri, Oct 04, 2019 at 03:24:02PM -0700, Paul E. McKenney wrote:
>> On Fri, Oct 04, 2019 at 07:49:10PM +0000, Stefan Reiter wrote:
>>> Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
>>> dump_tree") added print statements to rcu_organize_nocb_kthreads for
>>> debugging, but incorrectly guarded them, causing the function to always
>>> spew out its message.
>>>
>>> This patch fixes it by guarding both pr_alert statements with dump_tree,
>>> while also changing the second pr_alert to a pr_cont, to print the
>>> hierarchy in a single line (assuming that's how it was supposed to
>>> work).
>>>
>>> Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
>>> Signed-off-by: Stefan Reiter <stefan@pimaker.at>
>>
>> Queued for testing and review, thank you!
> 
> And here is an updated version to make the special case of a nocb GP
> kthread having no other nocb CB kthreads look less strange.  Does this
> work for you?

Tested just now, works for me. Thanks for the additional fix!

> 
> 							Thanx, Paul
> 
> ------------------------------------------------------------------------
> 
> commit e6223b0705369750990c32ddc80251942e61be30
> Author: Stefan Reiter <stefan@pimaker.at>
> Date:   Fri Oct 4 19:49:10 2019 +0000
> 
>      rcu/nocb: Fix dump_tree hierarchy print always active
> 
>      Commit 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if
>      dump_tree") added print statements to rcu_organize_nocb_kthreads for
>      debugging, but incorrectly guarded them, causing the function to always
>      spew out its message.
> 
>      This patch fixes it by guarding both pr_alert statements with dump_tree,
>      while also changing the second pr_alert to a pr_cont, to print the
>      hierarchy in a single line (assuming that's how it was supposed to
>      work).
> 
>      Fixes: 18cd8c93e69e ("rcu/nocb: Print gp/cb kthread hierarchy if dump_tree")
>      Signed-off-by: Stefan Reiter <stefan@pimaker.at>
>      [ paulmck: Make single-nocbs-CPU GP kthreads look less erroneous. ]
>      Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index d5334e4..d43f4e0 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2295,6 +2295,8 @@ static void __init rcu_organize_nocb_kthreads(void)
>   {
>   	int cpu;
>   	bool firsttime = true;
> +	bool gotnocbs = false;
> +	bool gotnocbscbs = true;
>   	int ls = rcu_nocb_gp_stride;
>   	int nl = 0;  /* Next GP kthread. */
>   	struct rcu_data *rdp;
> @@ -2317,21 +2319,31 @@ static void __init rcu_organize_nocb_kthreads(void)
>   		rdp = per_cpu_ptr(&rcu_data, cpu);
>   		if (rdp->cpu >= nl) {
>   			/* New GP kthread, set up for CBs & next GP. */
> +			gotnocbs = true;
>   			nl = DIV_ROUND_UP(rdp->cpu + 1, ls) * ls;
>   			rdp->nocb_gp_rdp = rdp;
>   			rdp_gp = rdp;
> -			if (!firsttime && dump_tree)
> -				pr_cont("\n");
> -			firsttime = false;
> -			pr_alert("%s: No-CB GP kthread CPU %d:", __func__, cpu);
> +			if (dump_tree) {
> +				if (!firsttime)
> +					pr_cont("%s\n", gotnocbscbs
> +							? "" : " (self only)");
> +				gotnocbscbs = false;
> +				firsttime = false;
> +				pr_alert("%s: No-CB GP kthread CPU %d:",
> +					 __func__, cpu);
> +			}
>   		} else {
>   			/* Another CB kthread, link to previous GP kthread. */
> +			gotnocbscbs = true;
>   			rdp->nocb_gp_rdp = rdp_gp;
>   			rdp_prev->nocb_next_cb_rdp = rdp;
> -			pr_alert(" %d", cpu);
> +			if (dump_tree)
> +				pr_cont(" %d", cpu);
>   		}
>   		rdp_prev = rdp;
>   	}
> +	if (gotnocbs && dump_tree)
> +		pr_cont("%s\n", gotnocbscbs ? "" : " (self only)");
>   }
> 
>   /*
> 


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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 19:49 [PATCH] rcu/nocb: Fix dump_tree hierarchy print always active Stefan Reiter
2019-10-04 22:24 ` Paul E. McKenney
2019-10-07  1:26   ` Paul E. McKenney
2019-10-07 17:56     ` Stefan

RCU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/rcu/0 rcu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 rcu rcu/ https://lore.kernel.org/rcu \
		rcu@vger.kernel.org
	public-inbox-index rcu

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.rcu


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git