block: Make the rwbs field as a bit field enum
authorGeneviève Bastien <gbastien@versatic.net>
Tue, 11 Feb 2020 16:20:27 +0000 (11:20 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 14 Feb 2020 15:54:16 +0000 (10:54 -0500)
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 <gbastien@versatic.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/block.h

index 9f77526db0aaec415cf82f017a35d4fbb90ccaee..9dd47eddce5d0b340b04cdfa817ddd07ec13b08f 100644 (file)
@@ -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 ))))                                              \
This page took 0.026986 seconds and 4 git commands to generate.