OSDN Git Service

io_uring: use the text representation of ops in trace
authorDylan Yudaken <dylany@fb.com>
Tue, 26 Apr 2022 08:29:07 +0000 (01:29 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 Apr 2022 23:06:03 +0000 (17:06 -0600)
It is annoying to translate opcodes to textwhen tracing io_uring. Use the
io_uring_get_opcode function instead to use the text representation.

A downside here might have been that if the opcode is invalid it will not
be obvious, however the opcode is already overridden in these cases to
0 (NOP) in io_init_req(). Therefore this is a non issue.

Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220426082907.3600028-5-dylany@fb.com
[axboe: don't include register, those are not req opcodes]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/trace/events/io_uring.h

index 42c7e1a..3f2961b 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/tracepoint.h>
 #include <uapi/linux/io_uring.h>
+#include <linux/io_uring.h>
 
 struct io_wq_work;
 
@@ -169,8 +170,9 @@ TRACE_EVENT(io_uring_queue_async_work,
                __entry->rw             = rw;
        ),
 
-       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %d, flags 0x%x, %s queue, work %p",
-               __entry->ctx, __entry->req, __entry->user_data, __entry->opcode,
+       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, flags 0x%x, %s queue, work %p",
+               __entry->ctx, __entry->req, __entry->user_data,
+               io_uring_get_opcode(__entry->opcode),
                __entry->flags, __entry->rw ? "hashed" : "normal", __entry->work)
 );
 
@@ -205,8 +207,9 @@ TRACE_EVENT(io_uring_defer,
                __entry->opcode = opcode;
        ),
 
-       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %d",
-               __entry->ctx, __entry->req, __entry->data, __entry->opcode)
+       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s",
+               __entry->ctx, __entry->req, __entry->data,
+               io_uring_get_opcode(__entry->opcode))
 );
 
 /**
@@ -305,9 +308,9 @@ TRACE_EVENT(io_uring_fail_link,
                __entry->link           = link;
        ),
 
-       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %d, link %p",
-               __entry->ctx, __entry->req, __entry->user_data, __entry->opcode,
-               __entry->link)
+       TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, link %p",
+               __entry->ctx, __entry->req, __entry->user_data,
+               io_uring_get_opcode(__entry->opcode), __entry->link)
 );
 
 /**
@@ -389,9 +392,9 @@ TRACE_EVENT(io_uring_submit_sqe,
                __entry->sq_thread      = sq_thread;
        ),
 
-       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %d, flags 0x%x, "
+       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, flags 0x%x, "
                  "non block %d, sq_thread %d", __entry->ctx, __entry->req,
-                 __entry->user_data, __entry->opcode,
+                 __entry->user_data, io_uring_get_opcode(__entry->opcode),
                  __entry->flags, __entry->force_nonblock, __entry->sq_thread)
 );
 
@@ -433,8 +436,9 @@ TRACE_EVENT(io_uring_poll_arm,
                __entry->events         = events;
        ),
 
-       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %d, mask 0x%x, events 0x%x",
-                 __entry->ctx, __entry->req, __entry->user_data, __entry->opcode,
+       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask 0x%x, events 0x%x",
+                 __entry->ctx, __entry->req, __entry->user_data,
+                 io_uring_get_opcode(__entry->opcode),
                  __entry->mask, __entry->events)
 );
 
@@ -470,8 +474,9 @@ TRACE_EVENT(io_uring_task_add,
                __entry->mask           = mask;
        ),
 
-       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %d, mask %x",
-               __entry->ctx, __entry->req, __entry->user_data, __entry->opcode,
+       TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask %x",
+               __entry->ctx, __entry->req, __entry->user_data,
+               io_uring_get_opcode(__entry->opcode),
                __entry->mask)
 );
 
@@ -530,12 +535,13 @@ TRACE_EVENT(io_uring_req_failed,
        ),
 
        TP_printk("ring %p, req %p, user_data 0x%llx, "
-                 "opcode %d, flags 0x%x, prio=%d, off=%llu, addr=%llu, "
+                 "opcode %s, flags 0x%x, prio=%d, off=%llu, addr=%llu, "
                  "len=%u, rw_flags=0x%x, buf_index=%d, "
                  "personality=%d, file_index=%d, pad=0x%llx, addr3=%llx, "
                  "error=%d",
                  __entry->ctx, __entry->req, __entry->user_data,
-                 __entry->opcode, __entry->flags, __entry->ioprio,
+                 io_uring_get_opcode(__entry->opcode),
+                 __entry->flags, __entry->ioprio,
                  (unsigned long long)__entry->off,
                  (unsigned long long) __entry->addr, __entry->len,
                  __entry->op_flags,