[PATCH 12/16] blktrace: add block trace commands for zone operations

Johannes Thumshirn posted 16 patches 3 weeks, 2 days ago
There is a newer version of this series
[PATCH 12/16] blktrace: add block trace commands for zone operations
Posted by Johannes Thumshirn 3 weeks, 2 days ago
Add block trace commands for zone operations. These are added as a
separate set of 'block trace commands' shifted by 32bit so that they do
not interfere with the old 16bit wide trace command field in 'struct
blk_io_trace' action.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 include/uapi/linux/blktrace_api.h | 11 +++++++++++
 kernel/trace/blktrace.c           | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
index 01779f84d09f..d5047467c8ee 100644
--- a/include/uapi/linux/blktrace_api.h
+++ b/include/uapi/linux/blktrace_api.h
@@ -29,8 +29,19 @@ enum blktrace_cat {
 	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
 };
 
+enum blktrace_cat2 {
+	BLK_TC_ZONE_APPEND	= 1 << 1ull,   	/* zone append */
+	BLK_TC_ZONE_RESET	= 1 << 2ull,	/* zone reset */
+	BLK_TC_ZONE_RESET_ALL	= 1 << 3ull,	/* zone reset all */
+	BLK_TC_ZONE_FINISH	= 1 << 4ull,	/* zone finish */
+	BLK_TC_ZONE_OPEN	= 1 << 5ull,	/* zone open */
+	BLK_TC_ZONE_CLOSE	= 1 << 6ull,	/* zone close */
+};
+
 #define BLK_TC_SHIFT		(16)
 #define BLK_TC_ACT(act)		((act) << BLK_TC_SHIFT)
+#define BLK_TC_SHIFT2		(32)
+#define BLK_TC_ACT2(act)	((u64)(act) << BLK_TC_SHIFT2)
 
 /*
  * Basic trace actions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 82ad626d6202..62f6cfcee4f6 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -333,6 +333,24 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 	case REQ_OP_FLUSH:
 		what |= BLK_TC_ACT(BLK_TC_FLUSH);
 		break;
+	case REQ_OP_ZONE_APPEND:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_APPEND);
+		break;
+	case REQ_OP_ZONE_RESET:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_RESET);
+		break;
+	case REQ_OP_ZONE_RESET_ALL:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_RESET_ALL);
+		break;
+	case REQ_OP_ZONE_FINISH:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_FINISH);
+		break;
+	case REQ_OP_ZONE_OPEN:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_OPEN);
+		break;
+	case REQ_OP_ZONE_CLOSE:
+		what |= BLK_TC_ACT2(BLK_TC_ZONE_CLOSE);
+		break;
 	default:
 		break;
 	}
-- 
2.51.0
Re: [PATCH 12/16] blktrace: add block trace commands for zone operations
Posted by Christoph Hellwig 1 week, 6 days ago
On Tue, Sep 09, 2025 at 01:06:07PM +0200, Johannes Thumshirn wrote:
> Add block trace commands for zone operations. These are added as a
> separate set of 'block trace commands' shifted by 32bit so that they do
> not interfere with the old 16bit wide trace command field in 'struct
> blk_io_trace' action.

This is very confusing.  Why not havve a single enum with the actual
values with a clearly marked cutoff for v1?