* [PATCH blktrace 1/6] blktrace: sync blktrace_api.h with kernel
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
@ 2026-11-24 13:45 ` Johannes Thumshirn
2026-11-25 22:53 ` Chaitanya Kulkarni
2026-11-24 13:45 ` [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES Johannes Thumshirn
` (4 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:45 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
Re-sync blktrace_api.h with kernel uapi/linux/blktrace_api.h.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace_api.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/blktrace_api.h b/blktrace_api.h
index 8db24fc..00740d9 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -26,14 +26,16 @@ enum {
BLK_TC_END_V1 = 1 << 15, /* we've run out of bits! */
- BLK_TC_ZONE_APPEND = 1ull << 16, /* zone append */
- BLK_TC_ZONE_RESET = 1ull << 17, /* zone reset */
- BLK_TC_ZONE_RESET_ALL = 1ull << 18, /* zone reset all */
- BLK_TC_ZONE_FINISH = 1ull << 19, /* zone finish */
- BLK_TC_ZONE_OPEN = 1ull << 20, /* zone open */
- BLK_TC_ZONE_CLOSE = 1ull << 21, /* zone close */
-
- BLK_TC_END_V2 = 1ull << 21,
+ BLK_TC_ZONE_APPEND = 1ull << 16, /* zone append */
+ BLK_TC_ZONE_RESET = 1ull << 17, /* zone reset */
+ BLK_TC_ZONE_RESET_ALL = 1ull << 18, /* zone reset all */
+ BLK_TC_ZONE_FINISH = 1ull << 19, /* zone finish */
+ BLK_TC_ZONE_OPEN = 1ull << 20, /* zone open */
+ BLK_TC_ZONE_CLOSE = 1ull << 21, /* zone close */
+
+ BLK_TC_WRITE_ZEROES = 1ull << 22, /* write zeroes */
+
+ BLK_TC_END_V2 = 1ull << 22,
};
#define BLK_TC_SHIFT (16)
@@ -62,7 +64,6 @@ enum {
__BLK_TA_DRV_DATA, /* binary driver data */
__BLK_TA_ZONE_PLUG, /* zone write plug was plugged */
__BLK_TA_ZONE_UNPLUG, /* zone write plug was unplugged */
- __BLK_TA_ZONE_MGMT, /* zone management command was issued */
__BLK_TA_CGROUP = 1 << 8,
};
@@ -98,8 +99,7 @@ enum blktrace_notify {
#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
#define BLK_TA_ZONE_APPEND (__BLK_TA_COMPLETE |\
- BLK_TC_ACT2(BLK_TC_ZONE_APPEND))
-#define BLK_TA_ZONE_MGMT __BLK_TA_ZONE_MGMT
+ BLK_TC_ACT(BLK_TC_ZONE_APPEND))
#define BLK_TA_ZONE_PLUG (__BLK_TA_ZONE_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
#define BLK_TA_ZONE_UNPLUG (__BLK_TA_ZONE_UNPLUG |\
BLK_TC_ACT(BLK_TC_QUEUE))
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 1/6] blktrace: sync blktrace_api.h with kernel
2026-11-24 13:45 ` [PATCH blktrace 1/6] blktrace: sync blktrace_api.h with kernel Johannes Thumshirn
@ 2026-11-25 22:53 ` Chaitanya Kulkarni
0 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:53 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:45 AM, Johannes Thumshirn wrote:
> Re-sync blktrace_api.h with kernel uapi/linux/blktrace_api.h.
>
> Signed-off-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
2026-11-24 13:45 ` [PATCH blktrace 1/6] blktrace: sync blktrace_api.h with kernel Johannes Thumshirn
@ 2026-11-24 13:45 ` Johannes Thumshirn
2026-11-25 22:57 ` Chaitanya Kulkarni
2026-11-25 23:00 ` Chaitanya Kulkarni
2026-11-24 13:45 ` [PATCH blktrace 3/6] blktrace: add ioprio to blktrace Johannes Thumshirn
` (3 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:45 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
Add RWBS value for WRITE ZEROES.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse_fmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index 06b055b..ef9f745 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -66,6 +66,7 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
bool zf = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_FINISH));
bool zo = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_OPEN));
bool zc = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_CLOSE));
+ bool wz = !!(t->action & BLK_TC_ACT(BLK_TC_WRITE_ZEROES));
int i = 0;
if (f)
@@ -92,6 +93,9 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
} else if (zc) {
rwbs[i++] = 'Z';
rwbs[i++] = 'C';
+ } else if (wz) {
+ rwbs[i++] = 'W';
+ rwbs[i++] = 'Z';
} else if (w) {
rwbs[i++] = 'W';
} else if (t->bytes) {
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES
2026-11-24 13:45 ` [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES Johannes Thumshirn
@ 2026-11-25 22:57 ` Chaitanya Kulkarni
2026-11-25 23:00 ` Chaitanya Kulkarni
1 sibling, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:57 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:45 AM, Johannes Thumshirn wrote:
> Add RWBS value for WRITE ZEROES.
>
> Signed-off-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES
2026-11-24 13:45 ` [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES Johannes Thumshirn
2026-11-25 22:57 ` Chaitanya Kulkarni
@ 2026-11-25 23:00 ` Chaitanya Kulkarni
1 sibling, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 23:00 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:45 AM, Johannes Thumshirn wrote:
> Add RWBS value for WRITE ZEROES.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH blktrace 3/6] blktrace: add ioprio to blktrace
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
2026-11-24 13:45 ` [PATCH blktrace 1/6] blktrace: sync blktrace_api.h with kernel Johannes Thumshirn
2026-11-24 13:45 ` [PATCH blktrace 2/6] blktrace: add RWBS for WRITE ZEROES Johannes Thumshirn
@ 2026-11-24 13:45 ` Johannes Thumshirn
2026-11-25 22:59 ` Chaitanya Kulkarni
2026-11-24 13:45 ` [PATCH blktrace 4/6] blktrace: mask __BLK_TA_IOPRIO when decoding actions Johannes Thumshirn
` (2 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:45 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
Add the definitions for I/O priority tracing from the kernel UAPI: the
BLKTRACE_FLAG_IOPRIO setup flag, the __BLK_TA_IOPRIO action flag and the
ioprio member of struct blk_io_trace2.
Convert the ioprio when the trace was recorded on a host with different
endianness, and clear __BLK_TA_IOPRIO when converting to the v1 format,
which cannot carry an I/O priority.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace.h | 3 ++-
blktrace_api.h | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/blktrace.h b/blktrace.h
index 370e921..ea48f3e 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -137,7 +137,7 @@ static inline void bit2_to_bit(struct blk_io_trace2 *new,
old->time = new->time;
old->sector = new->sector;
old->bytes = new->bytes;
- old->action = new->action;
+ old->action = new->action & ~__BLK_TA_IOPRIO;
old->pid = new->pid;
old->device = new->device;
old->cpu = new->cpu;
@@ -165,6 +165,7 @@ static inline void bit2_trace_to_cpu(struct blk_io_trace2 *t)
t->cpu = be32_to_cpu(t->cpu);
t->error = be16_to_cpu(t->error);
t->pdu_len = be16_to_cpu(t->pdu_len);
+ t->ioprio = be16_to_cpu(t->ioprio);
}
static inline void bit_trace_to_cpu(struct blk_io_trace *t)
diff --git a/blktrace_api.h b/blktrace_api.h
index 00740d9..4b56e96 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -65,6 +65,7 @@ enum {
__BLK_TA_ZONE_PLUG, /* zone write plug was plugged */
__BLK_TA_ZONE_UNPLUG, /* zone write plug was unplugged */
__BLK_TA_CGROUP = 1 << 8,
+ __BLK_TA_IOPRIO = 1 << 9,
};
/*
@@ -150,7 +151,8 @@ struct blk_io_trace2 {
__u32 cpu; /* on what cpu did it happen */
__u16 error; /* completion error */
__u16 pdu_len; /* length of data after this trace */
- __u8 pad[12];
+ __u16 ioprio; /* IO priority */
+ __u8 pad[10];
/* cgroup id will be stored here if exists */
};
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 3/6] blktrace: add ioprio to blktrace
2026-11-24 13:45 ` [PATCH blktrace 3/6] blktrace: add ioprio to blktrace Johannes Thumshirn
@ 2026-11-25 22:59 ` Chaitanya Kulkarni
0 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:59 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:45 AM, Johannes Thumshirn wrote:
> Add the definitions for I/O priority tracing from the kernel UAPI: the
> BLKTRACE_FLAG_IOPRIO setup flag, the __BLK_TA_IOPRIO action flag and the
> ioprio member of struct blk_io_trace2.
>
> Convert the ioprio when the trace was recorded on a host with different
> endianness, and clear __BLK_TA_IOPRIO when converting to the v1 format,
> which cannot carry an I/O priority.
>
> Signed-off-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
> ---
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH blktrace 4/6] blktrace: mask __BLK_TA_IOPRIO when decoding actions
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
` (2 preceding siblings ...)
2026-11-24 13:45 ` [PATCH blktrace 3/6] blktrace: add ioprio to blktrace Johannes Thumshirn
@ 2026-11-24 13:45 ` Johannes Thumshirn
2026-11-25 22:56 ` Chaitanya Kulkarni
2026-11-24 13:46 ` [PATCH blktrace 5/6] blktrace: add --ioprio option Johannes Thumshirn
2026-11-24 13:46 ` [PATCH blktrace 6/6] blkparse: print I/O priorities Johannes Thumshirn
5 siblings, 1 reply; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:45 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
__BLK_TA_IOPRIO is a flag in the action, like __BLK_TA_CGROUP, so it has
to be masked out wherever the action is decoded: in blkparse, btt,
iowatcher and btrecord. btt and btrecord did not mask __BLK_TA_CGROUP
either, so mask both there.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 4 ++--
btreplay/btrecord.c | 5 +++--
btt/trace.c | 6 +++++-
iowatcher/blkparse.c | 3 ++-
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 88ef019..980ce42 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -1649,7 +1649,7 @@ static void dump_trace_pc(struct blk_io_trace2 *t, struct per_dev_info *pdi,
struct per_cpu_info *pci)
{
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
- int act = (t->action & 0xffff) & ~__BLK_TA_CGROUP;
+ int act = (t->action & 0xffff) & ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO);
switch (act) {
case __BLK_TA_QUEUE:
@@ -1698,7 +1698,7 @@ static void dump_trace_fs(struct blk_io_trace2 *t, struct per_dev_info *pdi,
struct per_cpu_info *pci)
{
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
- int act = (t->action & 0xffff) & ~__BLK_TA_CGROUP;
+ int act = (t->action & 0xffff) & ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO);
switch (act) {
case __BLK_TA_QUEUE:
diff --git a/btreplay/btrecord.c b/btreplay/btrecord.c
index c1c9456..4a44bd3 100644
--- a/btreplay/btrecord.c
+++ b/btreplay/btrecord.c
@@ -202,8 +202,9 @@ static inline void fatal(const char *errstring, const int exitval,
*/
static inline int match(__u64 action)
{
- return ((action & 0xffff) == __BLK_TA_QUEUE) &&
- (action & BLK_TC_ACT(BLK_TC_QUEUE));
+ __u64 act = action & 0xffff & ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO);
+
+ return act == __BLK_TA_QUEUE && (action & BLK_TC_ACT(BLK_TC_QUEUE));
}
/**
diff --git a/btt/trace.c b/btt/trace.c
index 48f4f99..1f4883a 100644
--- a/btt/trace.c
+++ b/btt/trace.c
@@ -23,6 +23,7 @@
static void __add_trace(struct io *iop)
{
time_t now = time(NULL);
+ unsigned short action;
last_t_seen = BIT_TIME(iop->t.time);
@@ -36,7 +37,10 @@ static void __add_trace(struct io *iop)
last_vtrace = now;
}
- switch (iop->t.action & 0xffff) {
+ action = iop->t.action & 0xffff;
+ action = action & ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO);
+
+ switch (action) {
case __BLK_TA_QUEUE: trace_queue(iop); break;
case __BLK_TA_REMAP: trace_remap(iop); break;
case __BLK_TA_INSERT: trace_insert(iop); break;
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index 92ee1cc..efe7acf 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -50,7 +50,8 @@ extern int plot_io_action;
extern int io_per_process;
#define BLK_DATADIR(a) (((a) >> BLK_TC_SHIFT) & (BLK_TC_READ | BLK_TC_WRITE))
-#define BLK_TA_MASK (((1 << BLK_TC_SHIFT) - 1) & ~__BLK_TA_CGROUP)
+#define BLK_TA_MASK (((1 << BLK_TC_SHIFT) - 1) & \
+ ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO))
struct pending_io {
/* sector offset of this IO */
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 4/6] blktrace: mask __BLK_TA_IOPRIO when decoding actions
2026-11-24 13:45 ` [PATCH blktrace 4/6] blktrace: mask __BLK_TA_IOPRIO when decoding actions Johannes Thumshirn
@ 2026-11-25 22:56 ` Chaitanya Kulkarni
0 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:56 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:45 AM, Johannes Thumshirn wrote:
> __BLK_TA_IOPRIO is a flag in the action, like __BLK_TA_CGROUP, so it has
> to be masked out wherever the action is decoded: in blkparse, btt,
> iowatcher and btrecord. btt and btrecord did not mask __BLK_TA_CGROUP
> either, so mask both there.
>
> Signed-off-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH blktrace 5/6] blktrace: add --ioprio option
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
` (3 preceding siblings ...)
2026-11-24 13:45 ` [PATCH blktrace 4/6] blktrace: mask __BLK_TA_IOPRIO when decoding actions Johannes Thumshirn
@ 2026-11-24 13:46 ` Johannes Thumshirn
2026-11-25 22:56 ` Chaitanya Kulkarni
2026-11-24 13:46 ` [PATCH blktrace 6/6] blkparse: print I/O priorities Johannes Thumshirn
5 siblings, 1 reply; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:46 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
Add an '--ioprio' option to request a trace with I/O priorities recorded
in it from the Kernel.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace.c | 29 +++++++++++++++++++++++++++++
blktrace_api.h | 5 ++++-
doc/blktrace.8 | 5 +++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/blktrace.c b/blktrace.c
index 89a8f8a..9ba3b3e 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -27,6 +27,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <getopt.h>
@@ -284,6 +285,7 @@ static int kill_running_trace;
static int stop_watch;
static int piped_output;
static int trace_ver;
+static bool ioprio_trace;
static char *debugfs_path = "/sys/kernel/debug";
static char *output_name;
@@ -332,6 +334,7 @@ static int (*handle_list)(struct tracer_devpath_head *, struct list_head *);
enum {
OPT_TRACE_VERSION = 256,
+ OPT_IO_PRIO = 257,
};
#define S_OPTS "d:a:A:r:o:kw:vVb:n:D:lh:p:sI:"
@@ -444,6 +447,12 @@ static struct option l_opts[] = {
.flag = NULL,
.val = OPT_TRACE_VERSION
},
+ {
+ .name = "ioprio",
+ .has_arg = no_argument,
+ .flag = NULL,
+ .val = OPT_IO_PRIO,
+ },
{
.name = NULL,
}
@@ -466,6 +475,7 @@ static char usage_str[] = "\n\n" \
"[ -I <devs file> | --input-devs=<devs file>]\n" \
"[ -v <version> | --version]\n" \
"[ -V <version> | --version]\n" \
+ "[ --ioprio ]\n" \
"[ --trace-version=<1|2> ]\n" \
"\t-d Use specified device. May also be given last after options\n" \
@@ -484,6 +494,7 @@ static char usage_str[] = "\n\n" \
"\t-I Add devices found in <devs file>\n" \
"\t-v Print program version info\n" \
"\t-V Print program version info\n" \
+ "\t--ioprio Record I/O priorities (requires trace version 2)\n" \
"\t--trace-version Request trace protocol version 1 or 2 from the kernel\n\n";
static void clear_events(struct pollfd *pfd)
@@ -1093,6 +1104,7 @@ static int setup_buts2(void)
buts2.buf_size = buf_size;
buts2.buf_nr = buf_nr;
buts2.act_mask = act_mask;
+ buts2.flags = ioprio_trace ? BLKTRACE_FLAG_IOPRIO : 0;
if (ioctl(dpp->fd, BLKTRACESETUP2, &buts2) >= 0) {
dpp->ncpus = max_cpus;
@@ -1103,6 +1115,10 @@ static int setup_buts2(void)
dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats));
} else {
+ if (errno == EINVAL && ioprio_trace)
+ fprintf(stderr,
+ "BLKTRACESETUP2 %s: kernel does not support ioprio tracing\n",
+ dpp->path);
ret++;
}
}
@@ -2264,6 +2280,9 @@ static int handle_args(int argc, char *argv[])
exit(1);
}
break;
+ case OPT_IO_PRIO:
+ ioprio_trace = true;
+ break;
default:
show_usage(argv[0]);
exit(1);
@@ -2291,6 +2310,11 @@ static int handle_args(int argc, char *argv[])
return 1;
}
+ if (ioprio_trace && trace_ver == 1) {
+ show_usage(argv[0]);
+ return 1;
+ }
+
if (act_mask_tmp != 0)
act_mask = act_mask_tmp;
@@ -2735,6 +2759,11 @@ static int run_tracers(void)
printf("blktrace: connecting to %s\n", hostname);
if (trace_ver == 1 || setup_buts2()) {
+ if (trace_ver != 1 && ioprio_trace) {
+ done = 1;
+ return 1;
+ }
+
if (setup_buts()) {
done = 1;
return 1;
diff --git a/blktrace_api.h b/blktrace_api.h
index 4b56e96..884a718 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -188,10 +188,13 @@ struct blk_user_trace_setup2 {
__u64 start_lba;
__u64 end_lba;
__u32 pid;
- __u32 flags; /* currently unused */
+ __u32 flags; /* input */
__u64 reserved[11];
};
+#define BLKTRACE_FLAG_IOPRIO (1U << 0)
+#define BLKTRACE_FLAGS_MASK (BLKTRACE_FLAG_IOPRIO)
+
#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
#define BLKTRACESTART _IO(0x12,116)
#define BLKTRACESTOP _IO(0x12,117)
diff --git a/doc/blktrace.8 b/doc/blktrace.8
index c502adc..d35cbbf 100644
--- a/doc/blktrace.8
+++ b/doc/blktrace.8
@@ -191,6 +191,11 @@ Outputs version
Sets run time to the number of seconds specified
.RE
+\-\-ioprio\fR
+.RS
+Record I/O priorities (requires trace version 2)
+.RE
+
\-\-trace\-version=\fI1|2\fR
.RS
Selects the trace protocol version requested from the kernel. Requesting
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 5/6] blktrace: add --ioprio option
2026-11-24 13:46 ` [PATCH blktrace 5/6] blktrace: add --ioprio option Johannes Thumshirn
@ 2026-11-25 22:56 ` Chaitanya Kulkarni
0 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:56 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:46 AM, Johannes Thumshirn wrote:
> Add an '--ioprio' option to request a trace with I/O priorities recorded
> in it from the Kernel.
>
> Signed-off-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH blktrace 6/6] blkparse: print I/O priorities
2026-11-24 13:45 [PATCH blktrace 0/6] blktrace: add IO priorities Johannes Thumshirn
` (4 preceding siblings ...)
2026-11-24 13:46 ` [PATCH blktrace 5/6] blktrace: add --ioprio option Johannes Thumshirn
@ 2026-11-24 13:46 ` Johannes Thumshirn
2026-11-25 22:56 ` Chaitanya Kulkarni
5 siblings, 1 reply; 14+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:46 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Christoph Hellwig, linux-btrace,
Hannes Reinecke, Martin K. Petersen, Johannes Thumshirn
Add the %i format specifier which prints the I/O priority of an event as
"class,hint,level", in the same format as the kernel's block tracepoints,
or "-" if the event does not carry an I/O priority. Events with an I/O
priority also show it after the RWBS field in the default output, so the
default output of traces without I/O priorities does not change.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse_fmt.c | 33 +++++++++++++++++++++++++++++++++
doc/blkparse.1 | 7 +++++++
2 files changed, 40 insertions(+)
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index ef9f745..67345b1 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -16,6 +16,10 @@
#define HEADER "%D %2c %8s %5T.%9t %5p %2a %3d "
+#define IOPRIO_CLASS(ioprio) (((ioprio) >> 13) & 0x7)
+#define IOPRIO_HINT(ioprio) (((ioprio) >> 3) & 0x3ff)
+#define IOPRIO_LEVEL(ioprio) ((ioprio) & 0x7)
+
static char *override_format[256];
static inline int valid_spec(int spec)
@@ -116,6 +120,29 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
rwbs[i] = '\0';
}
+static const char *ioprio_class_str(unsigned int class)
+{
+ static const char * const names[] = { "none", "rt", "be", "idle" };
+
+ if (class < sizeof(names) / sizeof(names[0]))
+ return names[class];
+ return "invalid";
+}
+
+static const char *ioprio_str(struct blk_io_trace2 *t)
+{
+ static char iopbuff[128];
+
+ if (!(t->action & __BLK_TA_IOPRIO))
+ return "-";
+
+ snprintf(iopbuff, sizeof(iopbuff), "%s,%u,%u",
+ ioprio_class_str(IOPRIO_CLASS(t->ioprio)),
+ IOPRIO_HINT(t->ioprio), IOPRIO_LEVEL(t->ioprio));
+
+ return iopbuff;
+}
+
static const char *
print_time(unsigned long long timestamp)
{
@@ -298,6 +325,9 @@ static void print_field(char *act, struct per_cpu_info *pci,
case 'z':
fprintf(ofp, strcat(format, "s"), print_time(t->time));
break;
+ case 'i':
+ fprintf(ofp, strcat(format, "s"), ioprio_str(t));
+ break;
default:
fprintf(ofp,strcat(format, "c"), field);
break;
@@ -373,6 +403,9 @@ static void process_default(char *act, struct per_cpu_info *pci,
(int) SECONDS(t->time), (unsigned long) NANO_SECONDS(t->time),
t->pid, act, rwbs);
+ if (t->action & __BLK_TA_IOPRIO)
+ fprintf(ofp, "%s ", ioprio_str(t));
+
name = find_process_name(t->pid);
switch (act[0]) {
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index 80e7019..b17035f 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -343,6 +343,13 @@ Error value
Cgroup identifier of the cgroup that generated the IO. Note that this requires
appropriate kernel support (kernel version at least 4.14).
+.IP \fBi\fR 4
+I/O priority as \fIclass,hint,level\fR (for example \fIbe,3,4\fR), or
+\fI-\fR if the event carries no I/O priority. The hint is the SCSI/ATA
+command duration limit (CDL) descriptor index for hints 1 to 7. This
+requires a trace recorded with \fBblktrace \-\-ioprio\fR. Such events
+also show the I/O priority after the RWBS field in the default output.
+
.IP \fBm\fR 4
Minor number of event's device.
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH blktrace 6/6] blkparse: print I/O priorities
2026-11-24 13:46 ` [PATCH blktrace 6/6] blkparse: print I/O priorities Johannes Thumshirn
@ 2026-11-25 22:56 ` Chaitanya Kulkarni
0 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2026-11-25 22:56 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Damien Le Moal, Niklas Cassel,
Shinichiro Kawasaki, Christoph Hellwig,
linux-btrace@vger.kernel.org, Hannes Reinecke, Martin K. Petersen
On 11/24/26 5:46 AM, Johannes Thumshirn wrote:
> Add the %i format specifier which prints the I/O priority of an event as
> "class,hint,level", in the same format as the kernel's block tracepoints,
> or "-" if the event does not carry an I/O priority. Events with an I/O
> priority also show it after the RWBS field in the default output, so the
> default output of traces without I/O priorities does not change.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 14+ messages in thread