Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tokunori Ikegami <ikegami.t@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: Tokunori Ikegami <ikegami.t@gmail.com>
Subject: [PATCH] nvme-pci: tagset and admin_tagset sysfs attributes
Date: Sat, 24 May 2025 18:14:41 +0900	[thread overview]
Message-ID: <20250524091637.6938-1-ikegami.t@gmail.com> (raw)

This is to dump the tagset requests in progress.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
---
 drivers/nvme/host/pci.c | 68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index f1dd804151b1..971ababa58b9 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -45,6 +45,11 @@
 #define NVME_MAX_META_SEGS 15
 #define NVME_MAX_NR_ALLOCATIONS	5
 
+struct nvme_sysfs_data {
+	char *buf;
+	int len;
+};
+
 static int use_threaded_interrupts;
 module_param(use_threaded_interrupts, int, 0444);
 
@@ -2322,6 +2327,67 @@ static ssize_t hmb_store(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RW(hmb);
 
+static bool nvme_sysfs_request_show(struct request *req, void *data)
+{
+	struct nvme_sysfs_data *sysfs = data;
+	u8 opcode = nvme_req(req)->cmd->common.opcode;
+	struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
+	int len = sysfs_emit_at(sysfs->buf, sysfs->len,
+				"tag %d (%04x) opcode %#x (%s) QID %d req_op:%s(%u) size:%u state=%d\n",
+				req->tag, nvme_cid(req), opcode,
+				nvme_opcode_str(nvmeq->qid, opcode), nvmeq->qid,
+				blk_op_str(req_op(req)), req_op(req),
+				blk_rq_bytes(req), blk_mq_rq_state(req));
+
+	if (!len)
+		return false;
+
+	sysfs->len += len;
+
+	return true;
+}
+
+static ssize_t tagset_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+	struct nvme_sysfs_data data = {
+		.buf = buf,
+	};
+
+	if (!ctrl->tagset)
+		return sysfs_emit(buf, "none\n");
+
+	blk_mq_tagset_busy_iter(ctrl->tagset, nvme_sysfs_request_show, &data);
+
+	if (!data.len)
+		return sysfs_emit(buf, "no request\n");
+
+	return data.len;
+}
+static DEVICE_ATTR_RO(tagset);
+
+static ssize_t admin_tagset_show(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+	struct nvme_sysfs_data data = {
+		.buf = buf,
+	};
+
+	if (!ctrl->admin_tagset)
+		return sysfs_emit(buf, "none\n");
+
+	blk_mq_tagset_busy_iter(ctrl->admin_tagset, nvme_sysfs_request_show,
+				&data);
+
+	if (!data.len)
+		return sysfs_emit(buf, "no request\n");
+
+	return data.len;
+}
+static DEVICE_ATTR_RO(admin_tagset);
+
 static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj,
 		struct attribute *a, int n)
 {
@@ -2346,6 +2412,8 @@ static struct attribute *nvme_pci_attrs[] = {
 	&dev_attr_cmbloc.attr,
 	&dev_attr_cmbsz.attr,
 	&dev_attr_hmb.attr,
+	&dev_attr_tagset.attr,
+	&dev_attr_admin_tagset.attr,
 	NULL,
 };
 
-- 
2.48.1



                 reply	other threads:[~2025-05-24  9:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250524091637.6938-1-ikegami.t@gmail.com \
    --to=ikegami.t@gmail.com \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox