* [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing
@ 2025-10-29 3:34 Chaitanya Kulkarni
2025-11-03 6:30 ` Chaitanya Kulkarni
2025-11-03 15:31 ` Jens Axboe
0 siblings, 2 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-10-29 3:34 UTC (permalink / raw)
To: johannes.thumshirn
Cc: axboe, rostedt, mhiramat, mathieu.desnoyers, martin.petersen,
dlemoal, john.g.garry, ckulkarnilinux, linux-block,
linux-trace-kernel
Currently, REQ_OP_WRITE_ZEROES operations are not handled in the
blktrace infrastructure, resulting in incorrect or missing operation
labels in ftrace blktrace output. This manifests as write-zeroes
operations appearing with incorrect labels like "N" instead of a
proper "WZ" designation.
This patch adds complete support for REQ_OP_WRITE_ZEROES across the
blktrace infrastructure:
Add BLK_TC_WRITE_ZEROES trace category in blktrace_api.h and update
BLK_TC_END_V2 marker accordingly
Map REQ_OP_WRITE_ZEROES to BLK_TC_WRITE_ZEROES in __blk_add_trace()
to ensure proper trace event categorization
Update fill_rwbs() to generate "WZ" label for write-zeroes operations
in ftrace output, making them easily identifiable
Add "write-zeroes" string mapping in act_to_str array for debugfs
filter interface
Update blk_fill_rwbs() to handle REQ_OP_WRITE_ZEROES for block layer
event tracing
With this fix, write-zeroes operations are now correctly traced and
displayed.
===========================================================
BEFORE THIS PATCH
===========================================================
blkdiscard -z -o 0 -l 40960 /dev/nvme0n1
blkdiscard-3809 [030] ..... 1212.253701: block_bio_queue: 259,0 NS 0 + 80 [blkdiscard]
blkdiscard-3809 [030] ..... 1212.253703: block_getrq: 259,0 NS 0 + 80 [blkdiscard]
blkdiscard-3809 [030] ..... 1212.253704: block_io_start: 259,0 NS 40960 () 0 + 80 be,0,4 [blkdiscard]
blkdiscard-3809 [030] ..... 1212.253704: block_plug: [blkdiscard]
blkdiscard-3809 [030] ..... 1212.253706: block_unplug: [blkdiscard] 1
blkdiscard-3809 [030] ..... 1212.253706: block_rq_insert: 259,0 NS 40960 () 0 + 80 be,0,4 [blkdiscard]
kworker/30:1H-566 [030] ..... 1212.253726: block_rq_issue: 259,0 NS 40960 () 0 + 80 be,0,4 [kworker/30:1H]
<idle>-0 [030] d.h1. 1212.253957: block_rq_complete: 259,0 NS () 0 + 80 be,0,4 [0]
<idle>-0 [030] dNh1. 1212.253960: block_io_done: 259,0 NS 0 () 0 + 0 none,0,0 [swapper/30]
Trace Event Breakdown:
Event | Device | Op | Sector | Sectors | Byte Size | Calculation
block_bio_queue | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
block_getrq | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
block_io_start | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
block_rq_insert | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
block_rq_issue | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
block_rq_complete | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
block_io_done | 259,0 | NS | 0 | 0 | 0 | Completion (no data)
Total Bytes Transferred: Sectors: 80 Bytes: 80 × 512 = 40,960 bytes
===========================================================
AFTER THIS PATCH
===========================================================
blkdiscard -z -o 0 -l 40960 /dev/nvme0n1
blkdiscard-2477 [020] ..... 960.989131: block_bio_queue: 259,0 WZS 0 + 80 [blkdiscard]
blkdiscard-2477 [020] ..... 960.989134: block_getrq: 259,0 WZS 0 + 80 [blkdiscard]
blkdiscard-2477 [020] ..... 960.989135: block_io_start: 259,0 WZS 40960 () 0 + 80 be,0,4 [blkdiscard]
blkdiscard-2477 [020] ..... 960.989138: block_plug: [blkdiscard]
blkdiscard-2477 [020] ..... 960.989140: block_unplug: [blkdiscard] 1
blkdiscard-2477 [020] ..... 960.989141: block_rq_insert: 259,0 WZS 40960 () 0 + 80 be,0,4 [blkdiscard]
kworker/20:1H-736 [020] ..... 960.989166: block_rq_issue: 259,0 WZS 40960 () 0 + 80 be,0,4 [kworker/20:1H]
<idle>-0 [020] d.h1. 960.989476: block_rq_complete: 259,0 WZS () 0 + 80 be,0,4 [0]
<idle>-0 [020] dNh1. 960.989482: block_io_done: 259,0 WZS 0 () 0 + 0 none,0,0 [swapper/20]
Trace Event Breakdown:
Event | Device | Op | Sector | Sectors | Byte Size | Calculation
block_bio_queue | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
block_getrq | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
block_io_start | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
block_rq_insert | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
block_rq_issue | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
block_rq_complete | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
block_io_done | 259,0 | WZS | 0 | 0 | 0 | Completion (no data)
Total Bytes Transferred: Sectors: 80 Bytes: 80 × 512 = 40,960 bytes
Tested with ftrace blktrace on NVMe devices using blkdiscard with
the -z (write-zeroes) flag.
Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
---
include/uapi/linux/blktrace_api.h | 4 +++-
kernel/trace/blktrace.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
index 30f3d2589365..7c092d9f3aa4 100644
--- a/include/uapi/linux/blktrace_api.h
+++ b/include/uapi/linux/blktrace_api.h
@@ -35,7 +35,9 @@ enum blktrace_cat {
BLK_TC_ZONE_OPEN = 1ull << 20, /* zone open */
BLK_TC_ZONE_CLOSE = 1ull << 21, /* zone close */
- BLK_TC_END_V2 = 1ull << 21,
+ BLK_TC_WRITE_ZEROES = 1ull << 22, /* write-zeroes */
+
+ BLK_TC_END_V2 = 1ull << 22,
};
#define BLK_TC_SHIFT (16)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 4a37d9aa0481..1dd3b6a71649 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -360,6 +360,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
case REQ_OP_ZONE_CLOSE:
what |= BLK_TC_ACT(BLK_TC_ZONE_CLOSE);
break;
+ case REQ_OP_WRITE_ZEROES:
+ what |= BLK_TC_ACT(BLK_TC_WRITE_ZEROES);
+ break;
default:
break;
}
@@ -1414,7 +1417,10 @@ static void fill_rwbs(char *rwbs, const struct blk_io_trace2 *t)
if (tc & BLK_TC_DISCARD)
rwbs[i++] = 'D';
- else if (tc & BLK_TC_WRITE)
+ else if (tc & BLK_TC_WRITE_ZEROES) {
+ rwbs[i++] = 'W';
+ rwbs[i++] = 'Z';
+ } else if (tc & BLK_TC_WRITE)
rwbs[i++] = 'W';
else if (t->bytes)
rwbs[i++] = 'R';
@@ -1957,6 +1963,7 @@ static const struct {
{ BLK_TC_DISCARD, "discard" },
{ BLK_TC_DRV_DATA, "drv_data" },
{ BLK_TC_FUA, "fua" },
+ { BLK_TC_WRITE_ZEROES, "write-zeroes" },
};
static int blk_trace_str2mask(const char *str)
@@ -2170,6 +2177,10 @@ void blk_fill_rwbs(char *rwbs, blk_opf_t opf)
rwbs[i++] = 'Z';
rwbs[i++] = 'C';
break;
+ case REQ_OP_WRITE_ZEROES:
+ rwbs[i++] = 'W';
+ rwbs[i++] = 'Z';
+ break;
default:
rwbs[i++] = 'N';
}
--
2.40.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing
2025-10-29 3:34 [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing Chaitanya Kulkarni
@ 2025-11-03 6:30 ` Chaitanya Kulkarni
2025-11-03 8:59 ` Johannes Thumshirn
2025-11-03 15:31 ` Jens Axboe
1 sibling, 1 reply; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-11-03 6:30 UTC (permalink / raw)
To: Chaitanya Kulkarni, johannes.thumshirn@wdc.com
Cc: axboe@kernel.dk, rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, martin.petersen@oracle.com,
dlemoal@kernel.org, john.g.garry@oracle.com,
linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Johannes, gentle ping ...
-ck
On 10/28/25 20:34, Chaitanya Kulkarni wrote:
> Currently, REQ_OP_WRITE_ZEROES operations are not handled in the
> blktrace infrastructure, resulting in incorrect or missing operation
> labels in ftrace blktrace output. This manifests as write-zeroes
> operations appearing with incorrect labels like "N" instead of a
> proper "WZ" designation.
>
> This patch adds complete support for REQ_OP_WRITE_ZEROES across the
> blktrace infrastructure:
>
> Add BLK_TC_WRITE_ZEROES trace category in blktrace_api.h and update
> BLK_TC_END_V2 marker accordingly
> Map REQ_OP_WRITE_ZEROES to BLK_TC_WRITE_ZEROES in __blk_add_trace()
> to ensure proper trace event categorization
> Update fill_rwbs() to generate "WZ" label for write-zeroes operations
> in ftrace output, making them easily identifiable
> Add "write-zeroes" string mapping in act_to_str array for debugfs
> filter interface
> Update blk_fill_rwbs() to handle REQ_OP_WRITE_ZEROES for block layer
> event tracing
>
> With this fix, write-zeroes operations are now correctly traced and
> displayed.
>
> ===========================================================
> BEFORE THIS PATCH
> ===========================================================
> blkdiscard -z -o 0 -l 40960 /dev/nvme0n1
> blkdiscard-3809 [030] ..... 1212.253701: block_bio_queue: 259,0 NS 0 + 80 [blkdiscard]
> blkdiscard-3809 [030] ..... 1212.253703: block_getrq: 259,0 NS 0 + 80 [blkdiscard]
> blkdiscard-3809 [030] ..... 1212.253704: block_io_start: 259,0 NS 40960 () 0 + 80 be,0,4 [blkdiscard]
> blkdiscard-3809 [030] ..... 1212.253704: block_plug: [blkdiscard]
> blkdiscard-3809 [030] ..... 1212.253706: block_unplug: [blkdiscard] 1
> blkdiscard-3809 [030] ..... 1212.253706: block_rq_insert: 259,0 NS 40960 () 0 + 80 be,0,4 [blkdiscard]
> kworker/30:1H-566 [030] ..... 1212.253726: block_rq_issue: 259,0 NS 40960 () 0 + 80 be,0,4 [kworker/30:1H]
> <idle>-0 [030] d.h1. 1212.253957: block_rq_complete: 259,0 NS () 0 + 80 be,0,4 [0]
> <idle>-0 [030] dNh1. 1212.253960: block_io_done: 259,0 NS 0 () 0 + 0 none,0,0 [swapper/30]
>
> Trace Event Breakdown:
> Event | Device | Op | Sector | Sectors | Byte Size | Calculation
>
> block_bio_queue | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
> block_getrq | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
> block_io_start | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
> block_rq_insert | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
> block_rq_issue | 259,0 | NS | 0 | 80 | 40960 | Direct from trace
> block_rq_complete | 259,0 | NS | 0 | 80 | - | 80 × 512 = 40,960
> block_io_done | 259,0 | NS | 0 | 0 | 0 | Completion (no data)
>
> Total Bytes Transferred: Sectors: 80 Bytes: 80 × 512 = 40,960 bytes
>
> ===========================================================
> AFTER THIS PATCH
> ===========================================================
> blkdiscard -z -o 0 -l 40960 /dev/nvme0n1
>
> blkdiscard-2477 [020] ..... 960.989131: block_bio_queue: 259,0 WZS 0 + 80 [blkdiscard]
> blkdiscard-2477 [020] ..... 960.989134: block_getrq: 259,0 WZS 0 + 80 [blkdiscard]
> blkdiscard-2477 [020] ..... 960.989135: block_io_start: 259,0 WZS 40960 () 0 + 80 be,0,4 [blkdiscard]
> blkdiscard-2477 [020] ..... 960.989138: block_plug: [blkdiscard]
> blkdiscard-2477 [020] ..... 960.989140: block_unplug: [blkdiscard] 1
> blkdiscard-2477 [020] ..... 960.989141: block_rq_insert: 259,0 WZS 40960 () 0 + 80 be,0,4 [blkdiscard]
> kworker/20:1H-736 [020] ..... 960.989166: block_rq_issue: 259,0 WZS 40960 () 0 + 80 be,0,4 [kworker/20:1H]
> <idle>-0 [020] d.h1. 960.989476: block_rq_complete: 259,0 WZS () 0 + 80 be,0,4 [0]
> <idle>-0 [020] dNh1. 960.989482: block_io_done: 259,0 WZS 0 () 0 + 0 none,0,0 [swapper/20]
>
> Trace Event Breakdown:
> Event | Device | Op | Sector | Sectors | Byte Size | Calculation
>
> block_bio_queue | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
> block_getrq | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
> block_io_start | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
> block_rq_insert | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
> block_rq_issue | 259,0 | WZS | 0 | 80 | 40960 | Direct from trace
> block_rq_complete | 259,0 | WZS | 0 | 80 | - | 80 × 512 = 40,960
> block_io_done | 259,0 | WZS | 0 | 0 | 0 | Completion (no data)
>
> Total Bytes Transferred: Sectors: 80 Bytes: 80 × 512 = 40,960 bytes
>
> Tested with ftrace blktrace on NVMe devices using blkdiscard with
> the -z (write-zeroes) flag.
>
> Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
> ---
> include/uapi/linux/blktrace_api.h | 4 +++-
> kernel/trace/blktrace.c | 13 ++++++++++++-
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
> index 30f3d2589365..7c092d9f3aa4 100644
> --- a/include/uapi/linux/blktrace_api.h
> +++ b/include/uapi/linux/blktrace_api.h
> @@ -35,7 +35,9 @@ enum blktrace_cat {
> BLK_TC_ZONE_OPEN = 1ull << 20, /* zone open */
> BLK_TC_ZONE_CLOSE = 1ull << 21, /* zone close */
>
> - BLK_TC_END_V2 = 1ull << 21,
> + BLK_TC_WRITE_ZEROES = 1ull << 22, /* write-zeroes */
> +
> + BLK_TC_END_V2 = 1ull << 22,
> };
>
> #define BLK_TC_SHIFT (16)
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 4a37d9aa0481..1dd3b6a71649 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -360,6 +360,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
> case REQ_OP_ZONE_CLOSE:
> what |= BLK_TC_ACT(BLK_TC_ZONE_CLOSE);
> break;
> + case REQ_OP_WRITE_ZEROES:
> + what |= BLK_TC_ACT(BLK_TC_WRITE_ZEROES);
> + break;
> default:
> break;
> }
> @@ -1414,7 +1417,10 @@ static void fill_rwbs(char *rwbs, const struct blk_io_trace2 *t)
>
> if (tc & BLK_TC_DISCARD)
> rwbs[i++] = 'D';
> - else if (tc & BLK_TC_WRITE)
> + else if (tc & BLK_TC_WRITE_ZEROES) {
> + rwbs[i++] = 'W';
> + rwbs[i++] = 'Z';
> + } else if (tc & BLK_TC_WRITE)
> rwbs[i++] = 'W';
> else if (t->bytes)
> rwbs[i++] = 'R';
> @@ -1957,6 +1963,7 @@ static const struct {
> { BLK_TC_DISCARD, "discard" },
> { BLK_TC_DRV_DATA, "drv_data" },
> { BLK_TC_FUA, "fua" },
> + { BLK_TC_WRITE_ZEROES, "write-zeroes" },
> };
>
> static int blk_trace_str2mask(const char *str)
> @@ -2170,6 +2177,10 @@ void blk_fill_rwbs(char *rwbs, blk_opf_t opf)
> rwbs[i++] = 'Z';
> rwbs[i++] = 'C';
> break;
> + case REQ_OP_WRITE_ZEROES:
> + rwbs[i++] = 'W';
> + rwbs[i++] = 'Z';
> + break;
> default:
> rwbs[i++] = 'N';
> }
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing
2025-11-03 6:30 ` Chaitanya Kulkarni
@ 2025-11-03 8:59 ` Johannes Thumshirn
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2025-11-03 8:59 UTC (permalink / raw)
To: Chaitanya Kulkarni, Chaitanya Kulkarni
Cc: axboe@kernel.dk, rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, martin.petersen@oracle.com,
dlemoal@kernel.org, john.g.garry@oracle.com,
linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing
2025-10-29 3:34 [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing Chaitanya Kulkarni
2025-11-03 6:30 ` Chaitanya Kulkarni
@ 2025-11-03 15:31 ` Jens Axboe
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-11-03 15:31 UTC (permalink / raw)
To: johannes.thumshirn, Chaitanya Kulkarni
Cc: rostedt, mhiramat, mathieu.desnoyers, martin.petersen, dlemoal,
john.g.garry, linux-block, linux-trace-kernel
On Tue, 28 Oct 2025 20:34:23 -0700, Chaitanya Kulkarni wrote:
> Currently, REQ_OP_WRITE_ZEROES operations are not handled in the
> blktrace infrastructure, resulting in incorrect or missing operation
> labels in ftrace blktrace output. This manifests as write-zeroes
> operations appearing with incorrect labels like "N" instead of a
> proper "WZ" designation.
>
> This patch adds complete support for REQ_OP_WRITE_ZEROES across the
> blktrace infrastructure:
>
> [...]
Applied, thanks!
[1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing
commit: bc49af56eea866c34d21bf582f65b02fc8c06ec3
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-03 15:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 3:34 [PATCH 1/1] blktrace: add support for REQ_OP_WRITE_ZEROES tracing Chaitanya Kulkarni
2025-11-03 6:30 ` Chaitanya Kulkarni
2025-11-03 8:59 ` Johannes Thumshirn
2025-11-03 15:31 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).