Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea00c30b authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds
Browse files

percpu_counter: use this_cpu_ptr() instead of per_cpu_ptr()



this_cpu_ptr() avoids an array lookup and can use the percpu offset of the
local cpu directly.

Signed-off-by: default avatarChristoph Lameter <cl@linux.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 041b78f2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
{
	s64 count;
	s32 *pcount;
	int cpu = get_cpu();

	pcount = per_cpu_ptr(fbc->counters, cpu);
	preempt_disable();
	pcount = this_cpu_ptr(fbc->counters);
	count = *pcount + amount;
	if (count >= batch || count <= -batch) {
		spin_lock(&fbc->lock);
@@ -85,7 +85,7 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
	} else {
		*pcount = count;
	}
	put_cpu();
	preempt_enable();
}
EXPORT_SYMBOL(__percpu_counter_add);