Duh the retry setup if the number overflows is not correct. Signed-off-by: Christoph Lameter <cl@xxxxxxxxx> --- lib/percpu_counter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Index: linux-2.6/lib/percpu_counter.c =================================================================== --- linux-2.6.orig/lib/percpu_counter.c 2011-04-13 11:43:23.000000000 -0500 +++ linux-2.6/lib/percpu_counter.c 2011-04-13 11:43:30.000000000 -0500 @@ -80,9 +80,14 @@ void __percpu_counter_add(struct percpu_ /* In case of overflow fold it into the global counter instead */ if (new >= batch || new <= -batch) { spin_lock(&fbc->lock); - fbc->count += __this_cpu_read(*fbc->counters) + amount; + count = __this_cpu_read(*fbc->counters); + fbc->count += count + amount; spin_unlock(&fbc->lock); - amount = 0; + /* + * If cmpxchg fails then we need to subtract the amount that + * we found in the percpu value. + */ + amount = -count; new = 0; } -- 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>