Subject: + lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter.patch added to -mm tree To: tom.leiming@xxxxxxxxx,akpm@xxxxxxxxxxxxxxxxxxxx,axboe@xxxxxxxxx,fan.du@xxxxxxxxxxxxx,paul.gortmaker@xxxxxxxxxxxxx,shli@xxxxxxxxxxxx,stable@xxxxxxxxxxxxxxx,tj@xxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 07 Jan 2014 14:29:01 -0800 The patch titled Subject: lib/percpu_counter.c: disable local irq when updating percpu couter has been added to the -mm tree. Its filename is lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ming Lei <tom.leiming@xxxxxxxxx> Subject: lib/percpu_counter.c: disable local irq when updating percpu couter __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 disable local irq when updating the percpu counter, otherwise counts may be lost. The patch fixes problem that 'rmmod null_blk' may hang in blk_cleanup_queue() because of miscounting of request_queue->mq_usage_counter. Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx> Cc: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Shaohua Li <shli@xxxxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Fan Du <fan.du@xxxxxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/percpu_counter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff -puN lib/percpu_counter.c~lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter lib/percpu_counter.c --- a/lib/percpu_counter.c~lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter +++ a/lib/percpu_counter.c @@ -75,19 +75,19 @@ EXPORT_SYMBOL(percpu_counter_set); void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) { s64 count; + unsigned long flags; - preempt_disable(); + raw_local_irq_save(flags); count = __this_cpu_read(*fbc->counters) + amount; if (count >= batch || count <= -batch) { - unsigned long flags; - raw_spin_lock_irqsave(&fbc->lock, flags); + raw_spin_lock(&fbc->lock); fbc->count += count; - raw_spin_unlock_irqrestore(&fbc->lock, flags); + raw_spin_unlock(&fbc->lock); __this_cpu_write(*fbc->counters, 0); } else { __this_cpu_write(*fbc->counters, count); } - preempt_enable(); + raw_local_irq_restore(flags); } EXPORT_SYMBOL(__percpu_counter_add); _ Patches currently in -mm which might be from tom.leiming@xxxxxxxxx are lib-percpu_counterc-disable-local-irq-when-updating-percpu-couter.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html