Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D8D3C0015E for ; Thu, 27 Jul 2023 01:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ep/tgo1JF7kq+mSuQqf46nxDpvZxtSkMn2UHXJJVSFE=; b=qLxQhO7AVk5XuosTdY3j8hrMTJ 1//vwuWLB1jURRREB0C5RrF/TpgFGFo5jMvR36/PXyGdwWQ33jFPXFtTD8w2SYQAA+wMSuGOVN1nE td1lC3M+416j83qIfRQx7Tjs0byq3CIL7G+my7XaggpNGREvCOBoBwbgM8h8hQWEn8ekVhQmqgzVw J0jOnbgH278i/mE61LJ0dIKADMwb42ov3MB2DUL6M34/Fua8v04AJPf+ON2GWc0nu6x+uasW5Cho3 iLL3mDU7zW6jSRviMPRu8EkAYhdT2xwRVVxLobS6xr7g53+v9ANI7UXH05npsl9ZAGDb3IWulEetv VeWFltJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qOpTG-00Bqn7-2h; Thu, 27 Jul 2023 01:07:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qOpTC-00BqmO-1B for linux-nvme@lists.infradead.org; Thu, 27 Jul 2023 01:07:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690420026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ep/tgo1JF7kq+mSuQqf46nxDpvZxtSkMn2UHXJJVSFE=; b=P7eKfaOR4huFyeB1jnEpYoGfTbo/mr3dOFn7M689gDIel6QFXqTpopYSKeySpSPNs7n5A2 FbYCYOfc8Ow9ePQDICNup2a+ZC/F18GVE+yVwti0BpnzJWYJsJnCN8GOKmeuu+bteAYkDI sw4hKTcr/2VgAaNbwLhvx2YLtM1EbsM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-577-HTE6F5RpM4i9E-KzSY3P5w-1; Wed, 26 Jul 2023 21:07:02 -0400 X-MC-Unique: HTE6F5RpM4i9E-KzSY3P5w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 874D7185A78F; Thu, 27 Jul 2023 01:07:01 +0000 (UTC) Received: from ovpn-8-16.pek2.redhat.com (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 008CFC2C7D3; Thu, 27 Jul 2023 01:06:55 +0000 (UTC) Date: Thu, 27 Jul 2023 09:06:50 +0800 From: Ming Lei To: John Garry Cc: Jens Axboe , Christoph Hellwig , linux-nvme@lists.infradead.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Wen Xiong , Keith Busch , ming.lei@redhat.com Subject: Re: [PATCH V2 1/9] blk-mq: add blk_mq_max_nr_hw_queues() Message-ID: References: <20230726094027.535126-1-ming.lei@redhat.com> <20230726094027.535126-2-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230726_180710_491791_C566E7FA X-CRM114-Status: GOOD ( 35.51 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On Wed, Jul 26, 2023 at 05:36:34PM +0100, John Garry wrote: > On 26/07/2023 10:40, Ming Lei wrote: > > Hi Ming, > > > blk_mq_alloc_tag_set() may override set->nr_hw_queues as 1 in case of kdump > > kernel. This way causes trouble for driver, because blk-mq and driver see > > different queue mapping. Especially the only online CPU may not be 1 for > > kdump kernel, in which 'maxcpus=1' is passed from kernel command line, > > "the only online CPU may not be 1 for kdump kernel, in which 'maxcpus=1' > ..." - this seems inconsistent with the cover letter, where we have > "'maxcpus=1' just bring up one single cpu core during booting." OK, looks I should have mentioned "the only online CPU may not be 1 for maxcpus=1" in cover letter. > > then driver may map hctx0 into one inactive real hw queue which cpu > > affinity is 0(offline). > > > > The issue exists on all drivers which use managed irq and support > > multiple hw queue. > > > > Prepare for fixing this kind of issue by applying the added helper, so > > driver can take blk-mq max nr_hw_queues knowledge into account when > > calculating io queues. > > Could you alternatively solve in blk_mq_pci_map_queues() by fixing the > mappings in case of kdump to have all per-CPU mappings point at the HW queue > associated with cpu0 (which I assume would be active)? It ain't pretty ... cpu0 mapping isn't correct, as I mentioned that 'maxcpus=1' doesn't mean the only online cpu is cpu0, such as, on ppc64, the only online cpu could be selected at random during booting. > > > > > Signed-off-by: Ming Lei > > --- > > block/blk-mq.c | 16 ++++++++++++++++ > > include/linux/blk-mq.h | 1 + > > 2 files changed, 17 insertions(+) > > > > diff --git a/block/blk-mq.c b/block/blk-mq.c > > index b04ff6f56926..617d6f849a7b 100644 > > --- a/block/blk-mq.c > > +++ b/block/blk-mq.c > > @@ -140,6 +140,22 @@ void blk_mq_freeze_queue_wait(struct request_queue *q) > > } > > EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait); > > +/* > > + * Return the max supported nr_hw_queues for each hw queue type > > + * > > + * blk_mq_alloc_tag_set() may change nr_hw_queues for kdump kernel, so > > + * driver has to take blk-mq max supported nr_hw_queues into account > > + * when figuring out nr_hw_queues from hardware info, for avoiding > > + * inconsistency between driver and blk-mq. > > + */ > > +unsigned int blk_mq_max_nr_hw_queues(void) > > +{ > > + if (is_kdump_kernel()) > > + return 1; > > + return nr_cpu_ids; > > +} > > We rely on the driver having set->nr_hw_queues == 1 for kdump, right? > > If so, how about enforcing it then, like: > > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -4426,7 +4426,8 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) > * 64 tags to prevent using too much memory. > */ > if (is_kdump_kernel()) { > - set->nr_hw_queues = 1; > + if (set->nr_hw_queues != 1) > + return -EINVAL; > set->nr_maps = 1; > set->queue_depth = min(64U, set->queue_depth); > } In theory, this way should be ideal approach, but it needs all MQ drivers to get converted with blk_mq_max_nr_hw_queues(). However, it shouldn't be one issue for non-managed irq given non-managed irq can be migrated to the only online cpu. Thanks, Ming