mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
rcu: Improve srcu_readers_active_idx()'s cache locality
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>
This commit is contained in:
parent
966f58c2f6
commit
dc87917501
1 changed files with 8 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue