Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3571382rdb; Wed, 13 Sep 2023 16:52:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXbXOo6g6JZuK8njzlg+e4qPOa5WfQ7RrIXpEuvyDe9/tUbFFzlbQax0eNfTUAN8NL1wt7 X-Received: by 2002:a05:6808:652:b0:3ab:83fe:e18e with SMTP id z18-20020a056808065200b003ab83fee18emr3981878oih.54.1694649176365; Wed, 13 Sep 2023 16:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694649176; cv=none; d=google.com; s=arc-20160816; b=kpWXLfqeU0jSTsyb7d0Bg5lD1ySPU2EF+7aYgDhDzGifs8wwLrpELQBKiy4QJw63go V4BU/9vx7ZVAgUrsv1Jsckh6XQMUnKZ86ocvXmjwF3wO+0jS8zODdP5HaWNhSGsA3iQi El6PvHNzV8hCpdbRVhdNixjbWbmHLCLYcTOwobmIf5bv5DJ68Ry50/z+NdtL3OCSEX+z ULXfRLzlgsiyOL3XpPeu5/JbItW+BpMFsfIpxBM8dh3pGw1KeoU+xsFIF5WSztklmTJH /7FlEPnhG+KhARTE05AaRDJ8Tw3zF9blUyzY3CwzWZcXvIh2+NuLSJ7JXv/hYDxnDvW8 ajKg== 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 :dkim-signature; bh=HEQUCPUPTnw8DVS45Whbzs7PuWsvHPKXqwBfw1rbYI4=; fh=0kSCNnJ+Dz7/k19JqdLGTHBnZxdhAtg5C+lF7soNwhs=; b=JAm7JjX/DE+NZewQhKimEtF73ThStVzQkJefdEqc/c76uPL3rj5zoAz+79sqL/tnrb LFeBKZtXZfMKiEJjj6ZHcvR/3f8LmtxD8fDz/XekIvNccZjUi36JVL6GlVnwkyNcdvWe Yr0m3Radn3uSjhgi337mnWAhHYhnEaZ6oUzOM1b+L14TItd6ZtlyUXc3AlNj5frr9Cmk 0qMs0zNB3aFBdaz5XD8dJqtXw4+GhN17xh0KtzztLeAYPfHqlKyEe6m6R78/AgTKSD0x IcGLsWYOlw0YjHZdljjjlNwabrTISAB3rzCaBK8ov7AObqyxkWL3kHDAgN+h/axzXn9p cCoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ssUxvOoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q21-20020a056a00085500b0068ff2e98875si358554pfk.1.2023.09.13.16.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ssUxvOoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A8BD382365C7; Tue, 12 Sep 2023 20:51:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238245AbjIMDvY (ORCPT + 99 others); Tue, 12 Sep 2023 23:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236065AbjIMDvM (ORCPT ); Tue, 12 Sep 2023 23:51:12 -0400 Received: from out-211.mta0.migadu.com (out-211.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23A5172C for ; Tue, 12 Sep 2023 20:51:07 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1694577066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HEQUCPUPTnw8DVS45Whbzs7PuWsvHPKXqwBfw1rbYI4=; b=ssUxvOoXRUx2Pm6338qfoIwPn+XyiQU0rIfk8nVcF0TtKWrXpDxxFPUgY2e9y0Y7m3Oue0 DYgkAFvj9Shjeqs0cwM0NWJd/2n/wM7Xea1Az4VMr1IYnqz2jEkRLEfSdLeckiQhAgnTfr d0gjwXhTex1t74vgRyp8NR6DrmptqRs= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, bvanassche@acm.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou Subject: [PATCH v4 2/6] blk-mq-tag: introduce __blk_mq_tagset_busy_iter() Date: Wed, 13 Sep 2023 03:50:29 +0000 Message-Id: <20230913035033.1549277-3-chengming.zhou@linux.dev> In-Reply-To: <20230913035033.1549277-1-chengming.zhou@linux.dev> References: <20230913035033.1549277-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 20:51:31 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.vger.email From: Chengming Zhou For support of specified queue filter when iterating over a tagset, we introduce __blk_mq_tagset_busy_iter() here and all current users just set queue as NULL which means have no queue filter. Reviewed-by: Bart Van Assche Signed-off-by: Chengming Zhou --- block/blk-mq-tag.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 3cf3cf72cd54..dc4edde3c80a 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -381,15 +381,18 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data) * to continue iterating tags, false to stop. * @data: Will be passed as second argument to @fn. * @flags: BT_TAG_ITER_* + * @q: Only iterate over requests of this queue. */ static void bt_tags_for_each(struct blk_mq_tags *tags, struct sbitmap_queue *bt, - busy_tag_iter_fn *fn, void *data, unsigned int flags) + busy_tag_iter_fn *fn, void *data, unsigned int flags, + struct request_queue *q) { struct bt_tags_iter_data iter_data = { .tags = tags, .fn = fn, .data = data, .flags = flags, + .q = q, }; if (tags->rqs) @@ -397,14 +400,15 @@ static void bt_tags_for_each(struct blk_mq_tags *tags, struct sbitmap_queue *bt, } static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags, - busy_tag_iter_fn *fn, void *priv, unsigned int flags) + busy_tag_iter_fn *fn, void *priv, unsigned int flags, + struct request_queue *q) { WARN_ON_ONCE(flags & BT_TAG_ITER_RESERVED); if (tags->nr_reserved_tags) bt_tags_for_each(tags, &tags->breserved_tags, fn, priv, - flags | BT_TAG_ITER_RESERVED); - bt_tags_for_each(tags, &tags->bitmap_tags, fn, priv, flags); + flags | BT_TAG_ITER_RESERVED, q); + bt_tags_for_each(tags, &tags->bitmap_tags, fn, priv, flags, q); } /** @@ -422,7 +426,23 @@ static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags, void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, void *priv) { - __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS); + __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS, NULL); +} + +static void __blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, + busy_tag_iter_fn *fn, void *priv, + struct request_queue *q) +{ + unsigned int flags = tagset->flags; + int i, nr_tags; + + nr_tags = blk_mq_is_shared_tags(flags) ? 1 : tagset->nr_hw_queues; + + for (i = 0; i < nr_tags; i++) { + if (tagset->tags && tagset->tags[i]) + __blk_mq_all_tag_iter(tagset->tags[i], fn, priv, + BT_TAG_ITER_STARTED, q); + } } /** @@ -441,16 +461,7 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, busy_tag_iter_fn *fn, void *priv) { - unsigned int flags = tagset->flags; - int i, nr_tags; - - nr_tags = blk_mq_is_shared_tags(flags) ? 1 : tagset->nr_hw_queues; - - for (i = 0; i < nr_tags; i++) { - if (tagset->tags && tagset->tags[i]) - __blk_mq_all_tag_iter(tagset->tags[i], fn, priv, - BT_TAG_ITER_STARTED); - } + __blk_mq_tagset_busy_iter(tagset, fn, priv, NULL); } EXPORT_SYMBOL(blk_mq_tagset_busy_iter); -- 2.40.1