* [PATCH] block, nvme: export and use passthrough stats
@ 2026-05-22 15:15 Keith Busch
2026-05-23 18:54 ` Nilay Shroff
2026-05-25 7:32 ` Christoph Hellwig
0 siblings, 2 replies; 6+ messages in thread
From: Keith Busch @ 2026-05-22 15:15 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: axboe, hch, nilay, Keith Busch
From: Keith Busch <kbusch@kernel.org>
So stacking drivers can also report passthrough workloads through
iostat.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
block/blk-mq.c | 30 ------------------------------
drivers/nvme/host/multipath.c | 4 +++-
include/linux/blk-mq.h | 29 +++++++++++++++++++++++++++++
3 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 28c2d931e75ea..c794b70fefe26 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1088,36 +1088,6 @@ static inline void blk_account_io_done(struct request *req, u64 now)
}
}
-static inline bool blk_rq_passthrough_stats(struct request *req)
-{
- struct bio *bio = req->bio;
-
- if (!blk_queue_passthrough_stat(req->q))
- return false;
-
- /* Requests without a bio do not transfer data. */
- if (!bio)
- return false;
-
- /*
- * Stats are accumulated in the bdev, so must have one attached to a
- * bio to track stats. Most drivers do not set the bdev for passthrough
- * requests, but nvme is one that will set it.
- */
- if (!bio->bi_bdev)
- return false;
-
- /*
- * We don't know what a passthrough command does, but we know the
- * payload size and data direction. Ensuring the size is aligned to the
- * block size filters out most commands with payloads that don't
- * represent sector access.
- */
- if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
- return false;
- return true;
-}
-
static inline void blk_account_io_start(struct request *req)
{
trace_block_io_start(req);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 263161cb8ac06..435fab0be6401 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -175,9 +175,11 @@ void nvme_mpath_start_request(struct request *rq)
nvme_req(rq)->flags |= NVME_MPATH_CNT_ACTIVE;
}
- if (!blk_queue_io_stat(disk->queue) || blk_rq_is_passthrough(rq) ||
+ if (!blk_queue_io_stat(disk->queue) ||
(nvme_req(rq)->flags & NVME_MPATH_IO_STATS))
return;
+ if (blk_rq_is_passthrough(rq) && !blk_rq_passthrough_stats(rq))
+ return;
nvme_req(rq)->flags |= NVME_MPATH_IO_STATS;
nvme_req(rq)->start_time = bdev_start_io_acct(disk->part0, req_op(rq),
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 18a2388ba581d..8301830ece8b7 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1243,4 +1243,33 @@ static inline int blk_rq_map_sg(struct request *rq, struct scatterlist *sglist)
}
void blk_dump_rq_flags(struct request *, char *);
+static inline bool blk_rq_passthrough_stats(struct request *req)
+{
+ struct bio *bio = req->bio;
+
+ if (!blk_queue_passthrough_stat(req->q))
+ return false;
+
+ /* Requests without a bio do not transfer data. */
+ if (!bio)
+ return false;
+
+ /*
+ * Stats are accumulated in the bdev, so must have one attached to a
+ * bio to track stats. Most drivers do not set the bdev for passthrough
+ * requests, but nvme is one that will set it.
+ */
+ if (!bio->bi_bdev)
+ return false;
+
+ /*
+ * We don't know what a passthrough command does, but we know the
+ * payload size and data direction. Ensuring the size is aligned to the
+ * block size filters out most commands with payloads that don't
+ * represent sector access.
+ */
+ if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
+ return false;
+ return true;
+}
#endif /* BLK_MQ_H */
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block, nvme: export and use passthrough stats
2026-05-22 15:15 [PATCH] block, nvme: export and use passthrough stats Keith Busch
@ 2026-05-23 18:54 ` Nilay Shroff
2026-05-25 7:32 ` Christoph Hellwig
1 sibling, 0 replies; 6+ messages in thread
From: Nilay Shroff @ 2026-05-23 18:54 UTC (permalink / raw)
To: Keith Busch, linux-block, linux-nvme; +Cc: axboe, hch, Keith Busch
On 5/22/26 8:45 PM, Keith Busch wrote:
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 263161cb8ac06..435fab0be6401 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -175,9 +175,11 @@ void nvme_mpath_start_request(struct request *rq)
> nvme_req(rq)->flags |= NVME_MPATH_CNT_ACTIVE;
> }
>
> - if (!blk_queue_io_stat(disk->queue) || blk_rq_is_passthrough(rq) ||
> + if (!blk_queue_io_stat(disk->queue) ||
> (nvme_req(rq)->flags & NVME_MPATH_IO_STATS))
> return;
> + if (blk_rq_is_passthrough(rq) && !blk_rq_passthrough_stats(rq))
> + return;
>
> nvme_req(rq)->flags |= NVME_MPATH_IO_STATS;
> nvme_req(rq)->start_time = bdev_start_io_acct(disk->part0, req_op(rq),
Thanks for this patch! It will be very useful for nvme top dashboard for
displaying passthru I/O stat under head node.
Well, I see an issue here with @rq being passed to blk_rq_passthrough_stats()
as the @rq->q points to nvme path queue object rather than the head node queue
object. The intention here is to account passthrough I/O statistics at the
head node level, but with the current implementation the decision depends
on the path queue's iostats_passthrough setting instead of the head queue's
setting. As a result, head-node passthrough I/O statistics may get accounted
based on whether the underlying path queue has iostats_passthrough enabled,
irrespective of the head queue configuration.
Another issue is that nvme_mpath_start_request() is only reached from
nvme_start_request() when REQ_NVME_MPATH is set. Normal bio based I/O
through the head gets that flag in nvme_ns_head_submit_bio(), but the
passthrough ioctl/uring path in the quoted patch does not set it. So
head passthrough I/O would not enter nvme_mpath_start_request() and
would not get head-node stats.
Thanks,
--Nilay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block, nvme: export and use passthrough stats
2026-05-22 15:15 [PATCH] block, nvme: export and use passthrough stats Keith Busch
2026-05-23 18:54 ` Nilay Shroff
@ 2026-05-25 7:32 ` Christoph Hellwig
2026-05-25 7:35 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:32 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch
On Fri, May 22, 2026 at 08:15:37AM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> So stacking drivers can also report passthrough workloads through
> iostat.
Except that this patch also wires it up in nvme. So please split
it and write proper commit messages for both parts.
> +static inline bool blk_rq_passthrough_stats(struct request *req)
> +{
And maybe add a kerneldoc comment now that this is public.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block, nvme: export and use passthrough stats
2026-05-25 7:32 ` Christoph Hellwig
@ 2026-05-25 7:35 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:35 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch
On Mon, May 25, 2026 at 09:32:19AM +0200, Christoph Hellwig wrote:
> On Fri, May 22, 2026 at 08:15:37AM -0700, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> >
> > So stacking drivers can also report passthrough workloads through
> > iostat.
>
> Except that this patch also wires it up in nvme. So please split
> it and write proper commit messages for both parts.
.. and while we're at it - it actually is called from the lower nvme
drivers, just conditional on being a mpath request. So this is
in many ways a bit weird, and the comments / commit logs should
probably explain it a bit.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] block, nvme: export and use passthrough stats
@ 2026-05-28 0:58 Keith Busch
2026-05-28 1:00 ` Keith Busch
0 siblings, 1 reply; 6+ messages in thread
From: Keith Busch @ 2026-05-28 0:58 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: axboe, hch, Keith Busch
From: Keith Busch <kbusch@kernel.org>
So stacking drivers can also report passthrough workloads through
iostat.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
block/blk-mq.c | 30 ------------------------------
drivers/nvme/host/multipath.c | 4 +++-
include/linux/blk-mq.h | 29 +++++++++++++++++++++++++++++
3 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 28c2d931e75ea..c794b70fefe26 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1088,36 +1088,6 @@ static inline void blk_account_io_done(struct request *req, u64 now)
}
}
-static inline bool blk_rq_passthrough_stats(struct request *req)
-{
- struct bio *bio = req->bio;
-
- if (!blk_queue_passthrough_stat(req->q))
- return false;
-
- /* Requests without a bio do not transfer data. */
- if (!bio)
- return false;
-
- /*
- * Stats are accumulated in the bdev, so must have one attached to a
- * bio to track stats. Most drivers do not set the bdev for passthrough
- * requests, but nvme is one that will set it.
- */
- if (!bio->bi_bdev)
- return false;
-
- /*
- * We don't know what a passthrough command does, but we know the
- * payload size and data direction. Ensuring the size is aligned to the
- * block size filters out most commands with payloads that don't
- * represent sector access.
- */
- if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
- return false;
- return true;
-}
-
static inline void blk_account_io_start(struct request *req)
{
trace_block_io_start(req);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 263161cb8ac06..435fab0be6401 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -175,9 +175,11 @@ void nvme_mpath_start_request(struct request *rq)
nvme_req(rq)->flags |= NVME_MPATH_CNT_ACTIVE;
}
- if (!blk_queue_io_stat(disk->queue) || blk_rq_is_passthrough(rq) ||
+ if (!blk_queue_io_stat(disk->queue) ||
(nvme_req(rq)->flags & NVME_MPATH_IO_STATS))
return;
+ if (blk_rq_is_passthrough(rq) && !blk_rq_passthrough_stats(rq))
+ return;
nvme_req(rq)->flags |= NVME_MPATH_IO_STATS;
nvme_req(rq)->start_time = bdev_start_io_acct(disk->part0, req_op(rq),
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 18a2388ba581d..8301830ece8b7 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1243,4 +1243,33 @@ static inline int blk_rq_map_sg(struct request *rq, struct scatterlist *sglist)
}
void blk_dump_rq_flags(struct request *, char *);
+static inline bool blk_rq_passthrough_stats(struct request *req)
+{
+ struct bio *bio = req->bio;
+
+ if (!blk_queue_passthrough_stat(req->q))
+ return false;
+
+ /* Requests without a bio do not transfer data. */
+ if (!bio)
+ return false;
+
+ /*
+ * Stats are accumulated in the bdev, so must have one attached to a
+ * bio to track stats. Most drivers do not set the bdev for passthrough
+ * requests, but nvme is one that will set it.
+ */
+ if (!bio->bi_bdev)
+ return false;
+
+ /*
+ * We don't know what a passthrough command does, but we know the
+ * payload size and data direction. Ensuring the size is aligned to the
+ * block size filters out most commands with payloads that don't
+ * represent sector access.
+ */
+ if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
+ return false;
+ return true;
+}
#endif /* BLK_MQ_H */
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block, nvme: export and use passthrough stats
2026-05-28 0:58 Keith Busch
@ 2026-05-28 1:00 ` Keith Busch
0 siblings, 0 replies; 6+ messages in thread
From: Keith Busch @ 2026-05-28 1:00 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch
Sorry, please disregard. I pointed send-email to the v1 directory by
mistake.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-28 1:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 15:15 [PATCH] block, nvme: export and use passthrough stats Keith Busch
2026-05-23 18:54 ` Nilay Shroff
2026-05-25 7:32 ` Christoph Hellwig
2026-05-25 7:35 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2026-05-28 0:58 Keith Busch
2026-05-28 1:00 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox