rcu: Improve srcu_readers_active_idx()'s cache locality
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 6 Mar 2012 09:57:34 +0000 (17:57 +0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 30 Apr 2012 17:48:24 +0000 (10:48 -0700)
Expand the calls to srcu_readers_active_idx() from srcu_readers_active()
inline.  This change improves cache locality by interating over the CPUs
once rather than twice.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/srcu.c

index e0139a274856e4adb16d41b4817d7ab68a16f8c4..a43211c9286390e52c45efc10bf9d1ceee9ef5b0 100644 (file)
@@ -193,7 +193,14 @@ static bool srcu_readers_active_idx_check(struct srcu_struct *sp, int idx)
  */
 static int srcu_readers_active(struct srcu_struct *sp)
 {
-       return srcu_readers_active_idx(sp, 0) + srcu_readers_active_idx(sp, 1);
+       int cpu;
+       unsigned long sum = 0;
+
+       for_each_possible_cpu(cpu) {
+               sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[0]);
+               sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[1]);
+       }
+       return sum;
 }
 
 /**