Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5108286rwr; Mon, 8 May 2023 18:33:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69/a+bAQm67lW8WFp412Q9ej5wNtuTJ+Pf51yepAUh/wgHAA9a9BUz0NyHHXOGwe38igYE X-Received: by 2002:a05:6a21:9011:b0:f5:4ab9:2fde with SMTP id tq17-20020a056a21901100b000f54ab92fdemr13039138pzb.48.1683596022980; Mon, 08 May 2023 18:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683596022; cv=none; d=google.com; s=arc-20160816; b=VUdrTL5rWmA7Z0VJmHQ8D+fH3J9yH6OTFUJG7eMdh1cpOvxdnyxv9DwwRNq/czH7CZ I5YtfMra2YNid8RvhFlxsuajc91JP4feL3QNv0knu5zYYUzGCcHzBrp57Uf9mrZWbSqR Gbkr7Ts38BFc3HMjCyPK2ctXd586dx0hM2bQgyw2q5c0RawJg3DmO3nLrj52/KiH/qND oHyGasr0cVHPYN9lhp3TG6dIQEBdrgtk//6u5JouPH5De3CB7vSRx4qnBz+v/Evu8uh+ Cu1ONq1uqsfvBTzUu5hzX3UMyDUsDKSnsLlDRImxhEx0l7Q3dI5yE2kYiSGeQi9Cgm8E qIXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=F5Pj2TK8/Z8QaDkpd7ueT1SLGrmZrcavDg9rwqfVaD0=; b=hN7BpCYmtmlIIJyGuhxJ5oZPBc0x78Vs8G56DpLaKPSEKVZNmjSlT8dGMP4iRGy9B5 I/mpgRKPwwJ+8hJU7LhaPYc8u0HjoDNaEp01+g6DApblWCBbwNeK0b73NvWtQe2I7cgU O15ao3ilaDlPWWn4Jw7kiUaKa1TnjcboydqtVM4DWn93AGVfzd4GN6TrjLDBldrTTcXT AqxgPsTbuDL3ID90qtsMmhloV3EwZM1qYBSFg+L1xF/QZn8D317miMgs/A/a54X8fCWl HRzvyfFeJPcmSNq/QuWgWn4NrKu+53t0fKD2P7NIIYDjsblr4fnLFhKcuBWQH6g73t19 OxGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=b6IJUOLj; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b198-20020a6334cf000000b00514477c4403si321514pga.310.2023.05.08.18.33.30; Mon, 08 May 2023 18:33:42 -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; dkim=pass header.i=@mediatek.com header.s=dk header.b=b6IJUOLj; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbjEIB2W (ORCPT + 99 others); Mon, 8 May 2023 21:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEIB2V (ORCPT ); Mon, 8 May 2023 21:28:21 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC31DB0; Mon, 8 May 2023 18:28:15 -0700 (PDT) X-UUID: c0e57fd0ee0811edb20a276fd37b9834-20230509 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=F5Pj2TK8/Z8QaDkpd7ueT1SLGrmZrcavDg9rwqfVaD0=; b=b6IJUOLjCs7M6DI7iILfKSABxcsQVKXdGiGl3Mys2b1d1o1b40mb1mDD7w5fhwu73d2EcYoQigUQawaXxRQMVJf9yLGikqdAxmwWe7dxOb5rFYUWtGxiXPjfnyOIeKYw9xH0cq1Yl7qD2qGrqp1AaDNuYxnoPON+3ksvQZ2aZKY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.23,REQID:75014003-84fe-44cb-a790-496a64a1718d,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:697ab71,CLOUDID:af592531-6935-4eab-a959-f84f8da15543,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: c0e57fd0ee0811edb20a276fd37b9834-20230509 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 544316469; Tue, 09 May 2023 09:28:08 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 9 May 2023 09:28:06 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 9 May 2023 09:28:06 +0800 From: Ed Tsai To: CC: , , , , , , , , , , , , Ed Tsai Subject: [PATCH v1] block: make the fair sharing of tag configurable Date: Tue, 9 May 2023 09:27:58 +0800 Message-ID: <20230509012758.27094-1-ed.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=no 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 The tags allocation is limited by the fair sharing algorithm. It hurts the performance for UFS devices, because the queue depth of general I/O is reduced by half once the UFS send a control command. Add a new queue flag QUEUE_FLAG_FAIR_TAG_SHARING to make the fair tag sharing configurable. See also https://lore.kernel.org/all/20230103195337.158625-1-bvanassche@acm.org Signed-off-by: Ed Tsai --- block/blk-mq-debugfs.c | 1 + block/blk-mq-tag.c | 1 + block/blk-mq.c | 3 ++- drivers/ufs/core/ufshcd.c | 3 +++ include/linux/blkdev.h | 6 +++++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index d23a8554ec4a..f03b8bfe63be 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -103,6 +103,7 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(RQ_ALLOC_TIME), QUEUE_FLAG_NAME(HCTX_ACTIVE), QUEUE_FLAG_NAME(NOWAIT), + QUEUE_FLAG_NAME(FAIR_TAG_SHARING), }; #undef QUEUE_FLAG_NAME diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index d6af9d431dc6..b8b36823f5f5 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -97,6 +97,7 @@ static int __blk_mq_get_tag(struct blk_mq_alloc_data *data, struct sbitmap_queue *bt) { if (!data->q->elevator && !(data->flags & BLK_MQ_REQ_RESERVED) && + blk_queue_fair_tag_sharing(data->q) && !hctx_may_queue(data->hctx, bt)) return BLK_MQ_NO_TAG; diff --git a/block/blk-mq.c b/block/blk-mq.c index f6dad0886a2f..41f7e2b500bd 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1746,7 +1746,8 @@ static bool __blk_mq_alloc_driver_tag(struct request *rq) bt = &rq->mq_hctx->tags->breserved_tags; tag_offset = 0; } else { - if (!hctx_may_queue(rq->mq_hctx, bt)) + if (blk_queue_fair_tag_sharing(rq->q) && + !hctx_may_queue(rq->mq_hctx, bt)) return false; } diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 17d7bb875fee..e96a50265285 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5149,6 +5149,9 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1); if (hba->quirks & UFSHCD_QUIRK_4KB_DMA_ALIGNMENT) blk_queue_update_dma_alignment(q, 4096 - 1); + + blk_queue_flag_clear(QUEUE_FLAG_FAIR_TAG_SHARING, q); + /* * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links(). diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b441e633f4dd..7fcb2356860d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -561,10 +561,12 @@ struct request_queue { #define QUEUE_FLAG_NOWAIT 29 /* device supports NOWAIT */ #define QUEUE_FLAG_SQ_SCHED 30 /* single queue style io dispatch */ #define QUEUE_FLAG_SKIP_TAGSET_QUIESCE 31 /* quiesce_tagset skip the queue*/ +#define QUEUE_FLAG_FAIR_TAG_SHARING 32 /* fair allocation of shared tags */ #define QUEUE_FLAG_MQ_DEFAULT ((1UL << QUEUE_FLAG_IO_STAT) | \ (1UL << QUEUE_FLAG_SAME_COMP) | \ - (1UL << QUEUE_FLAG_NOWAIT)) + (1UL << QUEUE_FLAG_NOWAIT) | \ + (1UL << QUEUE_FLAG_FAIR_TAG_SHARING)) void blk_queue_flag_set(unsigned int flag, struct request_queue *q); void blk_queue_flag_clear(unsigned int flag, struct request_queue *q); @@ -602,6 +604,8 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q); #define blk_queue_sq_sched(q) test_bit(QUEUE_FLAG_SQ_SCHED, &(q)->queue_flags) #define blk_queue_skip_tagset_quiesce(q) \ test_bit(QUEUE_FLAG_SKIP_TAGSET_QUIESCE, &(q)->queue_flags) +#define blk_queue_fair_tag_sharing(q) \ + test_bit(QUEUE_FLAG_FAIR_TAG_SHARING, &(q)->queue_flags) extern void blk_set_pm_only(struct request_queue *q); extern void blk_clear_pm_only(struct request_queue *q); -- 2.18.0