Skip to contentSkip to conversation

rcu: Check for have_rcu_nocb_mask instead of rcu_nocb_mask

PATCH In review Pranith Kumar 2 participants 5 messages Jul 17, 2014 – Jul 19, 2014 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Check for have_rcu_nocb_mask instead of rcu_nocb_mask

Hi Paul,

This is something similar to what you found yesterday with tick_nohz_full mask.

--
Pranith

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

---
 kernel/rcu/tree_plugin.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree_plugin.h +2 -2
index cedb020..15c00b5 100644
@@ -2542,7 +2542,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 	struct rcu_data *rdp_leader = NULL;  /* Suppress misguided gcc warn. */
 	struct rcu_data *rdp_prev = NULL;
 
-	if (rcu_nocb_mask == NULL)
+	if (!have_rcu_nocb_mask)
 		return;
 #ifdef CONFIG_NO_HZ_FULL
 	cpumask_or(rcu_nocb_mask, rcu_nocb_mask, tick_nohz_full_mask);
@@ -2575,7 +2575,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 /* Prevent __call_rcu() from enqueuing callbacks on no-CBs CPUs */
 static bool init_nocb_callback_list(struct rcu_data *rdp)
 {
-	if (rcu_nocb_mask == NULL ||
+	if (have_rcu_nocb_mask == false ||
 	    !cpumask_test_cpu(rdp->cpu, rcu_nocb_mask))
 		return false;
 	rdp->nxttail[RCU_NEXT_TAIL] = NULL;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Pranith Kumar

Hi Paul,

This is something similar to what you found yesterday with tick_nohz_full mask.

--
Pranith

Quoted 8 lines

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

Good catch! Could you please forward-port this to current rcu/dev? This now includes the fix you mentioned above, which generates conflicts.

Could you please also fix the use in rcu_is_nocb_cpu()?

And please see the comment below.

Thanx, Paul

Quoted 18 lines
---
 kernel/rcu/tree_plugin.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree_plugin.h +1 -1
index cedb020..15c00b5 100644
@@ -2542,7 +2542,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 	struct rcu_data *rdp_leader = NULL;  /* Suppress misguided gcc warn. */
 	struct rcu_data *rdp_prev = NULL;
 
-	if (rcu_nocb_mask == NULL)
+	if (!have_rcu_nocb_mask)
 		return;
 #ifdef CONFIG_NO_HZ_FULL
 	cpumask_or(rcu_nocb_mask, rcu_nocb_mask, tick_nohz_full_mask);

kernel/rcu/tree_plugin.h static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp) · line 2578

Quoted 5 lines
kernel/rcu/tree_plugin.h +1 -1
@@ -2575,7 +2575,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 /* Prevent __call_rcu() from enqueuing callbacks on no-CBs CPUs */
 static bool init_nocb_callback_list(struct rcu_data *rdp)
 {
-	if (rcu_nocb_mask == NULL ||
+	if (have_rcu_nocb_mask == false ||

This should really be "if (!have_rcu_nocb_mask".

Of course, the original should have been "if (!rcu_nocb_mask", but old habits die hard. ;-)

Quoted 6 lines
kernel/rcu/tree_plugin.h +0 -0
 	    !cpumask_test_cpu(rdp->cpu, rcu_nocb_mask))
 		return false;
 	rdp->nxttail[RCU_NEXT_TAIL] = NULL;
Signature · 1 line
1.9.1
#2 lore raw
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines · Pranith Kumar

Hi Paul,

This is something similar to what you found yesterday with tick_nohz_full mask.

--
Pranith

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

Quoted 9 lines
Quoted 1 line

Good catch! Could you please forward-port this to current rcu/dev? This now includes the fix you mentioned above, which generates conflicts.

Could you please also fix the use in rcu_is_nocb_cpu()?

And please see the comment below.

Please find the fixed patch.

--
Pranith

From: Pranith Kumar <[email protected]>
Date: Thu, 17 Jul 2014 20:02:54 -0400
Subject: [PATCH 1/1] rcu: Feedback comments

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

---
 kernel/rcu/tree_plugin.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
kernel/rcu/tree_plugin.h +7 -6
index ce8c331..8f987c1 100644
@@ -2053,9 +2053,10 @@ static void rcu_init_one_nocb(struct rcu_node *rnp)
 /* Is the specified CPU a no-CBs CPU? */
 bool rcu_is_nocb_cpu(int cpu)
 {
-	if (have_rcu_nocb_mask)
-		return cpumask_test_cpu(cpu, rcu_nocb_mask);
-	return false;
+	if (!have_rcu_nocb_mask)
+		return false;
+
+	return cpumask_test_cpu(cpu, rcu_nocb_mask);
 }
 #endif /* #ifndef CONFIG_RCU_NOCB_CPU_ALL */
 
@@ -2540,7 +2541,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 	struct rcu_data *rdp_leader = NULL;  /* Suppress misguided gcc warn. */
 	struct rcu_data *rdp_prev = NULL;
 
-	if (rcu_nocb_mask == NULL)
+	if (!have_rcu_nocb_mask)
 		return;
 #if defined(CONFIG_NO_HZ_FULL) && !defined(CONFIG_NO_HZ_FULL_ALL)
 	if (tick_nohz_full_running)
@@ -2574,9 +2575,9 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 /* Prevent __call_rcu() from enqueuing callbacks on no-CBs CPUs */
 static bool init_nocb_callback_list(struct rcu_data *rdp)
 {
-	if (rcu_nocb_mask == NULL ||
-	    !cpumask_test_cpu(rdp->cpu, rcu_nocb_mask))
+	if (!rcu_is_nocb_cpu(rdp->cpu))
 		return false;
+
 	rdp->nxttail[RCU_NEXT_TAIL] = NULL;
 	return true;
 }
Signature · 1 line
1.9.1
#3 lore raw
Quoted 53 lines · Pranith Kumar
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines · Pranith Kumar

Hi Paul,

This is something similar to what you found yesterday with tick_nohz_full mask.

--
Pranith

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

Quoted 9 lines
Quoted 1 line

Good catch! Could you please forward-port this to current rcu/dev? This now includes the fix you mentioned above, which generates conflicts.

Could you please also fix the use in rcu_is_nocb_cpu()?

And please see the comment below.

Please find the fixed patch.

--
Pranith

From: Pranith Kumar <[email protected]>
Date: Thu, 17 Jul 2014 20:02:54 -0400
Subject: [PATCH 1/1] rcu: Feedback comments

If we configure a kernel with CONFIG_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_NONE=y and CONFIG_CPUMASK_OFFSTACK=n and do not pass in a rcu_nocb= boot parameter, the cpumask rcu_nocb_mask can be garbage instead of NULL.

Hence this commit replaces checks for rcu_nocb_mask == NULL with a check for have_rcu_nocb_mask.

---
 kernel/rcu/tree_plugin.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
kernel/rcu/tree_plugin.h +0 -0
index ce8c331..8f987c1 100644

kernel/rcu/tree_plugin.h static void rcu_init_one_nocb(struct rcu_node *rnp) · line 2059

Quoted 10 lines
kernel/rcu/tree_plugin.h +4 -3
@@ -2053,9 +2053,10 @@ static void rcu_init_one_nocb(struct rcu_node *rnp)
 /* Is the specified CPU a no-CBs CPU? */
 bool rcu_is_nocb_cpu(int cpu)
 {
-	if (have_rcu_nocb_mask)
-		return cpumask_test_cpu(cpu, rcu_nocb_mask);
-	return false;
+	if (!have_rcu_nocb_mask)
+		return false;
+
+	return cpumask_test_cpu(cpu, rcu_nocb_mask);

Hmmm... That was a subtle way to tell me that my feedback was bogus. ;-) I guess I need to stop reviewing patches at 2AM local time.

Anyway, you are correct, this was OK to start with, so I am dropping this hunk.

I queued the other two for 3.18.

Thanx, Paul

Quoted 34 lines
kernel/rcu/tree_plugin.h +3 -3
 }
 #endif /* #ifndef CONFIG_RCU_NOCB_CPU_ALL */
 
@@ -2540,7 +2541,7 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 	struct rcu_data *rdp_leader = NULL;  /* Suppress misguided gcc warn. */
 	struct rcu_data *rdp_prev = NULL;
 
-	if (rcu_nocb_mask == NULL)
+	if (!have_rcu_nocb_mask)
 		return;
 #if defined(CONFIG_NO_HZ_FULL) && !defined(CONFIG_NO_HZ_FULL_ALL)
 	if (tick_nohz_full_running)
@@ -2574,9 +2575,9 @@ static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp)
 /* Prevent __call_rcu() from enqueuing callbacks on no-CBs CPUs */
 static bool init_nocb_callback_list(struct rcu_data *rdp)
 {
-	if (rcu_nocb_mask == NULL ||
-	    !cpumask_test_cpu(rdp->cpu, rcu_nocb_mask))
+	if (!rcu_is_nocb_cpu(rdp->cpu))
 		return false;
+
 	rdp->nxttail[RCU_NEXT_TAIL] = NULL;
 	return true;
 }
Signature · 8 lines
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#4 lore raw
Quoted 19 lines · Paul E. McKenney
Quoted 5 lines
kernel/rcu/tree_plugin.h +0 -0
index ce8c331..8f987c1 100644

kernel/rcu/tree_plugin.h static void rcu_init_one_nocb(struct rcu_node *rnp) · line 2059

Quoted 10 lines
kernel/rcu/tree_plugin.h +4 -3
@@ -2053,9 +2053,10 @@ static void rcu_init_one_nocb(struct rcu_node *rnp)
 /* Is the specified CPU a no-CBs CPU? */
 bool rcu_is_nocb_cpu(int cpu)
 {
-	if (have_rcu_nocb_mask)
-		return cpumask_test_cpu(cpu, rcu_nocb_mask);
-	return false;
+	if (!have_rcu_nocb_mask)
+		return false;
+
+	return cpumask_test_cpu(cpu, rcu_nocb_mask);

Hmmm... That was a subtle way to tell me that my feedback was bogus. ;-) I guess I need to stop reviewing patches at 2AM local time.

Quoted 3 lines

Anyway, you are correct, this was OK to start with, so I am dropping this hunk.

I thought you wanted me to change the check of the have_rcu_nocb_mask, and I really think the new version is better. But yes, more of a style change :)

--
Pranith