percpu_counter: unbreak __percpu_counter_add()
Subsystems (2)
PATCH 1/1 percpu_counter: unbreak __percpu_counter_add()
Commit 74e72f894d56 ("lib/percpu_counter.c: fix __percpu_counter_add()") looked very plausible, but its arithmetic was badly wrong: obvious once you see the fix, but maddening to get there from the weird tmpfs ENOSPCs
---
lib/percpu_counter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/percpu_counter.c +1 -1
@@ -82,7 +82,7 @@ void __percpu_counter_add(struct percpu_unsigned long flags;raw_spin_lock_irqsave (&fbc->lock, flags); fbc->count += count; -__this_cpu_sub (*fbc->counters, count); +__this_cpu_sub (*fbc->counters, count - amount);raw_spin_unlock_irqrestore (&fbc->lock, flags); }else {this_cpu_add (*fbc->counters, amount);
Quoted 13 lines · Hugh Dickins
Commit
74e72f894d56("lib/percpu_counter.c: fix__percpu_counter_add()") looked very plausible, but its arithmetic was badly wrong: obvious once you see the fix, but maddening to get there from the weird tmpfs ENOSPCsSigned-off-by Hugh Dickins <[email protected]>---
lib/percpu_counter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/percpu_counter.c 2014-01-16 14:58:54.156555308 -0800 void __percpu_counter_add(struct percpu_ · line 85
Quoted 5 lines
lib/percpu_counter.c 2014-01-16 14:58:54.156555308 -0800 renamed from lib/percpu_counter.c 2014-01-15 09:53:27.768111792 -0800 +1
-1@@ -82,7 +82,7 @@ void __percpu_counter_add(struct percpu_ unsigned long flags; raw_spin_lock_irqsave(&fbc->lock, flags); fbc->count += count; - __this_cpu_sub(*fbc->counters, count); + __this_cpu_sub(*fbc->counters, count - amount);
Hammmm, you are right, thanks for the fix, and I really tested the patch with reinserting module of 'null_blk' after lots of IOs, now I know the
reason: the scale of my test is still too small to cover the slow path in case of the batch of 1000000, and only the part in fast path is verified to be OK.
Thanks,
Signature · 1 line
Ming Lei