From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:59378 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbeAQMfU (ORCPT ); Wed, 17 Jan 2018 07:35:20 -0500 From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Thomas Gleixner Cc: Christoph Hellwig , "jianchao . wang" , Christian Borntraeger , Ming Lei , Stefan Haberland , Christoph Hellwig Subject: [PATCH 2/2] blk-mq: convert WARN_ON in __blk_mq_run_hw_queue to printk Date: Wed, 17 Jan 2018 20:34:44 +0800 Message-Id: <20180117123444.18393-3-ming.lei@redhat.com> In-Reply-To: <20180117123444.18393-1-ming.lei@redhat.com> References: <20180117123444.18393-1-ming.lei@redhat.com> Sender: linux-block-owner@vger.kernel.org List-Id: linux-block@vger.kernel.org We know this WARN_ON is harmless and the stack trace isn't useful too, so convert it to printk(), and avoid to confuse people. Also add comment about two releated races here. Cc: Christian Borntraeger Cc: Stefan Haberland Cc: Christoph Hellwig Cc: Thomas Gleixner Cc: "jianchao.wang" Signed-off-by: Ming Lei --- block/blk-mq.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index dc4066d28323..6562360bf108 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1391,9 +1391,25 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) /* * We should be running this queue from one of the CPUs that * are mapped to it. + * + * There are at least two related races now between setting + * hctx->next_cpu from blk_mq_hctx_next_cpu() and running + * __blk_mq_run_hw_queue(): + * + * - hctx->next_cpu is found offline in blk_mq_hctx_next_cpu(), + * but later it becomes online, then this warning is harmless + * at all + * + * - hctx->next_cpu is found online in blk_mq_hctx_next_cpu(), + * but later it becomes offline, then the warning can't be + * triggered, and we depend on blk-mq timeout handler to + * handle dispatched requests to this hctx */ - WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) && - cpu_online(hctx->next_cpu)); + if (!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) && + cpu_online(hctx->next_cpu)) + printk(KERN_WARNING "run queue from wrong CPU %d, hctx %s\n", + raw_smp_processor_id(), + cpumask_empty(hctx->cpumask) ? "inactive": "active"); /* * We can't run the queue inline with ints disabled. Ensure that -- 2.9.5