[RFC 3/5] rcu: Use leaf_node_for_each_mask_possible_cpu() for ->expmask iteration

From: Boqun Feng
Date: Fri Dec 09 2016 - 03:49:44 EST


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

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

diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index a3a8756670d1..8c50a1cb9133 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -419,7 +419,7 @@ static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
int cpu;
unsigned long jiffies_stall;
unsigned long jiffies_start;
- unsigned long mask;
+ unsigned long bit;
int ndetected;
struct rcu_node *rnp;
struct rcu_node *rnp_root = rcu_get_root(rsp);
@@ -444,12 +444,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) {
+ leaf_node_for_each_mask_possible_cpu(rnp, rnp->expmask, bit, 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 +472,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)
+ leaf_node_for_each_mask_possible_cpu(rnp, rnp->expmask, bit, cpu)
dump_cpu_task(cpu);
- }
- }
+
jiffies_stall = 3 * rcu_jiffies_till_stall_check() + 3;
}
}
--
2.10.2