* [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing
@ 2025-11-24 7:37 Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 01/20] blktrace: fix comment for struct blk_trace_setup: Johannes Thumshirn
` (20 more replies)
0 siblings, 21 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
[The original submission can be found here: https://lore.kernel.org/linux-btrace/20251015105658.527262-1-johannes.thumshirn@wdc.com]
This patch series extends the user-space blktrace tools to support the new
trace events for zoned block device commands introduced in the corresponding
kernel patch series.
The updates include:
- Introduction of a new ioctl requesting the v2 version of the trace
- Definitions for new zoned operation trace events.
- Parsing support in blkparse for these events.
- Display of the new events with clear labeling (e.g., ZO, ZA, ZR).
- Backward-compatible changes that do not affect existing functionality.
These changes complement the kernel patches and allow full visibility into
zone management commands in blktrace output, enabling better analysis and
debugging of zoned storage workloads.
The updated blktrace utility will first issue the BLKTRACESETUP2 ioctl and if
it fails transpartently fall back to BLKTRACESETUP allowing backwards
compatibility.
Feedback and testing on additional device types are appreciated.
Changes to v2:
- Sync with kernel changes
- Drop the Zone Management trace action
Changes to v1:
- Incorporated feedback from Chaitanya
- Add patch fixing a compiler warning at the beginning
Johannes Thumshirn (20):
blktrace: fix comment for struct blk_trace_setup:
blkparse: fix compiler warning
blktrace: add definitions for BLKTRACESETUP2
blktrace: change size of action to 64 bits
blktrace: add definitions for blk_io_trace2
blktrace: support protocol version 8
blkparse: pass magic to get_magic
blkparse: read 'magic' first
blkparse: factor out reading of a singe blk_io_trace event
blkparse: skip unsupported protocol versions
blkparse: make get_pdulen() take the pdu_len
blkiomon: read 'magic' first
blktrace: pass magic to CHECK_MAGIC macro
blktrace: pass magic to verify_trace
blktrace: rename trace_to_cpu to bit_trace_to_cpu
blkparse: use blk_io_trace2 internally
blkparse: natively parse blk_io_trace2
blkparse: parse zone (un)plug actions
blkparse: add zoned commands to fill_rwbs()
blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace
act_mask.c | 4 +-
blkiomon.c | 15 +-
blkparse.c | 446 +++++++++++++++++++++++++++++++++----------------
blkparse_fmt.c | 83 ++++++---
blkrawverify.c | 14 +-
blktrace.c | 40 ++++-
blktrace.h | 64 +++++--
blktrace_api.h | 58 ++++++-
8 files changed, 535 insertions(+), 189 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 01/20] blktrace: fix comment for struct blk_trace_setup:
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 02/20] blkparse: fix compiler warning Johannes Thumshirn
` (19 subsequent siblings)
20 siblings, 0 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn,
Chaitanya Kulkarni
Fix a comment misnaming the ioctl(2) passing struct blk_trace_setup.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace_api.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blktrace_api.h b/blktrace_api.h
index 8c760b8..172b4c2 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -127,7 +127,7 @@ struct blk_io_cgroup_payload {
};
/*
- * User setup structure passed with BLKSTARTTRACE
+ * User setup structure passed with BLKTRACESETUP
*/
struct blk_user_trace_setup {
char name[32]; /* output */
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 02/20] blkparse: fix compiler warning
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 01/20] blktrace: fix comment for struct blk_trace_setup: Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2 Johannes Thumshirn
` (18 subsequent siblings)
20 siblings, 0 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
GCC (15.2.1) warns on about the following string truncation in blkparse.c
gcc -o blkparse.o -c -Wall -O2 -g -W -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 blkparse.c
blkparse.c: In function ‘main’:
blkparse.c:2103:68: warning: ‘):’ directive output may be truncated writing 2 bytes into a region of size between 1 and 41 [-Wformat-truncation=]
2103 | snprintf(line, sizeof(line) - 1, "CPU%d (%s):",
| ^~
In function ‘show_device_and_cpu_stats’,
inlined from ‘show_stats’ at blkparse.c:3064:3,
inlined from ‘main’ at blkparse.c:3386:3:
blkparse.c:2103:25: note: ‘snprintf’ output between 9 and 49 bytes into a destination of size 47
2103 | snprintf(line, sizeof(line) - 1, "CPU%d (%s):",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2104 | j, get_dev_name(pdi, name, sizeof(name)));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -Wall -O2 -g -W -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -o blkparse blkparse.o blkparse_fmt.o rbtree.o act_mask.o
Add two more bytes to the string in order to mitigate the compiler warning.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blkparse.c b/blkparse.c
index d6aaa8b..3f4d827 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2023,7 +2023,7 @@ static void show_device_and_cpu_stats(void)
struct io_stats total, *ios;
unsigned long long rrate, wrate, msec;
int i, j, pci_events;
- char line[3 + 8/*cpu*/ + 2 + 32/*dev*/ + 3];
+ char line[3 + 8/*cpu*/ + 2 + 32/*dev*/ + 3 + 2];
char name[32];
double ratio;
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 01/20] blktrace: fix comment for struct blk_trace_setup: Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 02/20] blkparse: fix compiler warning Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 8:57 ` Damien Le Moal
2025-11-24 9:16 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 04/20] blktrace: change size of action to 64 bits Johannes Thumshirn
` (17 subsequent siblings)
20 siblings, 2 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Add definitions for a new BLKTRACESETUP2 ioctl(2).
This new ioctl(2) will request a new, updated structure layout from the
kernel which enhances the storage size of the 'action' field in order to
store additional tracepoints.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace_api.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/blktrace_api.h b/blktrace_api.h
index 172b4c2..ecffe6e 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -139,9 +139,25 @@ struct blk_user_trace_setup {
__u32 pid;
};
+/*
+ * User setup structure passed with BLKTRACESETUP2
+ */
+struct blk_user_trace_setup2 {
+ char name[64]; /* output */
+ __u64 act_mask; /* input */
+ __u32 buf_size; /* input */
+ __u32 buf_nr; /* input */
+ __u64 start_lba;
+ __u64 end_lba;
+ __u32 pid;
+ __u32 flags; /* currently unused */
+ __u64 reserved[11];
+};
+
#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
#define BLKTRACESTART _IO(0x12,116)
#define BLKTRACESTOP _IO(0x12,117)
#define BLKTRACETEARDOWN _IO(0x12,118)
+#define BLKTRACESETUP2 _IOWR(0x12, 142, struct blk_user_trace_setup2)
#endif
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 04/20] blktrace: change size of action to 64 bits
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (2 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2 Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2 Johannes Thumshirn
` (16 subsequent siblings)
20 siblings, 0 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
In order to add the zoned commands to blktrace's actions, the storage size
needs to be increased to 64bits.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
act_mask.c | 4 ++--
blkparse.c | 2 +-
blkparse_fmt.c | 15 ++++++++-------
blkrawverify.c | 10 +++++-----
blktrace.h | 2 +-
5 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/act_mask.c b/act_mask.c
index 8f1b8d7..510c7e0 100644
--- a/act_mask.c
+++ b/act_mask.c
@@ -42,7 +42,7 @@ int find_mask_map(char *string)
return -1;
}
-int valid_act_opt(int x)
+unsigned long long valid_act_opt(unsigned long long x)
{
- return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
+ return (1ull <= x) && (x < (1ull << BLK_TC_SHIFT));
}
diff --git a/blkparse.c b/blkparse.c
index 3f4d827..512a2d2 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -299,7 +299,7 @@ static int per_device_and_cpu_stats = 1;
static int track_ios;
static int ppi_hash_by_pid = 1;
static int verbose;
-static unsigned int act_mask = -1U;
+static unsigned long long act_mask = -1U;
static int stats_printed;
static int bin_output_msgs = 1;
int data_is_native = -1;
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index 9b83d1d..02c5a3c 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <ctype.h>
#include <time.h>
+#include <stdbool.h>
#include "blktrace.h"
@@ -52,13 +53,13 @@ int add_format_spec(char *option)
static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
{
- int w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
- int a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
- int s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
- int m = t->action & BLK_TC_ACT(BLK_TC_META);
- int d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
- int f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
- int u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+ bool w = !!(t->action & BLK_TC_ACT(BLK_TC_WRITE));
+ bool a = !!(t->action & BLK_TC_ACT(BLK_TC_AHEAD));
+ bool s = !!(t->action & BLK_TC_ACT(BLK_TC_SYNC));
+ bool m = !!(t->action & BLK_TC_ACT(BLK_TC_META));
+ bool d = !!(t->action & BLK_TC_ACT(BLK_TC_DISCARD));
+ bool f = !!(t->action & BLK_TC_ACT(BLK_TC_FLUSH));
+ bool u = !!(t->action & BLK_TC_ACT(BLK_TC_FUA));
int i = 0;
if (f)
diff --git a/blkrawverify.c b/blkrawverify.c
index ed5d258..9c5d595 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -55,7 +55,7 @@ static struct trace_info traces[] = {
#define N_TRACES (sizeof(traces) / sizeof(struct trace_info))
struct act_info {
- __u32 val;
+ __u64 val;
char *string;
};
@@ -80,12 +80,12 @@ static struct act_info acts[] = {
};
#define N_ACTS (sizeof(acts) / sizeof(struct act_info))
-static char *act_to_str(__u32 action)
+static char *act_to_str(__u64 action)
{
static char buf[1024];
unsigned int i;
- unsigned int act = action & 0xffff;
- unsigned int trace = (action >> BLK_TC_SHIFT) & 0xffff;
+ unsigned long long act = action & 0xffffffff;
+ unsigned long long trace = (action >> BLK_TC_SHIFT) & 0xffffffff;
if (act < N_ACTS) {
sprintf(buf, "%s ", acts[act].string);
@@ -97,7 +97,7 @@ static char *act_to_str(__u32 action)
}
}
else
- sprintf(buf, "Invalid action=%08x", action);
+ sprintf(buf, "Invalid action=%016llx", action);
return buf;
}
diff --git a/blktrace.h b/blktrace.h
index 944fc08..74dfb48 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -144,7 +144,7 @@ extern void set_all_format_specs(char *);
extern int add_format_spec(char *);
extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
unsigned long long, int, unsigned char *);
-extern int valid_act_opt(int);
+extern unsigned long long valid_act_opt(unsigned long long);
extern int find_mask_map(char *);
extern char *find_process_name(pid_t);
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (3 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 04/20] blktrace: change size of action to 64 bits Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:15 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8 Johannes Thumshirn
` (15 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Add 'struct blk_io_trace2' which represents the extended version of the
blktrace protocol.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace_api.h | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/blktrace_api.h b/blktrace_api.h
index ecffe6e..04e81de 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -24,11 +24,20 @@ enum {
BLK_TC_DRV_DATA = 1 << 14, /* binary driver data */
BLK_TC_FUA = 1 << 15, /* fua requests */
- BLK_TC_END = 1 << 15, /* we've run out of bits! */
+ 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,
};
#define BLK_TC_SHIFT (16)
-#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
+#define BLK_TC_ACT(act) ((__u64)(act) << BLK_TC_SHIFT)
/*
* Basic trace actions
@@ -51,6 +60,7 @@ enum {
__BLK_TA_REMAP, /* bio was remapped */
__BLK_TA_ABORT, /* request aborted */
__BLK_TA_DRV_DATA, /* binary driver data */
+ __BLK_TA_ZONE_MGMT, /* zone management command was issued */
__BLK_TA_CGROUP = 1 << 8,
};
@@ -85,12 +95,20 @@ enum blktrace_notify {
#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
#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
+#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))
+
#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_IO_TRACE_MAGIC 0x65617400
#define BLK_IO_TRACE_VERSION 0x07
+#define BLK_IO_TRACE2_VERSION 0x08
/*
* The trace itself
@@ -118,6 +136,22 @@ struct blk_io_trace_remap {
__u64 sector_from;
};
+struct blk_io_trace2 {
+ __u32 magic; /* MAGIC << 8 | BLK_IO_TRACE2_VERSION */
+ __u32 sequence; /* event number */
+ __u64 time; /* in nanoseconds */
+ __u64 sector; /* disk offset */
+ __u32 bytes; /* transfer length */
+ __u32 pid; /* who did it */
+ __u64 action; /* what happened */
+ __u32 device; /* device number */
+ __u32 cpu; /* on what cpu did it happen */
+ __u16 error; /* completion error */
+ __u16 pdu_len; /* length of data after this trace */
+ __u8 pad[12];
+ /* cgroup id will be stored here if exists */
+};
+
/*
* Payload with originating cgroup info
*/
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (4 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2 Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:00 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic Johannes Thumshirn
` (14 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Also support protocol version 8 in conjunction with protocol version 7.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace.h | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/blktrace.h b/blktrace.h
index 74dfb48..3305fa0 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -69,6 +69,7 @@ extern struct timespec abs_start_time;
#define CHECK_MAGIC(t) (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
#define SUPPORTED_VERSION (0x07)
+#define SUPPORTED_VERSION2 (0x08)
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define be16_to_cpu(x) __bswap_16(x)
@@ -90,13 +91,17 @@ extern struct timespec abs_start_time;
static inline int verify_trace(struct blk_io_trace *t)
{
+ u8 version;
+
if (!CHECK_MAGIC(t)) {
fprintf(stderr, "bad trace magic %x\n", t->magic);
return 1;
}
- if ((t->magic & 0xff) != SUPPORTED_VERSION) {
- fprintf(stderr, "unsupported trace version %x\n",
- t->magic & 0xff);
+
+ version = t->magic & 0xff;
+ if (version != SUPPORTED_VERSION &&
+ version != SUPPORTED_VERSION2) {
+ fprintf(stderr, "unsupported trace version %x\n", version);
return 1;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (5 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8 Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:01 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first Johannes Thumshirn
` (13 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Pass the magic value to get_magic() instead of the whole 'struct
blk_io_trace'.
This is a preparation for distinguishing between two different types of
blktrace protocol versions in blkparse.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 512a2d2..d58322c 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2420,12 +2420,12 @@ static inline __u16 get_pdulen(struct blk_io_trace *bit)
return __bswap_16(bit->pdu_len);
}
-static inline __u32 get_magic(struct blk_io_trace *bit)
+static inline __u32 get_magic(__u32 magic)
{
if (data_is_native)
- return bit->magic;
+ return magic;
- return __bswap_32(bit->magic);
+ return __bswap_32(magic);
}
static int read_events(int fd, int always_block, int *fdblock)
@@ -2458,7 +2458,7 @@ static int read_events(int fd, int always_block, int *fdblock)
if (data_is_native == -1 && check_data_endianness(bit->magic))
break;
- magic = get_magic(bit);
+ magic = get_magic(bit->magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
break;
@@ -2604,7 +2604,7 @@ static int ms_prime(struct ms_stream *msp)
if (data_is_native == -1 && check_data_endianness(bit->magic))
goto err;
- magic = get_magic(bit);
+ magic = get_magic(bit->magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
goto err;
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (6 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:03 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event Johannes Thumshirn
` (12 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Read the 'magic' portion of 'struct blk_io_trace' first when reading the
tracefile and only if all magic checks succeed, read the rest of the
trace.
This is a preparation of supporting multiple trace protocol versions.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 44 ++++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index d58322c..5645c31 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2438,14 +2438,13 @@ static int read_events(int fd, int always_block, int *fdblock)
struct trace *t;
int pdu_len, should_block, ret;
__u32 magic;
-
- bit = bit_alloc();
+ void *p;
should_block = !events || always_block;
- ret = read_data(fd, bit, sizeof(*bit), should_block, fdblock);
+ ret = read_data(fd, &magic, sizeof(magic), should_block,
+ fdblock);
if (ret) {
- bit_free(bit);
if (!events && ret < 0)
events = ret;
break;
@@ -2455,15 +2454,28 @@ static int read_events(int fd, int always_block, int *fdblock)
* look at first trace to check whether we need to convert
* data in the future
*/
- if (data_is_native == -1 && check_data_endianness(bit->magic))
+ if (data_is_native == -1 && check_data_endianness(magic))
break;
- magic = get_magic(bit->magic);
+ magic = get_magic(magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
break;
}
+ bit = bit_alloc();
+ bit->magic = magic;
+ p = (void *) ((u8 *)bit + sizeof(magic));
+
+ ret = read_data(fd, p, sizeof(*bit) - sizeof(magic),
+ should_block, fdblock);
+ if (ret) {
+ bit_free(bit);
+ if (!events && ret < 0)
+ events = ret;
+ break;
+ }
+
pdu_len = get_pdulen(bit);
if (pdu_len) {
void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
@@ -2596,20 +2608,30 @@ static int ms_prime(struct ms_stream *msp)
int ret, pdu_len, ndone = 0;
for (i = 0; !is_done() && pci->fd >= 0 && i < rb_batch; i++) {
- bit = bit_alloc();
- ret = read_data(pci->fd, bit, sizeof(*bit), 1, &pci->fdblock);
+ void *p;
+
+ ret = read_data(pci->fd, &magic, sizeof(magic), 1,
+ &pci->fdblock);
if (ret)
goto err;
- if (data_is_native == -1 && check_data_endianness(bit->magic))
+ if (data_is_native == -1 && check_data_endianness(magic))
goto err;
- magic = get_magic(bit->magic);
+ magic = get_magic(magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
goto err;
}
+ bit = bit_alloc();
+ bit->magic = magic;
+ p = (void *) ((u8 *)bit + sizeof(magic));
+
+ ret = read_data(pci->fd, p, sizeof(*bit) - sizeof(magic), 1,
+ &pci->fdblock);
+ if (ret)
+ goto err;
pdu_len = get_pdulen(bit);
if (pdu_len) {
@@ -2639,6 +2661,7 @@ static int ms_prime(struct ms_stream *msp)
handle_notify(bit);
output_binary(bit, sizeof(*bit) + bit->pdu_len);
bit_free(bit);
+ bit = NULL;
i -= 1;
continue;
@@ -2659,6 +2682,7 @@ static int ms_prime(struct ms_stream *msp)
}
ndone++;
+ bit = NULL;
}
return ndone;
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (7 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:04 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions Johannes Thumshirn
` (11 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Factor out reading a single blk_io_trace event. This de-duplicates code
and also prepares for expansion with new trace protocol versions.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 78 ++++++++++++++++++++++++------------------------------
1 file changed, 34 insertions(+), 44 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 5645c31..2e175b8 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2428,6 +2428,34 @@ static inline __u32 get_magic(__u32 magic)
return __bswap_32(magic);
}
+static int read_one_bit(int fd, struct blk_io_trace *bit, int block,
+ int *fdblock)
+{
+ int ret;
+ int pdu_len;
+ void *p = (void *) ((u8 *)bit + sizeof(__u32));
+
+ ret = read_data(fd, p, sizeof(*bit) - sizeof(__u32), block, fdblock);
+ if (ret)
+ return ret;
+
+ pdu_len = get_pdulen(bit);
+ if (pdu_len) {
+ void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
+
+ ret = read_data(fd, ptr + sizeof(*bit), pdu_len, 1, fdblock);
+ if (ret) {
+ free(ptr);
+ return ret;
+ }
+ bit = ptr;
+ }
+
+ trace_to_cpu(bit);
+
+ return 0;
+}
+
static int read_events(int fd, int always_block, int *fdblock)
{
struct per_dev_info *pdi = NULL;
@@ -2436,9 +2464,8 @@ static int read_events(int fd, int always_block, int *fdblock)
while (!is_done() && events < rb_batch) {
struct blk_io_trace *bit;
struct trace *t;
- int pdu_len, should_block, ret;
+ int should_block, ret;
__u32 magic;
- void *p;
should_block = !events || always_block;
@@ -2465,33 +2492,14 @@ static int read_events(int fd, int always_block, int *fdblock)
bit = bit_alloc();
bit->magic = magic;
- p = (void *) ((u8 *)bit + sizeof(magic));
- ret = read_data(fd, p, sizeof(*bit) - sizeof(magic),
- should_block, fdblock);
- if (ret) {
- bit_free(bit);
- if (!events && ret < 0)
- events = ret;
+ ret = read_one_bit(fd, bit, 1, fdblock);
+ if (ret)
break;
- }
-
- pdu_len = get_pdulen(bit);
- if (pdu_len) {
- void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
-
- if (read_data(fd, ptr + sizeof(*bit), pdu_len, 1, fdblock)) {
- bit_free(ptr);
- break;
- }
-
- bit = ptr;
- }
-
- trace_to_cpu(bit);
if (verify_trace(bit)) {
bit_free(bit);
+ bit = NULL;
continue;
}
@@ -2605,10 +2613,9 @@ static int ms_prime(struct ms_stream *msp)
struct per_dev_info *pdi = msp->pdi;
struct per_cpu_info *pci = get_cpu_info(pdi, msp->cpu);
struct blk_io_trace *bit = NULL;
- int ret, pdu_len, ndone = 0;
+ int ret, ndone = 0;
for (i = 0; !is_done() && pci->fd >= 0 && i < rb_batch; i++) {
- void *p;
ret = read_data(pci->fd, &magic, sizeof(magic), 1,
&pci->fdblock);
@@ -2626,28 +2633,11 @@ static int ms_prime(struct ms_stream *msp)
}
bit = bit_alloc();
bit->magic = magic;
- p = (void *) ((u8 *)bit + sizeof(magic));
- ret = read_data(pci->fd, p, sizeof(*bit) - sizeof(magic), 1,
- &pci->fdblock);
+ ret = read_one_bit(pci->fd, bit, 1, &pci->fdblock);
if (ret)
goto err;
- pdu_len = get_pdulen(bit);
- if (pdu_len) {
- void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
- ret = read_data(pci->fd, ptr + sizeof(*bit), pdu_len,
- 1, &pci->fdblock);
- if (ret) {
- free(ptr);
- bit = NULL;
- goto err;
- }
-
- bit = ptr;
- }
-
- trace_to_cpu(bit);
if (verify_trace(bit))
goto err;
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (8 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:05 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len Johannes Thumshirn
` (10 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Skip unsupported protocol versions for now.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 136 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 76 insertions(+), 60 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 2e175b8..163da73 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2462,10 +2462,10 @@ static int read_events(int fd, int always_block, int *fdblock)
unsigned int events = 0;
while (!is_done() && events < rb_batch) {
- struct blk_io_trace *bit;
struct trace *t;
int should_block, ret;
__u32 magic;
+ u8 version;
should_block = !events || always_block;
@@ -2489,42 +2489,50 @@ static int read_events(int fd, int always_block, int *fdblock)
fprintf(stderr, "Bad magic %x\n", magic);
break;
}
+ version = magic & 0xff;
+ if (version == SUPPORTED_VERSION) {
+ struct blk_io_trace *bit;
+ bit = bit_alloc();
+ bit->magic = magic;
- bit = bit_alloc();
- bit->magic = magic;
+ ret = read_one_bit(fd, bit, 1, fdblock);
+ if (ret)
+ break;
- ret = read_one_bit(fd, bit, 1, fdblock);
- if (ret)
- break;
+ /*
+ * not a real trace, so grab and handle it here
+ */
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ continue;
+ }
- if (verify_trace(bit)) {
- bit_free(bit);
- bit = NULL;
- continue;
- }
+ if (verify_trace(bit)) {
+ bit_free(bit);
+ bit = NULL;
+ continue;
+ }
- /*
- * not a real trace, so grab and handle it here
- */
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
- handle_notify(bit);
- output_binary(bit, sizeof(*bit) + bit->pdu_len);
- continue;
- }
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+ t->read_sequence = read_sequence;
- t = t_alloc();
- memset(t, 0, sizeof(*t));
- t->bit = bit;
- t->read_sequence = read_sequence;
+ t->next = trace_list;
+ trace_list = t;
- t->next = trace_list;
- trace_list = t;
+ if (!pdi || pdi->dev != bit->device)
+ pdi = get_dev_info(bit->device);
- if (!pdi || pdi->dev != bit->device)
- pdi = get_dev_info(bit->device);
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+ } else {
+ fprintf(stderr, "unsupported version %d\n", version);
+ continue;
+ }
- if (bit->time > pdi->last_read_time)
- pdi->last_read_time = bit->time;
events++;
}
@@ -2616,6 +2624,7 @@ static int ms_prime(struct ms_stream *msp)
int ret, ndone = 0;
for (i = 0; !is_done() && pci->fd >= 0 && i < rb_batch; i++) {
+ u8 version;
ret = read_data(pci->fd, &magic, sizeof(magic), 1,
&pci->fdblock);
@@ -2631,46 +2640,53 @@ static int ms_prime(struct ms_stream *msp)
goto err;
}
- bit = bit_alloc();
- bit->magic = magic;
+ version = magic & 0xff;
+ if (version == SUPPORTED_VERSION) {
+ bit = bit_alloc();
+ bit->magic = magic;
- ret = read_one_bit(pci->fd, bit, 1, &pci->fdblock);
- if (ret)
- goto err;
+ ret = read_one_bit(pci->fd, bit, 1, &pci->fdblock);
+ if (ret)
+ goto err;
- if (verify_trace(bit))
- goto err;
+ if (verify_trace(bit))
+ goto err;
- if (bit->cpu != pci->cpu) {
- fprintf(stderr, "cpu %d trace info has error cpu %d\n",
- pci->cpu, bit->cpu);
- continue;
- }
+ if (bit->cpu != pci->cpu) {
+ fprintf(stderr,
+ "cpu %d trace info has error cpu %d\n",
+ pci->cpu, bit->cpu);
+ continue;
+ }
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
- handle_notify(bit);
- output_binary(bit, sizeof(*bit) + bit->pdu_len);
- bit_free(bit);
- bit = NULL;
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ bit_free(bit);
+ bit = NULL;
- i -= 1;
- continue;
- }
+ i -= 1;
+ continue;
+ }
- if (bit->time > pdi->last_read_time)
- pdi->last_read_time = bit->time;
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
- t = t_alloc();
- memset(t, 0, sizeof(*t));
- t->bit = bit;
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
- if (msp->first == NULL)
- msp->first = msp->last = t;
- else {
- msp->last->next = t;
- msp->last = t;
+ if (msp->first == NULL)
+ msp->first = msp->last = t;
+ else {
+ msp->last->next = t;
+ msp->last = t;
+ }
+ } else {
+ fprintf(stderr, "unsupported version %d\n", version);
+ continue;
}
-
ndone++;
bit = NULL;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (9 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:06 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first Johannes Thumshirn
` (9 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Directly pass in the pdu_len into get_pdulen() and only care about the
byte swapping in get_pdulen().
This enables us to use the function for different versions of the
protocol.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 163da73..0402e81 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2412,12 +2412,12 @@ static int read_data(int fd, void *buffer, int bytes, int block, int *fdblock)
return 0;
}
-static inline __u16 get_pdulen(struct blk_io_trace *bit)
+static inline __u16 get_pdulen(__u16 pdu_len)
{
if (data_is_native)
- return bit->pdu_len;
+ return pdu_len;
- return __bswap_16(bit->pdu_len);
+ return __bswap_16(pdu_len);
}
static inline __u32 get_magic(__u32 magic)
@@ -2439,7 +2439,7 @@ static int read_one_bit(int fd, struct blk_io_trace *bit, int block,
if (ret)
return ret;
- pdu_len = get_pdulen(bit);
+ pdu_len = get_pdulen(bit->pdu_len);
if (pdu_len) {
void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (10 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:06 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro Johannes Thumshirn
` (8 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Similar to blkparse, read the 'magic' portion of 'struct blk_io_trace'
first when reading the trace.
This is a preparation of supporting multiple trace protocol versions.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkiomon.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/blkiomon.c b/blkiomon.c
index f8b0c9d..05f2d00 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -460,19 +460,28 @@ static int blkiomon_do_fifo(void)
bit = &t->bit;
while (up) {
+ __u32 magic;
+
+ if (fread(&magic, sizeof(magic), 1, ifp) != 1) {
+ if (!feof(ifp))
+ fprintf(stderr,
+ "blkiomon: could not read trace");
+ break;
+ }
if (fread(bit, sizeof(*bit), 1, ifp) != 1) {
if (!feof(ifp))
fprintf(stderr,
"blkiomon: could not read trace");
break;
}
+ bit->magic = magic;
if (ferror(ifp)) {
clearerr(ifp);
fprintf(stderr, "blkiomon: error while reading trace");
break;
}
- if (data_is_native == -1 && check_data_endianness(bit->magic)) {
+ if (data_is_native == -1 && check_data_endianness(magic)) {
fprintf(stderr, "blkiomon: endianess problem\n");
break;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (11 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:07 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace Johannes Thumshirn
` (7 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Pass only the magic number itself to the CHECK_MAGIC() macro.
This enables support for multiple versions.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkrawverify.c | 2 +-
blktrace.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/blkrawverify.c b/blkrawverify.c
index 9c5d595..cc5b06e 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -183,7 +183,7 @@ static int process(FILE **fp, char *devname, char *file, unsigned int cpu)
trace_to_cpu(bit);
- if (!CHECK_MAGIC(bit)) {
+ if (!CHECK_MAGIC(bit->magic)) {
INC_BAD("bad trace");
continue;
}
diff --git a/blktrace.h b/blktrace.h
index 3305fa0..81a5b51 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -67,7 +67,7 @@ extern FILE *ofp;
extern int data_is_native;
extern struct timespec abs_start_time;
-#define CHECK_MAGIC(t) (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
+#define CHECK_MAGIC(magic) (((magic) & 0xffffff00) == BLK_IO_TRACE_MAGIC)
#define SUPPORTED_VERSION (0x07)
#define SUPPORTED_VERSION2 (0x08)
@@ -93,7 +93,7 @@ static inline int verify_trace(struct blk_io_trace *t)
{
u8 version;
- if (!CHECK_MAGIC(t)) {
+ if (!CHECK_MAGIC(t->magic)) {
fprintf(stderr, "bad trace magic %x\n", t->magic);
return 1;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (12 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:07 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu Johannes Thumshirn
` (6 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Pass magic to verify_trace(), this will enable verification of multiple
supported versions.
Singed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkiomon.c | 2 +-
blkparse.c | 4 ++--
blktrace.h | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/blkiomon.c b/blkiomon.c
index 05f2d00..373947e 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -488,7 +488,7 @@ static int blkiomon_do_fifo(void)
/* endianess */
trace_to_cpu(bit);
- if (verify_trace(bit)) {
+ if (verify_trace(bit->magic)) {
fprintf(stderr, "blkiomon: bad trace\n");
break;
}
diff --git a/blkparse.c b/blkparse.c
index 0402e81..9065330 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2509,7 +2509,7 @@ static int read_events(int fd, int always_block, int *fdblock)
continue;
}
- if (verify_trace(bit)) {
+ if (verify_trace(bit->magic)) {
bit_free(bit);
bit = NULL;
continue;
@@ -2649,7 +2649,7 @@ static int ms_prime(struct ms_stream *msp)
if (ret)
goto err;
- if (verify_trace(bit))
+ if (verify_trace(bit->magic))
goto err;
if (bit->cpu != pci->cpu) {
diff --git a/blktrace.h b/blktrace.h
index 81a5b51..68c67f2 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -89,16 +89,16 @@ extern struct timespec abs_start_time;
#error "Bad arch"
#endif
-static inline int verify_trace(struct blk_io_trace *t)
+static inline int verify_trace(__u32 magic)
{
u8 version;
- if (!CHECK_MAGIC(t->magic)) {
- fprintf(stderr, "bad trace magic %x\n", t->magic);
+ if (!CHECK_MAGIC(magic)) {
+ fprintf(stderr, "bad trace magic %x\n", magic);
return 1;
}
- version = t->magic & 0xff;
+ version = magic & 0xff;
if (version != SUPPORTED_VERSION &&
version != SUPPORTED_VERSION2) {
fprintf(stderr, "unsupported trace version %x\n", version);
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (13 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:08 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally Johannes Thumshirn
` (5 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkiomon.c | 2 +-
blkparse.c | 2 +-
blkrawverify.c | 2 +-
blktrace.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/blkiomon.c b/blkiomon.c
index 373947e..9defa2c 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -487,7 +487,7 @@ static int blkiomon_do_fifo(void)
}
/* endianess */
- trace_to_cpu(bit);
+ bit_trace_to_cpu(bit);
if (verify_trace(bit->magic)) {
fprintf(stderr, "blkiomon: bad trace\n");
break;
diff --git a/blkparse.c b/blkparse.c
index 9065330..6396611 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2451,7 +2451,7 @@ static int read_one_bit(int fd, struct blk_io_trace *bit, int block,
bit = ptr;
}
- trace_to_cpu(bit);
+ bit_trace_to_cpu(bit);
return 0;
}
diff --git a/blkrawverify.c b/blkrawverify.c
index cc5b06e..8e863cb 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -181,7 +181,7 @@ static int process(FILE **fp, char *devname, char *file, unsigned int cpu)
if (data_is_native == -1)
check_data_endianness(bit->magic);
- trace_to_cpu(bit);
+ bit_trace_to_cpu(bit);
if (!CHECK_MAGIC(bit->magic)) {
INC_BAD("bad trace");
diff --git a/blktrace.h b/blktrace.h
index 68c67f2..08ac28b 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -108,7 +108,7 @@ static inline int verify_trace(__u32 magic)
return 0;
}
-static inline void trace_to_cpu(struct blk_io_trace *t)
+static inline void bit_trace_to_cpu(struct blk_io_trace *t)
{
if (data_is_native)
return;
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (14 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:10 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2 Johannes Thumshirn
` (4 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Use 'struct blk_io_trace2' as internal representation for a captured
blktrace.
This implies the conversion of 'struct blk_io_trace' into 'struct
blk_io_trace2' when reading the trace from the binary file.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 131 +++++++++++++++++++++++++++----------------------
blkparse_fmt.c | 16 +++---
blktrace.h | 23 ++++++++-
3 files changed, 103 insertions(+), 67 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 6396611..7100009 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -243,7 +243,7 @@ static struct option l_opts[] = {
* for sorting the displayed output
*/
struct trace {
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
struct rb_node rb_node;
struct trace *next;
unsigned long read_sequence;
@@ -257,7 +257,7 @@ static struct trace *trace_list;
/*
* allocation cache
*/
-static struct blk_io_trace *bit_alloc_list;
+static struct blk_io_trace2 *bit_alloc_list;
static struct trace *t_alloc_list;
/*
@@ -332,7 +332,7 @@ static int have_drv_data = 0;
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
-static void io_warn_unless(struct blk_io_trace *t, int condition,
+static void io_warn_unless(struct blk_io_trace2 *t, int condition,
const char *fmt, ...)
{
va_list ap;
@@ -613,7 +613,7 @@ static struct process_pid_map *add_ppm_hash(pid_t pid, const char *name)
return ppm;
}
-static void handle_notify(struct blk_io_trace *bit)
+static void handle_notify(struct blk_io_trace2 *bit)
{
void *payload = (caddr_t) bit + sizeof(*bit);
__u32 two32[2];
@@ -802,25 +802,25 @@ static inline struct trace *t_alloc(void)
return malloc(sizeof(*t));
}
-static inline void bit_free(struct blk_io_trace *bit)
+static inline void bit_free(struct blk_io_trace2 *bit)
{
if (bit_alloc_cache < 1024 && !bit->pdu_len) {
/*
* abuse a 64-bit field for a next pointer for the free item
*/
bit->time = (__u64) (unsigned long) bit_alloc_list;
- bit_alloc_list = (struct blk_io_trace *) bit;
+ bit_alloc_list = (struct blk_io_trace2 *) bit;
bit_alloc_cache++;
} else
free(bit);
}
-static inline struct blk_io_trace *bit_alloc(void)
+static inline struct blk_io_trace2 *bit_alloc(void)
{
- struct blk_io_trace *bit = bit_alloc_list;
+ struct blk_io_trace2 *bit = bit_alloc_list;
if (bit) {
- bit_alloc_list = (struct blk_io_trace *) (unsigned long) \
+ bit_alloc_list = (struct blk_io_trace2 *) (unsigned long) \
bit->time;
bit_alloc_cache--;
return bit;
@@ -1041,7 +1041,7 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
}
static void log_track_frontmerge(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
struct io_track *iot;
@@ -1062,7 +1062,7 @@ static void log_track_frontmerge(struct per_dev_info *pdi,
track_rb_insert(pdi, iot);
}
-static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
struct io_track_req *req;
@@ -1081,7 +1081,7 @@ static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
* for md/dm setups, the interesting cycle is Q -> C. So track queueing
* time here, as dispatch time
*/
-static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
struct io_track_req *req;
@@ -1096,7 +1096,7 @@ static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
req->dispatch_time = t->time;
}
-static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot, *split;
@@ -1118,7 +1118,7 @@ static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
* return time between rq allocation and insertion
*/
static unsigned long long log_track_insert(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed;
struct io_track *iot;
@@ -1153,7 +1153,7 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
* return time between queue and issue
*/
static unsigned long long log_track_issue(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed = -1ULL;
struct io_track *iot;
@@ -1191,7 +1191,7 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
return elapsed;
}
-static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
__u64 start_sector;
@@ -1214,7 +1214,7 @@ static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *t)
* return time between dispatch and complete
*/
static unsigned long long log_track_complete(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed = -1ULL;
struct io_track *iot, *next;
@@ -1288,7 +1288,7 @@ static char *get_dev_name(struct per_dev_info *pdi, char *buffer, int size)
return buffer;
}
-static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit)
+static void check_time(struct per_dev_info *pdi, struct blk_io_trace2 *bit)
{
unsigned long long this = bit->time;
unsigned long long last = pdi->last_reported_time;
@@ -1297,7 +1297,7 @@ static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit)
pdi->last_reported_time = this;
}
-static inline void __account_m(struct io_stats *ios, struct blk_io_trace *t,
+static inline void __account_m(struct io_stats *ios, struct blk_io_trace2 *t,
int rw)
{
if (rw) {
@@ -1311,7 +1311,7 @@ static inline void __account_m(struct io_stats *ios, struct blk_io_trace *t,
}
}
-static inline void account_m(struct blk_io_trace *t, struct per_cpu_info *pci,
+static inline void account_m(struct blk_io_trace2 *t, struct per_cpu_info *pci,
int rw)
{
__account_m(&pci->io_stats, t, rw);
@@ -1324,7 +1324,7 @@ static inline void account_m(struct blk_io_trace *t, struct per_cpu_info *pci,
}
static inline void __account_pc_queue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->qwrites_pc++;
@@ -1337,7 +1337,7 @@ static inline void __account_pc_queue(struct io_stats *ios,
}
}
-static inline void account_pc_queue(struct blk_io_trace *t,
+static inline void account_pc_queue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_queue(&pci->io_stats, t, rw);
@@ -1363,7 +1363,7 @@ static inline void __account_pc_issue(struct io_stats *ios, int rw,
}
}
-static inline void account_pc_issue(struct blk_io_trace *t,
+static inline void account_pc_issue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_issue(&pci->io_stats, rw, t->bytes);
@@ -1376,7 +1376,7 @@ static inline void account_pc_issue(struct blk_io_trace *t,
}
static inline void __account_pc_requeue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->wrqueue_pc++;
@@ -1389,7 +1389,7 @@ static inline void __account_pc_requeue(struct io_stats *ios,
}
}
-static inline void account_pc_requeue(struct blk_io_trace *t,
+static inline void account_pc_requeue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_requeue(&pci->io_stats, t, rw);
@@ -1409,7 +1409,7 @@ static inline void __account_pc_c(struct io_stats *ios, int rw)
ios->creads_pc++;
}
-static inline void account_pc_c(struct blk_io_trace *t,
+static inline void account_pc_c(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_c(&pci->io_stats, rw);
@@ -1421,7 +1421,7 @@ static inline void account_pc_c(struct blk_io_trace *t,
}
}
-static inline void __account_queue(struct io_stats *ios, struct blk_io_trace *t,
+static inline void __account_queue(struct io_stats *ios, struct blk_io_trace2 *t,
int rw)
{
if (rw) {
@@ -1435,7 +1435,7 @@ static inline void __account_queue(struct io_stats *ios, struct blk_io_trace *t,
}
}
-static inline void account_queue(struct blk_io_trace *t,
+static inline void account_queue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_queue(&pci->io_stats, t, rw);
@@ -1460,7 +1460,7 @@ static inline void __account_c(struct io_stats *ios, int rw, int bytes)
}
}
-static inline void account_c(struct blk_io_trace *t, struct per_cpu_info *pci,
+static inline void account_c(struct blk_io_trace2 *t, struct per_cpu_info *pci,
int rw, int bytes)
{
__account_c(&pci->io_stats, rw, bytes);
@@ -1486,7 +1486,7 @@ static inline void __account_issue(struct io_stats *ios, int rw,
}
}
-static inline void account_issue(struct blk_io_trace *t,
+static inline void account_issue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_issue(&pci->io_stats, rw, t->bytes);
@@ -1506,7 +1506,7 @@ static inline void __account_unplug(struct io_stats *ios, int timer)
ios->io_unplugs++;
}
-static inline void account_unplug(struct blk_io_trace *t,
+static inline void account_unplug(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int timer)
{
__account_unplug(&pci->io_stats, timer);
@@ -1519,7 +1519,7 @@ static inline void account_unplug(struct blk_io_trace *t,
}
static inline void __account_requeue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->wrqueue++;
@@ -1532,7 +1532,7 @@ static inline void __account_requeue(struct io_stats *ios,
}
}
-static inline void account_requeue(struct blk_io_trace *t,
+static inline void account_requeue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_requeue(&pci->io_stats, t, rw);
@@ -1545,31 +1545,31 @@ static inline void account_requeue(struct blk_io_trace *t,
}
static void log_complete(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_complete(pdi, t), 0, NULL);
}
static void log_insert(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_insert(pdi, t), 0, NULL);
}
-static void log_queue(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_queue(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1, 0, NULL);
}
static void log_issue(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_issue(pdi, t), 0, NULL);
}
static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
if (act[0] == 'F')
log_track_frontmerge(pdi, t);
@@ -1577,38 +1577,38 @@ static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci,
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_action(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_action(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_generic(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_generic(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_split(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_split(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_pc(struct per_cpu_info *pci, struct blk_io_trace *t, char *act)
+static void log_pc(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act)
{
unsigned char *buf = (unsigned char *) t + sizeof(*t);
process_fmt(act, pci, t, -1ULL, t->pdu_len, buf);
}
-static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi,
+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;
@@ -1657,7 +1657,7 @@ static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi,
}
}
-static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
+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;
@@ -1737,12 +1737,12 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
/* dump to binary file only */
break;
default:
- fprintf(stderr, "Bad fs action %x\n", t->action);
+ fprintf(stderr, "Bad fs action %llx\n", t->action);
break;
}
}
-static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
+static void dump_trace(struct blk_io_trace2 *t, struct per_cpu_info *pci,
struct per_dev_info *pdi)
{
if (text_output) {
@@ -2162,7 +2162,7 @@ static void find_genesis(void)
}
}
-static inline int check_stopwatch(struct blk_io_trace *bit)
+static inline int check_stopwatch(struct blk_io_trace2 *bit)
{
if (bit->time < stopwatch_end &&
bit->time >= stopwatch_start)
@@ -2185,7 +2185,7 @@ static int sort_entries(unsigned long long *youngest)
*youngest = 0;
while ((t = trace_list) != NULL) {
- struct blk_io_trace *bit = t->bit;
+ struct blk_io_trace2 *bit = t->bit;
trace_list = t->next;
@@ -2264,7 +2264,7 @@ static int check_cpu_map(struct per_dev_info *pdi)
static int check_sequence(struct per_dev_info *pdi, struct trace *t, int force)
{
- struct blk_io_trace *bit = t->bit;
+ struct blk_io_trace2 *bit = t->bit;
unsigned long expected_sequence;
struct per_cpu_info *pci;
struct trace *__t;
@@ -2315,7 +2315,7 @@ static void show_entries_rb(int force)
{
struct per_dev_info *pdi = NULL;
struct per_cpu_info *pci = NULL;
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
struct rb_node *n;
struct trace *t;
@@ -2428,12 +2428,22 @@ static inline __u32 get_magic(__u32 magic)
return __bswap_32(magic);
}
-static int read_one_bit(int fd, struct blk_io_trace *bit, int block,
+static int read_one_bit(int fd, struct blk_io_trace2 **bit2, int block,
int *fdblock)
{
+ struct blk_io_trace2 *new = *bit2;
+ struct blk_io_trace *bit;
int ret;
int pdu_len;
- void *p = (void *) ((u8 *)bit + sizeof(__u32));
+ void *p;
+
+ bit = malloc(sizeof(*bit));
+ if (!bit)
+ return -1;
+
+ bit->magic = new->magic;
+
+ p = (void *) ((u8 *)bit + sizeof(__u32));
ret = read_data(fd, p, sizeof(*bit) - sizeof(__u32), block, fdblock);
if (ret)
@@ -2449,9 +2459,14 @@ static int read_one_bit(int fd, struct blk_io_trace *bit, int block,
return ret;
}
bit = ptr;
+
+ new = realloc(*bit2, sizeof(struct blk_io_trace2) + pdu_len);
}
bit_trace_to_cpu(bit);
+ bit_to_bit2(bit, new);
+ free(bit);
+ *bit2 = new;
return 0;
}
@@ -2491,11 +2506,11 @@ static int read_events(int fd, int always_block, int *fdblock)
}
version = magic & 0xff;
if (version == SUPPORTED_VERSION) {
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
bit = bit_alloc();
bit->magic = magic;
- ret = read_one_bit(fd, bit, 1, fdblock);
+ ret = read_one_bit(fd, &bit, 1, fdblock);
if (ret)
break;
@@ -2620,7 +2635,7 @@ static int ms_prime(struct ms_stream *msp)
struct trace *t;
struct per_dev_info *pdi = msp->pdi;
struct per_cpu_info *pci = get_cpu_info(pdi, msp->cpu);
- struct blk_io_trace *bit = NULL;
+ struct blk_io_trace2 *bit = NULL;
int ret, ndone = 0;
for (i = 0; !is_done() && pci->fd >= 0 && i < rb_batch; i++) {
@@ -2645,7 +2660,7 @@ static int ms_prime(struct ms_stream *msp)
bit = bit_alloc();
bit->magic = magic;
- ret = read_one_bit(pci->fd, bit, 1, &pci->fdblock);
+ ret = read_one_bit(pci->fd, &bit, 1, &pci->fdblock);
if (ret)
goto err;
@@ -2767,7 +2782,7 @@ static int handle(struct ms_stream *msp)
struct trace *t;
struct per_dev_info *pdi;
struct per_cpu_info *pci;
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
t = ms_peek(msp);
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index 02c5a3c..f93addb 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -51,7 +51,7 @@ int add_format_spec(char *option)
return 0;
}
-static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
+static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
{
bool w = !!(t->action & BLK_TC_ACT(BLK_TC_WRITE));
bool a = !!(t->action & BLK_TC_ACT(BLK_TC_AHEAD));
@@ -146,16 +146,16 @@ static char *dump_pdu(unsigned char *pdu_buf, int pdu_len)
return p;
}
-#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace)))
+#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace2)))
-static unsigned int get_pdu_int(struct blk_io_trace *t)
+static unsigned int get_pdu_int(struct blk_io_trace2 *t)
{
__u64 *val = pdu_start(t);
return be64_to_cpu(*val);
}
-static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_remap *r)
+static void get_pdu_remap(struct blk_io_trace2 *t, struct blk_io_trace_remap *r)
{
struct blk_io_trace_remap *__r = pdu_start(t);
__u64 sector_from = __r->sector_from;
@@ -166,7 +166,7 @@ static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_remap *r)
}
static void print_field(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf, char field,
int minus, int has_w, int width)
{
@@ -275,7 +275,7 @@ static void print_field(char *act, struct per_cpu_info *pci,
}
static char *parse_field(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf,
char *primary_format)
{
@@ -302,7 +302,7 @@ static char *parse_field(char *act, struct per_cpu_info *pci,
}
static void process_default(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf)
{
struct blk_io_trace_remap r = { .device_from = 0, };
@@ -436,7 +436,7 @@ static void process_default(char *act, struct per_cpu_info *pci,
}
-void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace *t,
+void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace2 *t,
unsigned long long elapsed, int pdu_len,
unsigned char *pdu_buf)
{
diff --git a/blktrace.h b/blktrace.h
index 08ac28b..196b3c9 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -6,6 +6,7 @@
#include <byteswap.h>
#include <endian.h>
#include <sys/types.h>
+#include <string.h>
#include "blktrace_api.h"
#include "rbtree.h"
@@ -108,6 +109,26 @@ static inline int verify_trace(__u32 magic)
return 0;
}
+static inline void bit_to_bit2(struct blk_io_trace *old,
+ struct blk_io_trace2 *new)
+{
+ new->magic = old->magic;
+ new->sequence = old->sequence;
+ new->time = old->time;
+ new->sector = old->sector;
+ new->bytes = old->bytes;
+ new->action = 0 | old->action;
+ new->pid = old->pid;
+ new->device = old->device;
+ new->cpu = old->cpu;
+ new->error = old->error;
+ new->pdu_len = old->pdu_len;
+
+ if (new->pdu_len)
+ memcpy(((u8 *) new + sizeof(*new)), ((u8 *)old + sizeof(*old)),
+ old->pdu_len);
+}
+
static inline void bit_trace_to_cpu(struct blk_io_trace *t)
{
if (data_is_native)
@@ -147,7 +168,7 @@ static inline int check_data_endianness(u32 magic)
extern void set_all_format_specs(char *);
extern int add_format_spec(char *);
-extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
+extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace2 *,
unsigned long long, int, unsigned char *);
extern unsigned long long valid_act_opt(unsigned long long);
extern int find_mask_map(char *);
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (15 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:11 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions Johannes Thumshirn
` (3 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Natively parse 'struct blk_io_trace2' from a blktrace binary.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++
blktrace.h | 18 +++++++++
2 files changed, 130 insertions(+)
diff --git a/blkparse.c b/blkparse.c
index 7100009..2eec3a9 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2471,6 +2471,37 @@ static int read_one_bit(int fd, struct blk_io_trace2 **bit2, int block,
return 0;
}
+static int read_one_bit2(int fd, struct blk_io_trace2 **bit2, int block,
+ int *fdblock)
+{
+ struct blk_io_trace2 *new = *bit2;
+ int ret;
+ int pdu_len;
+ void *p;
+
+ p = (void *) ((u8 *)new + sizeof(__u32));
+
+ ret = read_data(fd, p, sizeof(*new) - sizeof(__u32), block, fdblock);
+ if (ret)
+ return ret;
+
+ pdu_len = get_pdulen(new->pdu_len);
+ if (pdu_len) {
+ void *ptr = realloc(new, sizeof(*new) + pdu_len);
+
+ ret = read_data(fd, ptr + sizeof(*new), pdu_len, 1, fdblock);
+ if (ret) {
+ free(ptr);
+ return ret;
+ }
+ new = ptr;
+ }
+
+ bit2_trace_to_cpu(new);
+ *bit2 = new;
+
+ return 0;
+}
static int read_events(int fd, int always_block, int *fdblock)
{
struct per_dev_info *pdi = NULL;
@@ -2538,6 +2569,44 @@ static int read_events(int fd, int always_block, int *fdblock)
t->next = trace_list;
trace_list = t;
+ if (!pdi || pdi->dev != bit->device)
+ pdi = get_dev_info(bit->device);
+
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+ } else if (version == SUPPORTED_VERSION2) {
+ struct blk_io_trace2 *bit;
+ bit = bit_alloc();
+ bit->magic = magic;
+
+ ret = read_one_bit2(fd, &bit, 1, fdblock);
+ if (ret)
+ break;
+
+ /*
+ * not a real trace, so grab and handle it here
+ */
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ continue;
+ }
+
+ if (verify_trace(bit->magic)) {
+ bit_free(bit);
+ bit = NULL;
+ continue;
+ }
+
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+ t->read_sequence = read_sequence;
+
+ t->next = trace_list;
+ trace_list = t;
+
if (!pdi || pdi->dev != bit->device)
pdi = get_dev_info(bit->device);
@@ -2698,6 +2767,49 @@ static int ms_prime(struct ms_stream *msp)
msp->last->next = t;
msp->last = t;
}
+ } else if (version == SUPPORTED_VERSION2) {
+ bit = bit_alloc();
+ bit->magic = magic;
+
+ ret = read_one_bit2(pci->fd, &bit, 1, &pci->fdblock);
+ if (ret)
+ goto err;
+
+ if (verify_trace(bit->magic))
+ goto err;
+
+ if (bit->cpu != pci->cpu) {
+ fprintf(stderr,
+ "cpu %d trace info has error cpu %d\n",
+ pci->cpu, bit->cpu);
+ continue;
+ }
+
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ bit_free(bit);
+ bit = NULL;
+
+ i -= 1;
+ continue;
+ }
+
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+
+ if (msp->first == NULL)
+ msp->first = msp->last = t;
+ else {
+ msp->last->next = t;
+ msp->last = t;
+ }
+
} else {
fprintf(stderr, "unsupported version %d\n", version);
continue;
diff --git a/blktrace.h b/blktrace.h
index 196b3c9..ba06237 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -129,6 +129,24 @@ static inline void bit_to_bit2(struct blk_io_trace *old,
old->pdu_len);
}
+static inline void bit2_trace_to_cpu(struct blk_io_trace2 *t)
+{
+ if (data_is_native)
+ return;
+
+ t->magic = be32_to_cpu(t->magic);
+ t->sequence = be32_to_cpu(t->sequence);
+ t->time = be64_to_cpu(t->time);
+ t->sector = be64_to_cpu(t->sector);
+ t->bytes = be32_to_cpu(t->bytes);
+ t->action = be64_to_cpu(t->action);
+ t->pid = be32_to_cpu(t->pid);
+ t->device = be32_to_cpu(t->device);
+ t->cpu = be32_to_cpu(t->cpu);
+ t->error = be16_to_cpu(t->error);
+ t->pdu_len = be16_to_cpu(t->pdu_len);
+}
+
static inline void bit_trace_to_cpu(struct blk_io_trace *t)
{
if (data_is_native)
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (16 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2 Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:12 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs() Johannes Thumshirn
` (2 subsequent siblings)
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Parse Zone Write Plugging plug and unplug actions in blkparse.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse.c | 7 +++++++
blkparse_fmt.c | 18 ++++++++++++++++++
blktrace_api.h | 2 ++
3 files changed, 27 insertions(+)
diff --git a/blkparse.c b/blkparse.c
index 2eec3a9..76c775b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -1722,6 +1722,13 @@ static void dump_trace_fs(struct blk_io_trace2 *t, struct per_dev_info *pdi,
account_unplug(t, pci, 1);
log_unplug(pci, t, "UT");
break;
+ case __BLK_TA_ZONE_PLUG:
+ log_action(pci, t, "ZP");
+ break;
+ case __BLK_TA_ZONE_UNPLUG:
+ account_unplug(t, pci, 0);
+ log_unplug(pci, t, "ZU");
+ break;
case __BLK_TA_SPLIT:
log_track_split(pdi, t);
log_split(pci, t, "X");
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index f93addb..80e02fc 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -301,6 +301,21 @@ static char *parse_field(char *act, struct per_cpu_info *pci,
return p;
}
+static void process_zoned(char *act, struct blk_io_trace2 *t, char *name)
+{
+ switch (act[1]) {
+ case 'P': /* Zone Plug */
+ fprintf(ofp, "[%s]\n", name);
+ break;
+ case 'U': /* Zone Unplug */
+ fprintf(ofp, "[%s] %u\n", name, get_pdu_int(t));
+ break;
+ default:
+ fprintf(stderr, "Unknown zoned action %c\n", act[1]);
+ break;
+ }
+}
+
static void process_default(char *act, struct per_cpu_info *pci,
struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf)
@@ -429,6 +444,9 @@ static void process_default(char *act, struct per_cpu_info *pci,
fprintf(ofp, "%*s\n", pdu_len, pdu_buf);
break;
+ case 'Z': /* Zoned command */
+ process_zoned(act, t, name);
+ break;
default:
fprintf(stderr, "Unknown action %c\n", act[0]);
break;
diff --git a/blktrace_api.h b/blktrace_api.h
index 04e81de..8db24fc 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -60,6 +60,8 @@ enum {
__BLK_TA_REMAP, /* bio was remapped */
__BLK_TA_ABORT, /* request aborted */
__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,
};
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs()
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (17 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:13 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace Johannes Thumshirn
2025-11-24 13:08 ` [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Martin K. Petersen
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Parse zoned commands in blkparse.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blkparse_fmt.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index 80e02fc..06b055b 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -60,19 +60,45 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
bool d = !!(t->action & BLK_TC_ACT(BLK_TC_DISCARD));
bool f = !!(t->action & BLK_TC_ACT(BLK_TC_FLUSH));
bool u = !!(t->action & BLK_TC_ACT(BLK_TC_FUA));
+ bool za = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_APPEND));
+ bool zr = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET));
+ bool zra = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET_ALL));
+ 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));
int i = 0;
if (f)
rwbs[i++] = 'F'; /* flush */
- if (d)
+ if (d) {
rwbs[i++] = 'D';
- else if (w)
+ } else if (za) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'A';
+ } else if (zr) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'R';
+ } else if (zra) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'R';
+ rwbs[i++] = 'A';
+ } else if (zf) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'F';
+ } else if (zo) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'O';
+ } else if (zc) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'C';
+ } else if (w) {
rwbs[i++] = 'W';
- else if (t->bytes)
+ } else if (t->bytes) {
rwbs[i++] = 'R';
- else
+ } else {
rwbs[i++] = 'N';
+ }
if (u)
rwbs[i++] = 'F'; /* fua */
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (18 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs() Johannes Thumshirn
@ 2025-11-24 7:37 ` Johannes Thumshirn
2025-11-24 9:14 ` Damien Le Moal
2025-11-24 13:08 ` [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Martin K. Petersen
20 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 7:37 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace, Johannes Thumshirn
Call BLKTRACESETUP2 ioctl per default and if the kernel does not support
this ioctl because it is too old, fall back to calling BLKTRACESETUP.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
blktrace.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/blktrace.c b/blktrace.c
index 038b2cb..72562fd 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -279,7 +279,7 @@ static int max_cpus;
static int ncpus;
static cpu_set_t *online_cpus;
static int pagesize;
-static int act_mask = ~0U;
+static unsigned long long act_mask = ~0U;
static int kill_running_trace;
static int stop_watch;
static int piped_output;
@@ -1067,6 +1067,36 @@ static void close_client_connections(void)
}
}
+static int setup_buts2(void)
+{
+ struct list_head *p;
+ int ret = 0;
+
+ __list_for_each(p, &devpaths) {
+ struct blk_user_trace_setup2 buts2;
+ struct devpath *dpp = list_entry(p, struct devpath, head);
+
+ memset(&buts2, 0, sizeof(buts2));
+ buts2.buf_size = buf_size;
+ buts2.buf_nr = buf_nr;
+ buts2.act_mask = act_mask;
+
+ if (ioctl(dpp->fd, BLKTRACESETUP2, &buts2) >= 0) {
+ dpp->ncpus = max_cpus;
+ dpp->buts_name = strdup(buts2.name);
+ dpp->setup_done = 1;
+ if (dpp->stats)
+ free(dpp->stats);
+ dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
+ memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats));
+ } else {
+ ret++;
+ }
+ }
+
+ return ret;
+}
+
static int setup_buts(void)
{
struct list_head *p;
@@ -2684,9 +2714,11 @@ static int run_tracers(void)
if (net_mode == Net_client)
printf("blktrace: connecting to %s\n", hostname);
- if (setup_buts()) {
- done = 1;
- return 1;
+ if (setup_buts2()) {
+ if (setup_buts()) {
+ done = 1;
+ return 1;
+ }
}
if (use_tracer_devpaths()) {
--
2.51.0
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2 Johannes Thumshirn
@ 2025-11-24 8:57 ` Damien Le Moal
2025-11-24 9:04 ` Johannes Thumshirn
2025-11-24 9:16 ` Damien Le Moal
1 sibling, 1 reply; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 8:57 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Add definitions for a new BLKTRACESETUP2 ioctl(2).
>
> This new ioctl(2) will request a new, updated structure layout from the
> kernel which enhances the storage size of the 'action' field in order to
> store additional tracepoints.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> blktrace_api.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/blktrace_api.h b/blktrace_api.h
> index 172b4c2..ecffe6e 100644
> --- a/blktrace_api.h
> +++ b/blktrace_api.h
> @@ -139,9 +139,25 @@ struct blk_user_trace_setup {
> __u32 pid;
> };
>
> +/*
> + * User setup structure passed with BLKTRACESETUP2
> + */
> +struct blk_user_trace_setup2 {
> + char name[64]; /* output */
> + __u64 act_mask; /* input */
> + __u32 buf_size; /* input */
> + __u32 buf_nr; /* input */
> + __u64 start_lba;
> + __u64 end_lba;
> + __u32 pid;
> + __u32 flags; /* currently unused */
> + __u64 reserved[11];
> +};
Any particular reason to go for 192B ? Why not 128B with a __u64 reserved[3] at
the end ? Not enough to future proof it ?
> +
> #define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
> #define BLKTRACESTART _IO(0x12,116)
> #define BLKTRACESTOP _IO(0x12,117)
> #define BLKTRACETEARDOWN _IO(0x12,118)
> +#define BLKTRACESETUP2 _IOWR(0x12, 142, struct blk_user_trace_setup2)
>
> #endif
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8 Johannes Thumshirn
@ 2025-11-24 9:00 ` Damien Le Moal
2025-11-24 9:04 ` Johannes Thumshirn
0 siblings, 1 reply; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:00 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Also support protocol version 8 in conjunction with protocol version 7.
Shouldn't this go last in the series, after enabling the code that deal with
this new version ?
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> blktrace.h | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/blktrace.h b/blktrace.h
> index 74dfb48..3305fa0 100644
> --- a/blktrace.h
> +++ b/blktrace.h
> @@ -69,6 +69,7 @@ extern struct timespec abs_start_time;
>
> #define CHECK_MAGIC(t) (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
> #define SUPPORTED_VERSION (0x07)
> +#define SUPPORTED_VERSION2 (0x08)
>
> #if __BYTE_ORDER == __LITTLE_ENDIAN
> #define be16_to_cpu(x) __bswap_16(x)
> @@ -90,13 +91,17 @@ extern struct timespec abs_start_time;
>
> static inline int verify_trace(struct blk_io_trace *t)
> {
> + u8 version;
> +
> if (!CHECK_MAGIC(t)) {
> fprintf(stderr, "bad trace magic %x\n", t->magic);
> return 1;
> }
> - if ((t->magic & 0xff) != SUPPORTED_VERSION) {
> - fprintf(stderr, "unsupported trace version %x\n",
> - t->magic & 0xff);
> +
> + version = t->magic & 0xff;
> + if (version != SUPPORTED_VERSION &&
> + version != SUPPORTED_VERSION2) {
> + fprintf(stderr, "unsupported trace version %x\n", version);
> return 1;
> }
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic Johannes Thumshirn
@ 2025-11-24 9:01 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:01 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Pass the magic value to get_magic() instead of the whole 'struct
> blk_io_trace'.
>
> This is a preparation for distinguishing between two different types of
> blktrace protocol versions in blkparse.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first Johannes Thumshirn
@ 2025-11-24 9:03 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:03 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Read the 'magic' portion of 'struct blk_io_trace' first when reading the
> tracefile and only if all magic checks succeed, read the rest of the
> trace.
>
> This is a preparation of supporting multiple trace protocol versions.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2
2025-11-24 8:57 ` Damien Le Moal
@ 2025-11-24 9:04 ` Johannes Thumshirn
0 siblings, 0 replies; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 9:04 UTC (permalink / raw)
To: Damien Le Moal, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Chaitanya Kulkarni, hch,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel,
linux-btrace@vger.kernel.org
On 11/24/25 9:57 AM, Damien Le Moal wrote:
> On 2025/11/24 16:37, Johannes Thumshirn wrote:
>> Add definitions for a new BLKTRACESETUP2 ioctl(2).
>>
>> This new ioctl(2) will request a new, updated structure layout from the
>> kernel which enhances the storage size of the 'action' field in order to
>> store additional tracepoints.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> ---
>> blktrace_api.h | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/blktrace_api.h b/blktrace_api.h
>> index 172b4c2..ecffe6e 100644
>> --- a/blktrace_api.h
>> +++ b/blktrace_api.h
>> @@ -139,9 +139,25 @@ struct blk_user_trace_setup {
>> __u32 pid;
>> };
>>
>> +/*
>> + * User setup structure passed with BLKTRACESETUP2
>> + */
>> +struct blk_user_trace_setup2 {
>> + char name[64]; /* output */
>> + __u64 act_mask; /* input */
>> + __u32 buf_size; /* input */
>> + __u32 buf_nr; /* input */
>> + __u64 start_lba;
>> + __u64 end_lba;
>> + __u32 pid;
>> + __u32 flags; /* currently unused */
>> + __u64 reserved[11];
>> +};
> Any particular reason to go for 192B ? Why not 128B with a __u64 reserved[3] at
> the end ? Not enough to future proof it ?
I don't completely remember why (could've been a mistake as well), but
the kernel hast u64 reserved[11] too.
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event Johannes Thumshirn
@ 2025-11-24 9:04 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:04 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Factor out reading a single blk_io_trace event. This de-duplicates code
> and also prepares for expansion with new trace protocol versions.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8
2025-11-24 9:00 ` Damien Le Moal
@ 2025-11-24 9:04 ` Johannes Thumshirn
2025-11-24 9:16 ` Damien Le Moal
0 siblings, 1 reply; 43+ messages in thread
From: Johannes Thumshirn @ 2025-11-24 9:04 UTC (permalink / raw)
To: Damien Le Moal, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Chaitanya Kulkarni, hch,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel,
linux-btrace@vger.kernel.org
On 11/24/25 10:00 AM, Damien Le Moal wrote:
> Shouldn't this go last in the series, after enabling the code that deal with
> this new version ?
Right, will move
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions Johannes Thumshirn
@ 2025-11-24 9:05 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:05 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Skip unsupported protocol versions for now.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len Johannes Thumshirn
@ 2025-11-24 9:06 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:06 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Directly pass in the pdu_len into get_pdulen() and only care about the
> byte swapping in get_pdulen().
>
> This enables us to use the function for different versions of the
> protocol.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first Johannes Thumshirn
@ 2025-11-24 9:06 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:06 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Similar to blkparse, read the 'magic' portion of 'struct blk_io_trace'
> first when reading the trace.
>
> This is a preparation of supporting multiple trace protocol versions.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro Johannes Thumshirn
@ 2025-11-24 9:07 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:07 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Pass only the magic number itself to the CHECK_MAGIC() macro.
>
> This enables support for multiple versions.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace Johannes Thumshirn
@ 2025-11-24 9:07 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:07 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Pass magic to verify_trace(), this will enable verification of multiple
> supported versions.
>
> Singed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu Johannes Thumshirn
@ 2025-11-24 9:08 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:08 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Not a big fan of empty commit messages, even if the content endup being trivial.
Nevertheless,
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally Johannes Thumshirn
@ 2025-11-24 9:10 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:10 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Use 'struct blk_io_trace2' as internal representation for a captured
> blktrace.
>
> This implies the conversion of 'struct blk_io_trace' into 'struct
> blk_io_trace2' when reading the trace from the binary file.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2 Johannes Thumshirn
@ 2025-11-24 9:11 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:11 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Natively parse 'struct blk_io_trace2' from a blktrace binary.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions Johannes Thumshirn
@ 2025-11-24 9:12 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:12 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Parse Zone Write Plugging plug and unplug actions in blkparse.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs()
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs() Johannes Thumshirn
@ 2025-11-24 9:13 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:13 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Parse zoned commands in blkparse.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace Johannes Thumshirn
@ 2025-11-24 9:14 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:14 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Call BLKTRACESETUP2 ioctl per default and if the kernel does not support
> this ioctl because it is too old, fall back to calling BLKTRACESETUP.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2 Johannes Thumshirn
@ 2025-11-24 9:15 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:15 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Add 'struct blk_io_trace2' which represents the extended version of the
> blktrace protocol.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2 Johannes Thumshirn
2025-11-24 8:57 ` Damien Le Moal
@ 2025-11-24 9:16 ` Damien Le Moal
1 sibling, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:16 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block, Chaitanya Kulkarni, Christoph Hellwig,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel, linux-btrace
On 2025/11/24 16:37, Johannes Thumshirn wrote:
> Add definitions for a new BLKTRACESETUP2 ioctl(2).
>
> This new ioctl(2) will request a new, updated structure layout from the
> kernel which enhances the storage size of the 'action' field in order to
> store additional tracepoints.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8
2025-11-24 9:04 ` Johannes Thumshirn
@ 2025-11-24 9:16 ` Damien Le Moal
0 siblings, 0 replies; 43+ messages in thread
From: Damien Le Moal @ 2025-11-24 9:16 UTC (permalink / raw)
To: Johannes Thumshirn, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Chaitanya Kulkarni, hch,
Shinichiro Kawasaki, Naohiro Aota, Niklas Cassel,
linux-btrace@vger.kernel.org
On 2025/11/24 18:04, Johannes Thumshirn wrote:
> On 11/24/25 10:00 AM, Damien Le Moal wrote:
>> Shouldn't this go last in the series, after enabling the code that deal with
>> this new version ?
>
> Right, will move
>
Feel free to add:
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
When you do.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
` (19 preceding siblings ...)
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace Johannes Thumshirn
@ 2025-11-24 13:08 ` Martin K. Petersen
20 siblings, 0 replies; 43+ messages in thread
From: Martin K. Petersen @ 2025-11-24 13:08 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: axboe@kernel.dk, linux-block, Damien Le Moal, Chaitanya Kulkarni,
Christoph Hellwig, Shinichiro Kawasaki, Naohiro Aota,
Niklas Cassel, linux-btrace
Johannes,
> This patch series extends the user-space blktrace tools to support the new
> trace events for zoned block device commands introduced in the corresponding
> kernel patch series.
Looks OK to me.
With patch 6 moved to the end:
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2025-11-24 13:08 UTC | newest]
Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 7:37 [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 01/20] blktrace: fix comment for struct blk_trace_setup: Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 02/20] blkparse: fix compiler warning Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 03/20] blktrace: add definitions for BLKTRACESETUP2 Johannes Thumshirn
2025-11-24 8:57 ` Damien Le Moal
2025-11-24 9:04 ` Johannes Thumshirn
2025-11-24 9:16 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 04/20] blktrace: change size of action to 64 bits Johannes Thumshirn
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 05/20] blktrace: add definitions for blk_io_trace2 Johannes Thumshirn
2025-11-24 9:15 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 06/20] blktrace: support protocol version 8 Johannes Thumshirn
2025-11-24 9:00 ` Damien Le Moal
2025-11-24 9:04 ` Johannes Thumshirn
2025-11-24 9:16 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 07/20] blkparse: pass magic to get_magic Johannes Thumshirn
2025-11-24 9:01 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 08/20] blkparse: read 'magic' first Johannes Thumshirn
2025-11-24 9:03 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 09/20] blkparse: factor out reading of a singe blk_io_trace event Johannes Thumshirn
2025-11-24 9:04 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 10/20] blkparse: skip unsupported protocol versions Johannes Thumshirn
2025-11-24 9:05 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 11/20] blkparse: make get_pdulen() take the pdu_len Johannes Thumshirn
2025-11-24 9:06 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 12/20] blkiomon: read 'magic' first Johannes Thumshirn
2025-11-24 9:06 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 13/20] blktrace: pass magic to CHECK_MAGIC macro Johannes Thumshirn
2025-11-24 9:07 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 14/20] blktrace: pass magic to verify_trace Johannes Thumshirn
2025-11-24 9:07 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 15/20] blktrace: rename trace_to_cpu to bit_trace_to_cpu Johannes Thumshirn
2025-11-24 9:08 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 16/20] blkparse: use blk_io_trace2 internally Johannes Thumshirn
2025-11-24 9:10 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 17/20] blkparse: natively parse blk_io_trace2 Johannes Thumshirn
2025-11-24 9:11 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 18/20] blkparse: parse zone (un)plug actions Johannes Thumshirn
2025-11-24 9:12 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 19/20] blkparse: add zoned commands to fill_rwbs() Johannes Thumshirn
2025-11-24 9:13 ` Damien Le Moal
2025-11-24 7:37 ` [RESEND PATCH blktrace v3 20/20] blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace Johannes Thumshirn
2025-11-24 9:14 ` Damien Le Moal
2025-11-24 13:08 ` [RESEND PATCH blktrace v3 00/20] blktrace: Add user-space support for zoned command tracing Martin K. Petersen
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).