lkml.org 
[lkml]   [2011]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch v3 3/3] percpu_counter: use atomic64 for counter in SMP
Hello,

On Thu, Apr 14, 2011 at 10:04:50AM +0800, shaohua.li@intel.com wrote:
> Index: linux/lib/percpu_counter.c
> ===================================================================
> --- linux.orig/lib/percpu_counter.c 2011-04-14 09:53:04.000000000 +0800
> +++ linux/lib/percpu_counter.c 2011-04-14 10:01:29.000000000 +0800
> @@ -59,13 +59,17 @@ void percpu_counter_set(struct percpu_co
> {
> int cpu;
>
> - spin_lock(&fbc->lock);
> + /*
> + * Don't really need to disable preempt here, just make sure there is
> + * no big latency because of preemption
> + */
> + preempt_disable();
> for_each_possible_cpu(cpu) {
> s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
> *pcount = 0;
> }
> - fbc->count = amount;
> - spin_unlock(&fbc->lock);
> + atomic64_set(&fbc->count, amount);
> + preempt_enable();

Disabling preemption here doesn't make any sense.
percpu_counter_set() inherently requires its users to guarantee that
no other user is modifying the percpu counter.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2011-04-15 06:17    [W:0.078 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site