From patchwork Wed Jun 10 17:29:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 187761 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688382ilo; Wed, 10 Jun 2020 10:33:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznCaahTHcEKtpLPLhJ1MaF2Hl9GNmP2oJVPkhZDnJOSRi6jGOhnYJm3R8SwmlxpOzKB3R2 X-Received: by 2002:a17:906:480f:: with SMTP id w15mr4456160ejq.430.1591810417785; Wed, 10 Jun 2020 10:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591810417; cv=none; d=google.com; s=arc-20160816; b=SGC5rYDlzXQf6+za24P+SPKraNxpqkWclS1WrQ4Qt1pF10tzSu/Nr0p9ystls1C/lG fGtwB7SXMag+NCeJd8l6L4E89mTFIJHX/zDww7DqNJyp27WdQttWp2IqoIznoJ26m3vy a/nADGxqdS5XRrWfrEcmDv1LI+YUH4kPIySl6dONZThs76nFfPlyPtckrCcLzg9vrOej /yo1xxd9GXzeu4N+H6fbHonIjba/eex6GbGvF27VpAJQC7A9IL17D3j7NT2ejuWu9Gij zDPT30UPExcv88+FJuuB5x6lsgBSFpguCKyOZ5YHBuxWUohDOfViHWoZ+hn/rjmCkRE9 bXMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=QPcTf/JWvtsDm8ukqVCC0b0gsBuwVzdmfV0npE0lhEo=; b=oc/9useHeWx/44sKDpzJaUGWaro4o5xjsdl8tWv4PQZu/7jneMkNzxYF3H7PWwZUK0 inpFwNB8rnlcqG7SfR5FzEKii1rUJnVuE0tDGrILTt2BLO9Cwk/m6Nvh8wuuwczVwNqD Ym0h68Nly6z2Wyj6TaMwRcS7g5+iGHpf/j2481CFot5u1UBL5Wy4RP2vjL/CUnm2U6Db oKwm36pszTQXOIIwNyNCpl66q3LMR1DV/bahSIqKsEDTCA79ePfm/Y7W66OpX+KcUSxq jZudmj9agTbnXlIFQIEbptlg7bEDL7CbQ9dHTvSvJRWdc736p4mTYTyTD9zJvv6z3Ni7 tUfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz26si430501ejb.252.2020.06.10.10.33.37 for ; Wed, 10 Jun 2020 10:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbgFJRdh (ORCPT ); Wed, 10 Jun 2020 13:33:37 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5809 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726713AbgFJRdf (ORCPT ); Wed, 10 Jun 2020 13:33:35 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 142185FA3A0285FBF2DE; Thu, 11 Jun 2020 01:33:27 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Thu, 11 Jun 2020 01:33:19 +0800 From: John Garry To: , , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v7 07/12] blk-mq: Add support in hctx_tags_bitmap_show() for a shared sbitmap Date: Thu, 11 Jun 2020 01:29:14 +0800 Message-ID: <1591810159-240929-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1591810159-240929-1-git-send-email-john.garry@huawei.com> References: <1591810159-240929-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since a set-wide shared tag sbitmap may be used, it is no longer valid to examine the per-hctx tagset for getting the active requests for a hctx (when a shared sbitmap is used). As such, add support for the shared sbitmap by using an intermediate sbitmap per hctx, iterating all active tags for the specific hctx in the shared sbitmap. Originally-by: Bart Van Assche Reviewed-by: Hannes Reinecke #earlier version Signed-off-by: John Garry --- block/blk-mq-debugfs.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) -- 2.26.2 diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 05b4be0c03d9..4da7e54adf3b 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -495,6 +495,67 @@ static int hctx_tags_show(void *data, struct seq_file *m) return res; } +struct hctx_sb_data { + struct sbitmap *sb; /* output bitmap */ + struct blk_mq_hw_ctx *hctx; /* input hctx */ +}; + +static bool hctx_filter_fn(struct blk_mq_hw_ctx *hctx, struct request *req, + void *priv, bool reserved) +{ + struct hctx_sb_data *hctx_sb_data = priv; + + if (hctx == hctx_sb_data->hctx) + sbitmap_set_bit(hctx_sb_data->sb, req->tag); + + return true; +} + +static void hctx_filter_sb(struct sbitmap *sb, struct blk_mq_hw_ctx *hctx) +{ + struct hctx_sb_data hctx_sb_data = { .sb = sb, .hctx = hctx }; + + blk_mq_queue_tag_busy_iter(hctx->queue, hctx_filter_fn, &hctx_sb_data); +} + +static int hctx_tags_shared_sbitmap_bitmap_show(void *data, struct seq_file *m) +{ + struct blk_mq_hw_ctx *hctx = data; + struct request_queue *q = hctx->queue; + struct blk_mq_tag_set *set = q->tag_set; + struct sbitmap shared_sb, *sb; + int res; + + if (!set) + return 0; + + /* + * We could use the allocated sbitmap for that hctx here, but + * that would mean that we would need to clean it prior to use. + */ + res = sbitmap_init_node(&shared_sb, + set->__bitmap_tags.sb.depth, + set->__bitmap_tags.sb.shift, + GFP_KERNEL, NUMA_NO_NODE); + if (res) + return res; + sb = &shared_sb; + + res = mutex_lock_interruptible(&q->sysfs_lock); + if (res) + goto out; + if (hctx->tags) { + hctx_filter_sb(sb, hctx); + sbitmap_bitmap_show(sb, m); + } + + mutex_unlock(&q->sysfs_lock); + +out: + sbitmap_free(&shared_sb); + return res; +} + static int hctx_tags_bitmap_show(void *data, struct seq_file *m) { struct blk_mq_hw_ctx *hctx = data; @@ -823,6 +884,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_hctx_shared_sbitmap_attrs {"busy", 0400, hctx_busy_show}, {"ctx_map", 0400, hctx_ctx_map_show}, {"tags", 0400, hctx_tags_show}, + {"tags_bitmap", 0400, hctx_tags_shared_sbitmap_bitmap_show}, {"sched_tags", 0400, hctx_sched_tags_show}, {"sched_tags_bitmap", 0400, hctx_sched_tags_bitmap_show}, {"io_poll", 0600, hctx_io_poll_show, hctx_io_poll_write},