* [PATCH 0/5] blktrace: add support for tracing I/O priorities
@ 2026-11-24 13:35 Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2 Johannes Thumshirn
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
Now that we have a new format in blktrace, we finally also have a chance
of tracing I/O priorities.
This series adds tracing of I/O priorities to both blktrace and the
block layer's tracepoints.
Johannes Thumshirn (5):
blktrace: add ioprio field to struct blk_io_trace2
blktrace: pass ioprio to tracing data
blktrace: record I/O priorities if requested
blktrace: decode ioprio on ftrace block tracer
block: add ioprio to the bio based tracepoints
include/linux/blktrace_api.h | 1 +
include/trace/events/block.h | 50 +++++++++++---
include/uapi/linux/blktrace_api.h | 10 ++-
kernel/trace/blktrace.c | 105 +++++++++++++++++++++++-------
4 files changed, 131 insertions(+), 35 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
@ 2026-11-24 13:35 ` Johannes Thumshirn
2026-11-25 4:58 ` Christoph Hellwig
2026-11-24 13:35 ` [PATCH 2/5] blktrace: pass ioprio to tracing data Johannes Thumshirn
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
Add the UAPI definitions for passing I/O priorities, and with them SCSI
command duration limit (CDL) hints, to user space:
- BLKTRACE_FLAG_IOPRIO in blk_user_trace_setup2::flags to request I/O
priority tracing,
- __BLK_TA_IOPRIO in the action to mark events which carry an I/O
priority, and
- an ioprio member in struct blk_io_trace2, taken from the reserved
padding, so the size and layout of the structure do not change.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
include/uapi/linux/blktrace_api.h | 10 ++++++++--
kernel/trace/blktrace.c | 2 ++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
index 7c092d9f3aa4..7c580e5f62b5 100644
--- a/include/uapi/linux/blktrace_api.h
+++ b/include/uapi/linux/blktrace_api.h
@@ -67,6 +67,7 @@ enum blktrace_act {
__BLK_TA_ZONE_PLUG, /* zone write plug was plugged */
__BLK_TA_ZONE_UNPLUG, /* zone write plug was unplugged */
__BLK_TA_CGROUP = 1 << 8, /* from a cgroup*/
+ __BLK_TA_IOPRIO = 1 << 9, /* blk_io_trace2.ioprio is valid */
};
/*
@@ -145,7 +146,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; /* valid if action & __BLK_TA_IOPRIO */
+ __u8 pad[10];
/* cgroup id will be stored here if it exists */
};
/*
@@ -190,8 +192,12 @@ struct blk_user_trace_setup2 {
__u64 start_lba;
__u64 end_lba;
__u32 pid;
- __u32 flags; /* currently unused */
+ __u32 flags; /* input, BLKTRACE_FLAG_* */
__u64 reserved[11];
};
+/* blk_user_trace_setup2.flags */
+#define BLKTRACE_FLAG_IOPRIO (1U << 0) /* record I/O priorities */
+#define BLKTRACE_FLAGS_MASK (BLKTRACE_FLAG_IOPRIO)
+
#endif /* _UAPIBLKTRACE_H */
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 04a450542389..4d39edc6730d 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1860,6 +1860,8 @@ static int __init __init_blk_tracer(void)
BUILD_BUG_ON(__alignof__(struct blk_user_trace_setup2) %
__alignof__(long));
BUILD_BUG_ON(__alignof__(struct blk_io_trace2) % __alignof__(long));
+ BUILD_BUG_ON(sizeof(struct blk_io_trace2) != 64);
+ BUILD_BUG_ON(offsetof(struct blk_io_trace2, ioprio) != 52);
return 0;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] blktrace: pass ioprio to tracing data
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2 Johannes Thumshirn
@ 2026-11-24 13:35 ` Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 3/5] blktrace: record I/O priorities if requested Johannes Thumshirn
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
Pass the I/O priority of the bio or request down to the recording
functions and store it in struct blk_io_trace2. Events without a bio or
request (plug, unplug and the zone write plug events) pass -1, so that
they can later be told apart from requests with an I/O priority of 0.
No user visible change yet, as __BLK_TA_IOPRIO is not set on any event.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
kernel/trace/blktrace.c | 50 ++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 4d39edc6730d..c57df30750e9 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -95,7 +95,7 @@ static void record_blktrace_event2(struct blk_io_trace2 *t2, pid_t pid, int cpu,
sector_t sector, int bytes, u64 what,
dev_t dev, int error, u64 cgid,
ssize_t cgid_len, void *pdu_data,
- int pdu_len)
+ int pdu_len, u16 ioprio)
{
t2->pid = pid;
t2->cpu = cpu;
@@ -108,6 +108,7 @@ static void record_blktrace_event2(struct blk_io_trace2 *t2, pid_t pid, int cpu,
t2->pdu_len = pdu_len + cgid_len;
memset(t2->pad, 0, sizeof(t2->pad));
+ t2->ioprio = ioprio;
if (cgid_len)
memcpy((void *)t2 + sizeof(*t2), &cgid, cgid_len);
@@ -138,7 +139,8 @@ static void relay_blktrace_event1(struct blk_trace *bt, unsigned long sequence,
static void relay_blktrace_event2(struct blk_trace *bt, unsigned long sequence,
pid_t pid, int cpu, sector_t sector,
int bytes, u64 what, int error, u64 cgid,
- ssize_t cgid_len, void *pdu_data, int pdu_len)
+ ssize_t cgid_len, void *pdu_data, int pdu_len,
+ u16 ioprio)
{
struct blk_io_trace2 *t;
size_t trace_len = sizeof(struct blk_io_trace2) + pdu_len + cgid_len;
@@ -152,18 +154,19 @@ static void relay_blktrace_event2(struct blk_trace *bt, unsigned long sequence,
t->time = ktime_to_ns(ktime_get());
record_blktrace_event2(t, pid, cpu, sector, bytes, what, bt->dev, error,
- cgid, cgid_len, pdu_data, pdu_len);
+ cgid, cgid_len, pdu_data, pdu_len, ioprio);
}
static void relay_blktrace_event(struct blk_trace *bt, unsigned long sequence,
pid_t pid, int cpu, sector_t sector, int bytes,
u64 what, int error, u64 cgid,
- ssize_t cgid_len, void *pdu_data, int pdu_len)
+ ssize_t cgid_len, void *pdu_data, int pdu_len,
+ u16 ioprio)
{
if (bt->version == 2)
return relay_blktrace_event2(bt, sequence, pid, cpu, sector,
bytes, what, error, cgid, cgid_len,
- pdu_data, pdu_len);
+ pdu_data, pdu_len, ioprio);
return relay_blktrace_event1(bt, sequence, pid, cpu, sector, bytes,
what, error, cgid, cgid_len, pdu_data,
pdu_len);
@@ -196,7 +199,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, u64 action,
t = ring_buffer_event_data(event);
record_blktrace_event2(t, pid, cpu, 0, 0,
action, bt->dev, 0, cgid, cgid_len,
- (void *)data, len);
+ (void *)data, len, 0);
trace_buffer_unlock_commit(blk_tr, buffer, event, trace_ctx);
return;
}
@@ -205,7 +208,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, u64 action,
return;
relay_blktrace_event(bt, 0, pid, cpu, 0, 0, action, 0, cgid,
- cgid_len, (void *)data, len);
+ cgid_len, (void *)data, len, 0);
}
/*
@@ -311,7 +314,7 @@ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ),
*/
static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
const blk_opf_t opf, u64 what, int error,
- int pdu_len, void *pdu_data, u64 cgid)
+ int pdu_len, void *pdu_data, u64 cgid, int ioprio)
{
struct task_struct *tsk = current;
struct ring_buffer_event *event = NULL;
@@ -444,7 +447,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
record_blktrace_event2(ring_buffer_event_data(event),
pid, cpu, sector, bytes,
what, bt->dev, error, cgid, cgid_len,
- pdu_data, pdu_len);
+ pdu_data, pdu_len, max(ioprio, 0));
break;
}
@@ -464,7 +467,8 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
sequence = per_cpu_ptr(bt->sequence, cpu);
(*sequence)++;
relay_blktrace_event(bt, *sequence, pid, cpu, sector, bytes,
- what, error, cgid, cgid_len, pdu_data, pdu_len);
+ what, error, cgid, cgid_len, pdu_data, pdu_len,
+ max(ioprio, 0));
local_irq_restore(flags);
}
@@ -1038,7 +1042,8 @@ static void blk_add_trace_rq(struct request *rq, blk_status_t error,
what |= BLK_TC_ACT(BLK_TC_FS);
__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, rq->cmd_flags,
- what, blk_status_to_errno(error), 0, NULL, cgid);
+ what, blk_status_to_errno(error), 0, NULL, cgid,
+ req_get_ioprio(rq));
rcu_read_unlock();
}
@@ -1114,7 +1119,7 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio,
__blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
bio->bi_opf, what, error, 0, NULL,
- blk_trace_bio_get_cgid(q, bio));
+ blk_trace_bio_get_cgid(q, bio), bio->bi_ioprio);
rcu_read_unlock();
}
@@ -1154,7 +1159,7 @@ static void blk_add_trace_plug(void *ignore, struct request_queue *q)
rcu_read_lock();
bt = rcu_dereference(q->blk_trace);
if (bt)
- __blk_add_trace(bt, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0);
+ __blk_add_trace(bt, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0, -1);
rcu_read_unlock();
}
@@ -1174,7 +1179,8 @@ static void blk_add_trace_unplug(void *ignore, struct request_queue *q,
else
what = BLK_TA_UNPLUG_TIMER;
- __blk_add_trace(bt, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0);
+ __blk_add_trace(bt, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0,
+ -1);
}
rcu_read_unlock();
}
@@ -1189,7 +1195,7 @@ static void blk_add_trace_zone_plug(void *ignore, struct request_queue *q,
bt = rcu_dereference(q->blk_trace);
if (bt && bt->version >= 2)
__blk_add_trace(bt, sector, sectors << SECTOR_SHIFT, 0,
- BLK_TA_ZONE_PLUG, 0, 0, NULL, 0);
+ BLK_TA_ZONE_PLUG, 0, 0, NULL, 0, -1);
rcu_read_unlock();
return;
@@ -1205,7 +1211,7 @@ static void blk_add_trace_zone_unplug(void *ignore, struct request_queue *q,
bt = rcu_dereference(q->blk_trace);
if (bt && bt->version >= 2)
__blk_add_trace(bt, sector, sectors << SECTOR_SHIFT, 0,
- BLK_TA_ZONE_UNPLUG, 0, 0, NULL, 0);
+ BLK_TA_ZONE_UNPLUG, 0, 0, NULL, 0, -1);
rcu_read_unlock();
return;
}
@@ -1224,7 +1230,8 @@ static void blk_add_trace_split(void *ignore, struct bio *bio, unsigned int pdu)
bio->bi_iter.bi_size, bio->bi_opf, BLK_TA_SPLIT,
blk_status_to_errno(bio->bi_status),
sizeof(rpdu), &rpdu,
- blk_trace_bio_get_cgid(q, bio));
+ blk_trace_bio_get_cgid(q, bio),
+ bio->bi_ioprio);
}
rcu_read_unlock();
}
@@ -1259,7 +1266,8 @@ static void blk_add_trace_bio_remap(void *ignore, struct bio *bio, dev_t dev,
__blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
bio->bi_opf, BLK_TA_REMAP,
blk_status_to_errno(bio->bi_status),
- sizeof(r), &r, blk_trace_bio_get_cgid(q, bio));
+ sizeof(r), &r, blk_trace_bio_get_cgid(q, bio),
+ bio->bi_ioprio);
rcu_read_unlock();
}
@@ -1294,7 +1302,8 @@ static void blk_add_trace_rq_remap(void *ignore, struct request *rq, dev_t dev,
__blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq),
rq->cmd_flags, BLK_TA_REMAP, 0,
- sizeof(r), &r, blk_trace_request_get_cgid(rq));
+ sizeof(r), &r, blk_trace_request_get_cgid(rq),
+ req_get_ioprio(rq));
rcu_read_unlock();
}
@@ -1321,7 +1330,8 @@ void blk_add_driver_data(struct request *rq, void *data, size_t len)
__blk_add_trace(bt, blk_rq_trace_sector(rq), blk_rq_bytes(rq), 0,
BLK_TA_DRV_DATA, 0, len, data,
- blk_trace_request_get_cgid(rq));
+ blk_trace_request_get_cgid(rq),
+ req_get_ioprio(rq));
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(blk_add_driver_data);
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] blktrace: record I/O priorities if requested
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2 Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 2/5] blktrace: pass ioprio to tracing data Johannes Thumshirn
@ 2026-11-24 13:35 ` Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 4/5] blktrace: decode ioprio on ftrace block tracer Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 5/5] block: add ioprio to the bio based tracepoints Johannes Thumshirn
4 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
Accept BLKTRACE_FLAG_IOPRIO in BLKTRACESETUP2 and, if it is set, mark all
events that belong to a bio or request with __BLK_TA_IOPRIO, so user space
knows that blk_io_trace2::ioprio is valid. Old kernels reject the flag
with -EINVAL, so user space can detect the support. BLKTRACESETUP (v1)
has no flags and therefore never gets I/O priorities.
For the ftrace blk tracer the TRACE_BLK_OPT_IOPRIO flag is checked
instead, the corresponding tracer option is added together with the
decoding of the I/O priority in the next patch.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
include/linux/blktrace_api.h | 1 +
kernel/trace/blktrace.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 05c8754456aa..63d76a176e9a 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -27,6 +27,7 @@ struct blk_trace {
struct dentry *dir;
struct list_head running_list;
atomic_t dropped;
+ u32 flags;
};
extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index c57df30750e9..f1a3407d36c9 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -40,6 +40,7 @@ static __cacheline_aligned_in_smp DEFINE_RAW_SPINLOCK(running_trace_lock);
#define TRACE_BLK_OPT_CLASSIC 0x1
#define TRACE_BLK_OPT_CGROUP 0x2
#define TRACE_BLK_OPT_CGNAME 0x4
+#define TRACE_BLK_OPT_IOPRIO 0x8
static struct tracer_opt blk_tracer_opts[] = {
/* Default disable the minimalistic output */
@@ -308,6 +309,13 @@ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ),
#define MASK_TC_BIT(rw, __name) ((__force u32)(rw & REQ_ ## __name) << \
(ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - __REQ_ ## __name))
+static bool blk_trace_want_ioprio(struct blk_trace *bt, bool blk_tracer)
+{
+ if (blk_tracer)
+ return blk_tracer_flags.val & TRACE_BLK_OPT_IOPRIO;
+ return bt->version == 2 && (bt->flags & BLKTRACE_FLAG_IOPRIO);
+}
+
/*
* The worker for the various blk_add_trace*() types. Fills out a
* blk_io_trace structure and places it in a per-cpu subbuffer.
@@ -381,6 +389,8 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
if (cgid)
what |= __BLK_TA_CGROUP;
+ if (ioprio >= 0 && blk_trace_want_ioprio(bt, blk_tracer))
+ what |= __BLK_TA_IOPRIO;
pid = tsk->pid;
if (act_log_check(bt, what, sector, pid))
@@ -760,6 +770,7 @@ static void blk_trace_setup_finalize(struct request_queue *q,
bt->pid = buts->pid;
bt->trace_state = Blktrace_setup;
+ bt->flags = buts->flags;
rcu_assign_pointer(q->blk_trace, bt);
get_probe_ref();
@@ -823,7 +834,7 @@ static int blk_trace_setup2(struct request_queue *q, char *name, dev_t dev,
if (!buts2.buf_size || !buts2.buf_nr)
return -EINVAL;
- if (buts2.flags != 0)
+ if (buts2.flags & ~BLKTRACE_FLAGS_MASK)
return -EINVAL;
memflags = blk_debugfs_lock(q);
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] blktrace: decode ioprio on ftrace block tracer
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
` (2 preceding siblings ...)
2026-11-24 13:35 ` [PATCH 3/5] blktrace: record I/O priorities if requested Johannes Thumshirn
@ 2026-11-24 13:35 ` Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 5/5] block: add ioprio to the bio based tracepoints Johannes Thumshirn
4 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
Add the blk_ioprio option to the ftrace blk tracer. If it is set, events
with an I/O priority are marked with __BLK_TA_IOPRIO and the I/O priority
is printed as "class,hint,level" after the RWBS column, in the same
format as the block_rq_* tracepoints use.
Mask __BLK_TA_IOPRIO when decoding the action, and when synthesizing v1
records for the 'bin' output, which has no room for the I/O priority.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
kernel/trace/blktrace.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index f1a3407d36c9..c779263d2937 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -49,6 +49,7 @@ static struct tracer_opt blk_tracer_opts[] = {
{ TRACER_OPT(blk_cgroup, TRACE_BLK_OPT_CGROUP) },
{ TRACER_OPT(blk_cgname, TRACE_BLK_OPT_CGNAME) },
#endif
+ { TRACER_OPT(blk_ioprio, TRACE_BLK_OPT_IOPRIO) },
{ }
};
@@ -1513,6 +1514,33 @@ static __u64 get_pdu_int(const struct trace_entry *ent, bool has_cg)
typedef void (blk_log_action_t) (struct trace_iterator *iter, const char *act,
bool has_cg);
+static const char *ioprio_class_name(u16 class)
+{
+ switch (class) {
+ case IOPRIO_CLASS_NONE:
+ return "none";
+ case IOPRIO_CLASS_RT:
+ return "rt";
+ case IOPRIO_CLASS_BE:
+ return "be";
+ case IOPRIO_CLASS_IDLE:
+ return "idle";
+ default:
+ return "invalid";
+ }
+}
+
+static void blk_log_ioprio(struct trace_seq *s, const struct blk_io_trace2 *t)
+{
+ if (!(t->action & __BLK_TA_IOPRIO))
+ return;
+
+ trace_seq_printf(s, "%s,%u,%u ",
+ ioprio_class_name(IOPRIO_PRIO_CLASS(t->ioprio)),
+ IOPRIO_PRIO_HINT(t->ioprio),
+ IOPRIO_PRIO_LEVEL(t->ioprio));
+}
+
static void blk_log_action_classic(struct trace_iterator *iter, const char *act,
bool has_cg)
{
@@ -1528,6 +1556,7 @@ static void blk_log_action_classic(struct trace_iterator *iter, const char *act,
"%3d,%-3d %2d %5d.%09lu %5u %2s %3s ",
MAJOR(t->device), MINOR(t->device), iter->cpu,
secs, nsec_rem, iter->ent->pid, act, rwbs);
+ blk_log_ioprio(&iter->seq, t);
}
static void blk_log_action(struct trace_iterator *iter, const char *act,
@@ -1548,6 +1577,7 @@ static void blk_log_action(struct trace_iterator *iter, const char *act,
trace_seq_printf(&iter->seq, "%3d,%-3d %s %2s %3s ",
MAJOR(t->device), MINOR(t->device),
blkcg_name_buf, act, rwbs);
+ blk_log_ioprio(&iter->seq, t);
} else {
/*
* The cgid portion used to be "INO,GEN". Userland
@@ -1566,10 +1596,13 @@ static void blk_log_action(struct trace_iterator *iter, const char *act,
"%3d,%-3d %llx,%-llx %2s %3s ",
MAJOR(t->device), MINOR(t->device),
id & U32_MAX, id >> 32, act, rwbs);
+ blk_log_ioprio(&iter->seq, t);
}
- } else
+ } else {
trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ",
MAJOR(t->device), MINOR(t->device), act, rwbs);
+ blk_log_ioprio(&iter->seq, t);
+ }
}
static void blk_log_dump_pdu(struct trace_seq *s,
@@ -1762,7 +1795,8 @@ static enum print_line_t print_one_line(struct trace_iterator *iter,
bool has_cg;
t = te_blk_io_trace(iter->ent);
- what = (t->action & ((1 << BLK_TC_SHIFT) - 1)) & ~__BLK_TA_CGROUP;
+ what = (t->action & ((1 << BLK_TC_SHIFT) - 1)) &
+ ~(__BLK_TA_CGROUP | __BLK_TA_IOPRIO);
long_act = !!(tr->trace_flags & TRACE_ITER(VERBOSE));
log_action = classic ? &blk_log_action_classic : &blk_log_action;
has_cg = t->action & __BLK_TA_CGROUP;
@@ -1798,7 +1832,7 @@ static void blk_trace_synthesize_old_trace(struct trace_iterator *iter)
.time = iter->ts,
.sector = t->sector,
.bytes = t->bytes,
- .action = lower_32_bits(t->action),
+ .action = lower_32_bits(t->action) & ~__BLK_TA_IOPRIO,
.pid = t->pid,
.device = t->device,
.cpu = t->cpu,
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] block: add ioprio to the bio based tracepoints
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
` (3 preceding siblings ...)
2026-11-24 13:35 ` [PATCH 4/5] blktrace: decode ioprio on ftrace block tracer Johannes Thumshirn
@ 2026-11-24 13:35 ` Johannes Thumshirn
4 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 13:35 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: Christoph Hellwig, linux-block, Damien Le Moal, Hannes Reinecke,
Martin K. Petersen, Niklas Cassel, Shinichiro Kawasaki,
Chaitanya Kulkarni, Johannes Thumshirn
The request based block tracepoints already report the I/O priority
since commit aa6ff4eb7c10 ("block: Add ioprio to block_rq tracepoint").
Add it to block_bio_complete, the block_bio class (block_bio_backmerge,
block_bio_frontmerge, block_bio_queue and block_getrq), block_split,
block_bio_remap and block_rq_remap as well, so the I/O priority and with
it the CDL hint of an I/O can be followed through the whole block layer.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
include/trace/events/block.h | 50 +++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 9 deletions(-)
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 9c97a16850b9..5828ed5df872 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -373,6 +373,7 @@ TRACE_EVENT(block_bio_complete,
__field( dev_t, dev )
__field( sector_t, sector )
__field( unsigned, nr_sector )
+ __field( unsigned short, ioprio )
__field( int, error )
__array( char, rwbs, RWBS_LEN)
),
@@ -381,14 +382,20 @@ TRACE_EVENT(block_bio_complete,
__entry->dev = bio_dev(bio);
__entry->sector = bio->bi_iter.bi_sector;
__entry->nr_sector = bio_sectors(bio);
+ __entry->ioprio = bio->bi_ioprio;
__entry->error = blk_status_to_errno(bio->bi_status);
blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
),
- TP_printk("%d,%d %s %llu + %u [%d]",
+ TP_printk("%d,%d %s %llu + %u %s,%u,%u [%d]",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
(unsigned long long)__entry->sector,
- __entry->nr_sector, __entry->error)
+ __entry->nr_sector,
+ __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
+ IOPRIO_CLASS_STRINGS),
+ IOPRIO_PRIO_HINT(__entry->ioprio),
+ IOPRIO_PRIO_LEVEL(__entry->ioprio),
+ __entry->error)
);
DECLARE_EVENT_CLASS(block_bio,
@@ -401,6 +408,7 @@ DECLARE_EVENT_CLASS(block_bio,
__field( dev_t, dev )
__field( sector_t, sector )
__field( unsigned int, nr_sector )
+ __field( unsigned short, ioprio )
__array( char, rwbs, RWBS_LEN )
__array( char, comm, TASK_COMM_LEN )
),
@@ -409,14 +417,20 @@ DECLARE_EVENT_CLASS(block_bio,
__entry->dev = bio_dev(bio);
__entry->sector = bio->bi_iter.bi_sector;
__entry->nr_sector = bio_sectors(bio);
+ __entry->ioprio = bio->bi_ioprio;
blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
),
- TP_printk("%d,%d %s %llu + %u [%s]",
+ TP_printk("%d,%d %s %llu + %u %s,%u,%u [%s]",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
(unsigned long long)__entry->sector,
- __entry->nr_sector, __entry->comm)
+ __entry->nr_sector,
+ __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
+ IOPRIO_CLASS_STRINGS),
+ IOPRIO_PRIO_HINT(__entry->ioprio),
+ IOPRIO_PRIO_LEVEL(__entry->ioprio),
+ __entry->comm)
);
/**
@@ -554,6 +568,7 @@ TRACE_EVENT(block_split,
__field( dev_t, dev )
__field( sector_t, sector )
__field( sector_t, new_sector )
+ __field( unsigned short, ioprio )
__array( char, rwbs, RWBS_LEN )
__array( char, comm, TASK_COMM_LEN )
),
@@ -562,14 +577,19 @@ TRACE_EVENT(block_split,
__entry->dev = bio_dev(bio);
__entry->sector = bio->bi_iter.bi_sector;
__entry->new_sector = new_sector;
+ __entry->ioprio = bio->bi_ioprio;
blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
),
- TP_printk("%d,%d %s %llu / %llu [%s]",
+ TP_printk("%d,%d %s %llu / %llu %s,%u,%u [%s]",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
(unsigned long long)__entry->sector,
(unsigned long long)__entry->new_sector,
+ __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
+ IOPRIO_CLASS_STRINGS),
+ IOPRIO_PRIO_HINT(__entry->ioprio),
+ IOPRIO_PRIO_LEVEL(__entry->ioprio),
__entry->comm)
);
@@ -594,6 +614,7 @@ TRACE_EVENT(block_bio_remap,
__field( unsigned int, nr_sector )
__field( dev_t, old_dev )
__field( sector_t, old_sector )
+ __field( unsigned short, ioprio )
__array( char, rwbs, RWBS_LEN)
),
@@ -603,15 +624,20 @@ TRACE_EVENT(block_bio_remap,
__entry->nr_sector = bio_sectors(bio);
__entry->old_dev = dev;
__entry->old_sector = from;
+ __entry->ioprio = bio->bi_ioprio;
blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
),
- TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
+ TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %s,%u,%u",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
(unsigned long long)__entry->sector,
__entry->nr_sector,
MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
- (unsigned long long)__entry->old_sector)
+ (unsigned long long)__entry->old_sector,
+ __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
+ IOPRIO_CLASS_STRINGS),
+ IOPRIO_PRIO_HINT(__entry->ioprio),
+ IOPRIO_PRIO_LEVEL(__entry->ioprio))
);
/**
@@ -637,6 +663,7 @@ TRACE_EVENT(block_rq_remap,
__field( dev_t, old_dev )
__field( sector_t, old_sector )
__field( unsigned int, nr_bios )
+ __field( unsigned short, ioprio )
__array( char, rwbs, RWBS_LEN)
),
@@ -647,15 +674,20 @@ TRACE_EVENT(block_rq_remap,
__entry->old_dev = dev;
__entry->old_sector = from;
__entry->nr_bios = blk_rq_count_bios(rq);
+ __entry->ioprio = req_get_ioprio(rq);
blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
),
- TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
+ TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u %s,%u,%u",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
(unsigned long long)__entry->sector,
__entry->nr_sector,
MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
- (unsigned long long)__entry->old_sector, __entry->nr_bios)
+ (unsigned long long)__entry->old_sector, __entry->nr_bios,
+ __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
+ IOPRIO_CLASS_STRINGS),
+ IOPRIO_PRIO_HINT(__entry->ioprio),
+ IOPRIO_PRIO_LEVEL(__entry->ioprio))
);
/**
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2
2026-11-24 13:35 ` [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2 Johannes Thumshirn
@ 2026-11-25 4:58 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-11-25 4:58 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: axboe@kernel.dk, Christoph Hellwig, linux-block, Damien Le Moal,
Hannes Reinecke, Martin K. Petersen, Niklas Cassel,
Shinichiro Kawasaki, Chaitanya Kulkarni
On Tue, Nov 24, 2026 at 02:35:49PM +0100, Johannes Thumshirn wrote:
> Add the UAPI definitions for passing I/O priorities, and with them SCSI
> command duration limit (CDL) hints, to user space:
Before we start encoding this too hard we really need to fix how CDL
is used in the kernel. The whole idea of the user configures the
CDL descriptor and then the I/O issuers magically knows an I/O
priority maps to it is completely broken.
We need a way for the FS to know or even configure the CDL descriptor
and then use that.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-25 4:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:35 [PATCH 0/5] blktrace: add support for tracing I/O priorities Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 1/5] blktrace: add ioprio field to struct blk_io_trace2 Johannes Thumshirn
2026-11-25 4:58 ` Christoph Hellwig
2026-11-24 13:35 ` [PATCH 2/5] blktrace: pass ioprio to tracing data Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 3/5] blktrace: record I/O priorities if requested Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 4/5] blktrace: decode ioprio on ftrace block tracer Johannes Thumshirn
2026-11-24 13:35 ` [PATCH 5/5] block: add ioprio to the bio based tracepoints Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox