Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp124806rda; Sat, 21 Oct 2023 00:53:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsqZzlm7Y/5BTHdCZjs/knyQmPKXn95OvY+gUlsd1QFRCWj6Nu+soHLz3d7z89DWYqD/JV X-Received: by 2002:a05:6a20:e12a:b0:157:64e4:4260 with SMTP id kr42-20020a056a20e12a00b0015764e44260mr5620779pzb.9.1697874805382; Sat, 21 Oct 2023 00:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697874805; cv=none; d=google.com; s=arc-20160816; b=sf3vFQ13uOWzjAXbC/RH3FlnTlvsmoy0R4DKNMJQ+VR9zHCEz1TMyjapO4szVXiATo VxmUH3A3Beg87uaztjyoX40+hfNCOzkCebtq0ocisQbu/r6+h2rko4hGZopy2P7M/435 SYFf3M4Xu1iIU5v7xefWhRC3TO5gi2mthM5arvXtxpTSYaeBNPHAr0Vg3jH2nKesmfV1 RqPvxQDqCy1LmJ0Od4WEaznOraWBdj+DieJNvAhjfakF7TBTEDahJY5K2r+Hny0v7i+q zMCJwGnH05QPGE587QYk2E2GE1SQXHj1iXfwyLIorTnFzUty7cgqA5qIg8NNEmhaDxuA 22Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Yg9qM2gzZaEhQ8y08dwz07VqCVArRlZEPgLk4DltICw=; fh=arL6pA5NmwMvFY+nZRGHincKL7bYEPRz5M0mwGB0hxY=; b=XTvu/AoFz1PN/hjEz/6wh2q7AxvJWrLekUAgcLh02JZwaguBn99NMdQ/DI+B9vknHC z+R4MzJbvy8Bb3CA5YGD0BsSXTvLql1Bn5f7wI9B+VxhY9Tj0/HOZNwZ2f5mBuUMj6Z8 cJae5At0I7dTm+RbCPLrGU84qcbZOF5+kyyWcz1L8A6q0K9i1Lxa/u/u00Id+wQDWy5r OA09YHwIteRqIIE0UanQm7/5UGM3wMVNrY/A/dl16daacsdxxk0ZrXsbUMo8qtNGk4+q 0fj8JA9OdQkt9iy8HPVfuKeo81rl8iB4rziV3Gq30sU+ihu6x33rE32JsZIFJd49WYfY 1WAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z24-20020a656658000000b005740b4723f9si3444455pgv.811.2023.10.21.00.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 00:53:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E1DCD806047A; Sat, 21 Oct 2023 00:53:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbjJUHwe (ORCPT + 99 others); Sat, 21 Oct 2023 03:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjJUHw2 (ORCPT ); Sat, 21 Oct 2023 03:52:28 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B649D67; Sat, 21 Oct 2023 00:52:25 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SCDFG2Fjvz4f3mHf; Sat, 21 Oct 2023 15:52:18 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAXrt0ygzNl84cpDg--.7754S5; Sat, 21 Oct 2023 15:52:21 +0800 (CST) From: Yu Kuai To: bvanassche@acm.org, hch@lst.de, kbusch@kernel.org, ming.lei@redhat.com, axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 1/8] blk-mq: factor out a structure from blk_mq_tags Date: Sat, 21 Oct 2023 23:47:59 +0800 Message-Id: <20231021154806.4019417-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231021154806.4019417-1-yukuai1@huaweicloud.com> References: <20231021154806.4019417-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAXrt0ygzNl84cpDg--.7754S5 X-Coremail-Antispam: 1UD129KBjvJXoWxGF4xGF4DJr43uw1ktr43Wrg_yoW5uF4Dpa yDGa17Cw1fJr1UXFWvq3yUZF1Sganxtr17Jwn3W34YyF1UCw1fZr1v9rW0vr48ZrsayFsr Grs8trW8tF1UW37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zV CS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s02 6xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_Jr I_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v2 6r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj4 0_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8 JrUvcSsGvfC2KfnxnUUI43ZEXa7sRNvtAUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.7 required=5.0 tests=DATE_IN_FUTURE_06_12, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 21 Oct 2023 00:53:23 -0700 (PDT) From: Yu Kuai Currently tags are fairly shared. The new structure contains only one field active_queues for now. There are no functional changes and this patch prepares for refactoring tag sharing. Signed-off-by: Yu Kuai --- block/blk-mq-debugfs.c | 2 +- block/blk-mq-tag.c | 8 ++++---- block/blk-mq.h | 2 +- include/linux/blk-mq.h | 10 ++++++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 5cbeb9344f2f..f6b77289bc1f 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -400,7 +400,7 @@ static void blk_mq_debugfs_tags_show(struct seq_file *m, seq_printf(m, "nr_tags=%u\n", tags->nr_tags); seq_printf(m, "nr_reserved_tags=%u\n", tags->nr_reserved_tags); seq_printf(m, "active_queues=%d\n", - READ_ONCE(tags->active_queues)); + READ_ONCE(tags->ctl.active_queues)); seq_puts(m, "\nbitmap_tags:\n"); sbitmap_queue_show(&tags->bitmap_tags, m); diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index cc57e2dd9a0b..fe41a0d34fc0 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -57,8 +57,8 @@ void __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx) } spin_lock_irq(&tags->lock); - users = tags->active_queues + 1; - WRITE_ONCE(tags->active_queues, users); + users = tags->ctl.active_queues + 1; + WRITE_ONCE(tags->ctl.active_queues, users); blk_mq_update_wake_batch(tags, users); spin_unlock_irq(&tags->lock); } @@ -94,8 +94,8 @@ void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx) } spin_lock_irq(&tags->lock); - users = tags->active_queues - 1; - WRITE_ONCE(tags->active_queues, users); + users = tags->ctl.active_queues - 1; + WRITE_ONCE(tags->ctl.active_queues, users); blk_mq_update_wake_batch(tags, users); spin_unlock_irq(&tags->lock); diff --git a/block/blk-mq.h b/block/blk-mq.h index f75a9ecfebde..363c8f6e13dd 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -435,7 +435,7 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx, return true; } - users = READ_ONCE(hctx->tags->active_queues); + users = READ_ONCE(hctx->tags->ctl.active_queues); if (!users) return true; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 1ab3081c82ed..5a08527c53b9 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -727,13 +727,16 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, blk_opf_t opf, blk_mq_req_flags_t flags, unsigned int hctx_idx); +struct tag_sharing_ctl { + unsigned int active_queues; +}; + /* * Tag address space map. */ struct blk_mq_tags { unsigned int nr_tags; unsigned int nr_reserved_tags; - unsigned int active_queues; struct sbitmap_queue bitmap_tags; struct sbitmap_queue breserved_tags; @@ -744,9 +747,12 @@ struct blk_mq_tags { /* * used to clear request reference in rqs[] before freeing one - * request pool + * request pool, and to protect tag_sharing_ctl. */ spinlock_t lock; + + /* used when tags is shared for multiple request_queue or hctx. */ + struct tag_sharing_ctl ctl; }; static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, -- 2.39.2