lib/percpu_counter.c: fix __percpu_counter_add()
authorMing Lei <tom.leiming@gmail.com>
Wed, 15 Jan 2014 01:56:42 +0000 (17:56 -0800)
committerJens Axboe <axboe@fb.com>
Mon, 30 Mar 2015 18:54:38 +0000 (12:54 -0600)
commit38d4fc7b537d3c22e3f25ab5ba2ea27f1cf90521
tree02692c1736b92a82d7a972f1b2fddf2423f74d03
parente68f257a1c10655254c70c7c4e9f89b142297fb6
lib/percpu_counter.c: fix __percpu_counter_add()

__percpu_counter_add() may be called in softirq/hardirq handler (such
as, blk_mq_queue_exit() is typically called in hardirq/softirq handler),
so we need to call this_cpu_add()(irq safe helper) to update percpu
counter, otherwise counts may be lost.

This fixes the problem that 'rmmod null_blk' hangs in blk_cleanup_queue()
because of miscounting of request_queue->mq_usage_counter.

This patch is the v1 of previous one of "lib/percpu_counter.c:
disable local irq when updating percpu couter", and takes Andrew's
approach which may be more efficient for ARCHs(x86, s390) that
have optimized this_cpu_add().

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Shaohua Li <shli@fusionio.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Fan Du <fan.du@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/percpu_counter.c