[RFC 4/5] rcu: Use leaf_node_for_each_mask_possible_cpu() in force_qs_rnp()

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


->qsmask of an RCU leaf node is usually more sparse than the
corresponding cpu_possible_mask. So replace the
for_each_leaf_node_possible_cpu() in force_qs_rnp() with
leaf_node_for_each_mask_possible_cpu() to save several checks.

Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
---
kernel/rcu/tree.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 5f6802b9ba5f..10162ac71dbe 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3014,6 +3014,7 @@ static void force_qs_rnp(struct rcu_state *rsp,
bool *isidle, unsigned long *maxj)
{
int cpu;
+ unsigned long bit;
unsigned long flags;
unsigned long mask;
struct rcu_node *rnp;
@@ -3047,13 +3048,11 @@ static void force_qs_rnp(struct rcu_state *rsp,
continue;
}
}
- for_each_leaf_node_possible_cpu(rnp, cpu) {
- unsigned long bit = leaf_node_cpu_bit(rnp, cpu);
- if ((rnp->qsmask & bit) != 0) {
- if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj))
- mask |= bit;
- }
- }
+
+ leaf_node_for_each_mask_possible_cpu(rnp, rnp->qsmask, bit, cpu)
+ if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj))
+ mask |= 1 << bit;
+
if (mask != 0) {
/* Idle/offline CPUs, report (releases rnp->lock. */
rcu_report_qs_rnp(mask, rsp, rnp, rnp->gpnum, flags);
--
2.10.2