Skip to contentSkip to conversation

rcu: Remove redundant checks for rcu_scheduler_fully_active

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Remove redundant checks for rcu_scheduler_fully_active

rcu_scheduler_fully_active is set to true early in the boot process.

rcu_prepare_kthreads() is called in two locations. Once after setting the above flag and the other while hotplugging a CPU from rcu_cpu_notify(). CPU hotplug is enabled much later by which time the above flag is already set. Hence checking for this flag is redundant in this function.

The checks in rcu_spawn_one_boost_kthread() and rcu_spawn_all_nocb_kthreads() are similarly redundant.

This commit removes the redundant checks for this flag from the above locations.

---
 kernel/rcu/tree_plugin.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/rcu/tree_plugin.h +4 -6
index 17ccb62..a2113f6 100644
@@ -1341,7 +1341,7 @@ static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
 	if (&rcu_preempt_state != rsp)
 		return 0;
 
-	if (!rcu_scheduler_fully_active || rnp->qsmaskinit == 0)
+	if (rnp->qsmaskinit == 0)
 		return 0;
 
 	rsp->boost = 1;
@@ -1489,8 +1489,7 @@ static void rcu_prepare_kthreads(int cpu)
 	struct rcu_node *rnp = rdp->mynode;
 
 	/* Fire up the incoming CPU's kthread and leaf rcu_node kthread. */
-	if (rcu_scheduler_fully_active)
-		(void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
+	(void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
 }
 
 #else /* #ifdef CONFIG_RCU_BOOST */
@@ -2509,9 +2508,8 @@ static void rcu_spawn_all_nocb_kthreads(int cpu)
 {
 	struct rcu_state *rsp;
 
-	if (rcu_scheduler_fully_active)
-		for_each_rcu_flavor(rsp)
-			rcu_spawn_one_nocb_kthread(rsp, cpu);
+	for_each_rcu_flavor(rsp)
+		rcu_spawn_one_nocb_kthread(rsp, cpu);
 }
 
 /*
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Pranith Kumar

rcu_scheduler_fully_active is set to true early in the boot process.

rcu_prepare_kthreads() is called in two locations. Once after setting the above flag and the other while hotplugging a CPU from rcu_cpu_notify(). CPU hotplug is enabled much later by which time the above flag is already set. Hence checking for this flag is redundant in this function.

Quoted 7 lines

The checks in rcu_spawn_one_boost_kthread() and rcu_spawn_all_nocb_kthreads() are similarly redundant.

This commit removes the redundant checks for this flag from the above locations.

Good catch! Queued for 3.18.

Thanx, Paul

Quoted 42 lines
---
 kernel/rcu/tree_plugin.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/rcu/tree_plugin.h +4 -6
index 17ccb62..a2113f6 100644
@@ -1341,7 +1341,7 @@ static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
 	if (&rcu_preempt_state != rsp)
 		return 0;
 
-	if (!rcu_scheduler_fully_active || rnp->qsmaskinit == 0)
+	if (rnp->qsmaskinit == 0)
 		return 0;
 
 	rsp->boost = 1;
@@ -1489,8 +1489,7 @@ static void rcu_prepare_kthreads(int cpu)
 	struct rcu_node *rnp = rdp->mynode;
 
 	/* Fire up the incoming CPU's kthread and leaf rcu_node kthread. */
-	if (rcu_scheduler_fully_active)
-		(void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
+	(void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp);
 }
 
 #else /* #ifdef CONFIG_RCU_BOOST */
@@ -2509,9 +2508,8 @@ static void rcu_spawn_all_nocb_kthreads(int cpu)
 {
 	struct rcu_state *rsp;
 
-	if (rcu_scheduler_fully_active)
-		for_each_rcu_flavor(rsp)
-			rcu_spawn_one_nocb_kthread(rsp, cpu);
+	for_each_rcu_flavor(rsp)
+		rcu_spawn_one_nocb_kthread(rsp, cpu);
 }
 
 /*
Signature · 1 line
1.9.1