mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] percpu_counter: unbreak __percpu_counter_add()
@ 2014-01-16 23:26 Hugh Dickins
  2014-01-17  1:58 ` Ming Lei
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2014-01-16 23:26 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Ming Lei, Paul Gortmaker, Shaohua Li, Jens Axboe,
	Fan Du, linux-kernel

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

Signed-off-by: Hugh Dickins <hughd@google.com>
---

 lib/percpu_counter.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- 3.13-rc8+/lib/percpu_counter.c	2014-01-15 09:53:27.768111792 -0800
+++ linux/lib/percpu_counter.c	2014-01-16 14:58:54.156555308 -0800
@@ -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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] percpu_counter: unbreak __percpu_counter_add()
  2014-01-16 23:26 [PATCH] percpu_counter: unbreak __percpu_counter_add() Hugh Dickins
@ 2014-01-17  1:58 ` Ming Lei
  0 siblings, 0 replies; 2+ messages in thread
From: Ming Lei @ 2014-01-17  1:58 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Linus Torvalds, Andrew Morton, Paul Gortmaker, Shaohua Li,
	Jens Axboe, Fan Du, Linux Kernel Mailing List

On Fri, Jan 17, 2014 at 7:26 AM, Hugh Dickins <hughd@google.com> wrote:
> 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
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>
>  lib/percpu_counter.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- 3.13-rc8+/lib/percpu_counter.c      2014-01-15 09:53:27.768111792 -0800
> +++ linux/lib/percpu_counter.c  2014-01-16 14:58:54.156555308 -0800
> @@ -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,
-- 
Ming Lei

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-17  1:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16 23:26 [PATCH] percpu_counter: unbreak __percpu_counter_add() Hugh Dickins
2014-01-17  1:58 ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®