From 23634515e7271c8c8594ad87a6685232d4eff297 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Tue, 11 Feb 2020 11:20:27 -0500 Subject: [PATCH] block: Make the rwbs field as a bit field enum MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The rwbs value of block request events is in fact a series of bit fields set to 0 or 1. The enumeration values are all powers of 2, trace readers could interpret this as a bit field enum and show the result as a concatenation of the corresponding flags. For example, with a matching patch for babeltrace2's pretty sink, the output for a rwbs value of 12 would be: [13:15:49.024354958] (+0.000003868) wilbrod block_rq_complete: { cpu_id = 4 }, { dev = 8388624, sector = 375490176, nr_sector = 360, error = 0, rwbs = ( "RWBS_FLAG_READ" | "RWBS_FLAG_RAHEAD" : container = 12 ) } Consumers who have no notion of the bit field enum can still use the integer value of the field as before. Change-Id: I2e873f16e5a0507e52cfc85c70b471a9f4d5d5d1 Signed-off-by: Geneviève Bastien Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/block.h | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/instrumentation/events/lttng-module/block.h b/instrumentation/events/lttng-module/block.h index 9f77526d..9dd47edd 100644 --- a/instrumentation/events/lttng-module/block.h +++ b/instrumentation/events/lttng-module/block.h @@ -34,6 +34,22 @@ enum { #endif /* _TRACE_BLOCK_DEF_ */ +LTTNG_TRACEPOINT_ENUM(block_rq_type, + TP_ENUM_VALUES( + ctf_enum_value("RWBS_FLAG_WRITE", RWBS_FLAG_WRITE) + ctf_enum_value("RWBS_FLAG_DISCARD", RWBS_FLAG_DISCARD) + ctf_enum_value("RWBS_FLAG_READ", RWBS_FLAG_READ) + ctf_enum_value("RWBS_FLAG_RAHEAD", RWBS_FLAG_RAHEAD) + ctf_enum_value("RWBS_FLAG_BARRIER", RWBS_FLAG_BARRIER) + ctf_enum_value("RWBS_FLAG_SYNC", RWBS_FLAG_SYNC) + ctf_enum_value("RWBS_FLAG_META", RWBS_FLAG_META) + ctf_enum_value("RWBS_FLAG_SECURE", RWBS_FLAG_SECURE) + ctf_enum_value("RWBS_FLAG_FLUSH", RWBS_FLAG_FLUSH) + ctf_enum_value("RWBS_FLAG_FUA", RWBS_FLAG_FUA) + ctf_enum_value("RWBS_FLAG_PREFLUSH", RWBS_FLAG_PREFLUSH) + ) +) + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \ @@ -49,7 +65,7 @@ enum { #define lttng_bio_rw(bio) ((bio)->bi_opf) #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ - ctf_integer(type, rwbs, \ + ctf_enum(block_rq_type, type, rwbs, \ (((op) == REQ_OP_WRITE || (op) == REQ_OP_WRITE_SAME) ? RWBS_FLAG_WRITE : \ ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD : \ ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \ @@ -70,7 +86,7 @@ enum { #define lttng_bio_rw(bio) ((bio)->bi_rw) #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ - ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ + ctf_enum(block_rq_type, type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ ( (bytes) ? RWBS_FLAG_READ : \ ( 0 )))) \ @@ -89,7 +105,7 @@ enum { #define lttng_bio_rw(bio) ((bio)->bi_rw) #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ - ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ + ctf_enum(block_rq_type, type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ ( (bytes) ? RWBS_FLAG_READ : \ ( 0 )))) \ -- 2.34.1