lkml.org 
[lkml]   [2010]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] percpu_counter: change inaccurate comment
On Thu, 7 Oct 2010, Eric Dumazet wrote:

> percpu_counter used to be huge objects, they are not anymore,
> thanks to fine alloc_percpu() granularity.
>
> We now consume 4 bytes per possible cpu.

Ahh I did not notice that they switched.... Then we may also want the
following patch to improve performance. It would even be better if we
could do a this_cpu_add(fbc->counters, amount) there but the 64 bit size
fo count looks suspiciously like you are expecting overflows beyond ints
max size.


Subject: 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: Christoph Lameter <cl@linux.com>

---
lib/percpu_counter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/lib/percpu_counter.c
===================================================================
--- linux-2.6.orig/lib/percpu_counter.c 2010-10-07 14:36:39.000000000 -0500
+++ linux-2.6/lib/percpu_counter.c 2010-10-07 14:38:43.000000000 -0500
@@ -30,9 +30,9 @@ void __percpu_counter_add(struct percpu_
{
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);
@@ -42,7 +42,7 @@ void __percpu_counter_add(struct percpu_
} else {
*pcount = count;
}
- put_cpu();
+ preempt_enable();
}
EXPORT_SYMBOL(__percpu_counter_add);


\
 
 \ /
  Last update: 2010-10-07 21:45    [W:0.080 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site