[RFC v2 3/5] rcu: Use for_each_leaf_node_cpu() in ->expmask iteration

From: Boqun Feng
Date: Wed Dec 14 2016 - 21:44:08 EST


The ->expmask of an RCU leaf node should be more sparse than the
corresponding part of cpu_possible_mask, iterating over ->expmask bitmap
rather cpu_possible_mask to save some checks.

Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
---
kernel/rcu/tree_exp.h | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index a3a8756670d1..c4b3c8d01941 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -419,7 +419,6 @@ static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
int cpu;
unsigned long jiffies_stall;
unsigned long jiffies_start;
- unsigned long mask;
int ndetected;
struct rcu_node *rnp;
struct rcu_node *rnp_root = rcu_get_root(rsp);
@@ -444,12 +443,9 @@ static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
ndetected = 0;
rcu_for_each_leaf_node(rsp, rnp) {
ndetected += rcu_print_task_exp_stall(rnp);
- for_each_leaf_node_possible_cpu(rnp, cpu) {
+ for_each_leaf_node_cpu(rnp, rnp->expmask, cpu) {
struct rcu_data *rdp;

- mask = leaf_node_cpu_bit(rnp, cpu);
- if (!(rnp->expmask & mask))
- continue;
ndetected++;
rdp = per_cpu_ptr(rsp->rda, cpu);
pr_cont(" %d-%c%c%c", cpu,
@@ -475,14 +471,10 @@ static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
}
pr_cont("\n");
}
- rcu_for_each_leaf_node(rsp, rnp) {
- for_each_leaf_node_possible_cpu(rnp, cpu) {
- mask = leaf_node_cpu_bit(rnp, cpu);
- if (!(rnp->expmask & mask))
- continue;
+ rcu_for_each_leaf_node(rsp, rnp)
+ for_each_leaf_node_cpu(rnp, rnp->expmask, cpu)
dump_cpu_task(cpu);
- }
- }
+
jiffies_stall = 3 * rcu_jiffies_till_stall_check() + 3;
}
}
--
2.10.2