Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp456902rwb; Thu, 22 Sep 2022 01:54:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KMvfPxlilEr6r3J9SLs+2EQAbHFI8XGH9yn1oSX+4WdKnzfzpFs6lG86wHtomAUlq6K7E X-Received: by 2002:a17:90a:6887:b0:203:5861:fc5d with SMTP id a7-20020a17090a688700b002035861fc5dmr14427064pjd.132.1663836863958; Thu, 22 Sep 2022 01:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663836863; cv=none; d=google.com; s=arc-20160816; b=d1LjVKhrVjLBYsBZVA7Q43rqVfoakdPMgMOhbHYlHybf4VycPXnjhTmy6OGGx+IN5j /6Qj87RQ0jLgkI7MaWGgBQtwkO4YxZjm19zKf8TYPx1AD6GDKUd6fSJpq2lkX6ziRjA2 KBvdFCfqUCnecwtI0/ucYQ+yFkCvCNHwS6TQoeH5R2TcP8nZINI8kuZARUGjxE4qTyja 99CRxjZzmbjQwqvukEompamy3bNu1mgsJUNcLHySLzgvW8NC1uMoSQbvpcDn+fZax8av k2E8J2iL/iaCJ5cm0zXzbG0zX+ua8MT7pKoR4EDtfdFWkiwuxq7276CW+HeoAGLC3FHn y24Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=rk/AUBZkyK4WEL0xMD1MP1TuSlITkOAlqM4wbmizJuw=; b=fZAMAWvZWGE3EwPrsaT/yXpACys9K0KSaqW4K4nyu6E3qIoSioykWA7Sw17R6zqd4P rhozV/U1mk3HpCgvWUuryRyzO32OYZ2X9P6yTsmmY+Cm1driDpxQgcK9ckKLCT79lo4O 4Y/Tdcs95sv7f6OFWGBau8GSMxz54h/QBu6acysjoLoi/oZmDtS7ODEuDlozzEWnEYES CqSQ4qvoS0q1JKmx2p6qm4aLbQfEw3TF27ImGgN1ZqIbAjaogvnwvRKInJKfq8mnk5Gj mQlotpU4ywizoomKtITJB79vit/1uvi9x2kUilIdMXMlJRG652ZYKZCP7N2j4QubpxBg nwpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6300c7000000b0043077e1e17fsi5621217pga.680.2022.09.22.01.54.09; Thu, 22 Sep 2022 01:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbiIVI2u (ORCPT + 99 others); Thu, 22 Sep 2022 04:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiIVI2t (ORCPT ); Thu, 22 Sep 2022 04:28:49 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0305AB04B for ; Thu, 22 Sep 2022 01:28:47 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R971e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VQRkoi7_1663835274; Received: from localhost(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VQRkoi7_1663835274) by smtp.aliyun-inc.com; Thu, 22 Sep 2022 16:28:45 +0800 From: Liu Song To: hch@lst.de Cc: axboe@kernel.dk, kbusch@kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, liusong@linux.alibaba.com, sagi@grimberg.me Subject: [RFC PATCH v2] blk-mq: hctx has only one ctx mapping is no need to redirect the completion Date: Thu, 22 Sep 2022 16:27:54 +0800 Message-Id: <1663835274-3703-1-git-send-email-liusong@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20220922062010.GA27946@lst.de> References: <20220922062010.GA27946@lst.de> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Song High-performance NVMe devices usually support a larger number of hw queue, which ensures a 1:1 mapping of hctx and ctx. In this case there will be no remote request, so we don't need to care about it. Signed-off-by: Liu Song --- block/blk-mq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c11949d..7f9be13 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1093,10 +1093,11 @@ bool blk_mq_complete_request_remote(struct request *rq) WRITE_ONCE(rq->state, MQ_RQ_COMPLETE); /* - * For a polled request, always complete locally, it's pointless - * to redirect the completion. + * If the request's hctx has only one ctx mapping, + * or is a polled request, both always complete locally, + * it's pointless to redirect the completion. */ - if (rq->cmd_flags & REQ_POLLED) + if (rq->mq_hctx->nr_ctx == 1 || rq->cmd_flags & REQ_POLLED) return false; if (blk_mq_complete_need_ipi(rq)) { -- 1.8.3.1