Re: [PATCH] percpu: preemptless __per_cpu_counter_add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, Christoph.

On Wed, Apr 13, 2011 at 05:23:04PM -0500, Christoph Lameter wrote:
> 
> Suggested fixup. Return from slowpath and update percpu variable under
> spinlock.
> 
> Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>
> 
> ---
>  lib/percpu_counter.c |    8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6/lib/percpu_counter.c
> ===================================================================
> --- linux-2.6.orig/lib/percpu_counter.c	2011-04-13 17:20:41.000000000 -0500
> +++ linux-2.6/lib/percpu_counter.c	2011-04-13 17:21:33.000000000 -0500
> @@ -82,13 +82,9 @@ void __percpu_counter_add(struct percpu_
>  			spin_lock(&fbc->lock);
>  			count = __this_cpu_read(*fbc->counters);
>  			fbc->count += count + amount;
> +			__this_cpu_write(*fbc->counters, 0);
>  			spin_unlock(&fbc->lock);
> -			/*
> -			 * If cmpxchg fails then we need to subtract the amount that
> -			 * we found in the percpu value.
> -			 */
> -			amount = -count;
> -			new = 0;
> +			return;

Yeah, looks pretty good to me now.  Just a couple more things.

* Please fold this one into the original patch.

* While you're restructuring the functions, can you add unlikely to
  the slow path?

It now looks correct to me but just in case, Eric, do you mind
reviewing and acking it?

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]