Skip to content

Commit e70b64a

Browse files
Dylan Yudakenaxboe
authored andcommitted
io_uring: move io_uring_get_opcode out of TP_printk
The TP_printk macro's are not supposed to use custom code ([1]) or else tools such as perf cannot use these events. Convert the opcode string representation to use the __string wiring that the event framework provides ([2]). [1]: https://lwn.net/Articles/379903/ [2]: https://lwn.net/Articles/381064/ Fixes: 033b87d ("io_uring: use the text representation of ops in trace") Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220623083743.2648321-1-dylany@fb.com [axboe: fixup spurious removal of sq_thread assignment] Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c0737fa commit e70b64a

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

include/trace/events/io_uring.h

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ TRACE_EVENT(io_uring_queue_async_work,
158158
__field( unsigned int, flags )
159159
__field( struct io_wq_work *, work )
160160
__field( int, rw )
161+
162+
__string( op_str, io_uring_get_opcode(opcode) )
161163
),
162164

163165
TP_fast_assign(
@@ -168,11 +170,13 @@ TRACE_EVENT(io_uring_queue_async_work,
168170
__entry->opcode = opcode;
169171
__entry->work = work;
170172
__entry->rw = rw;
173+
174+
__assign_str(op_str, io_uring_get_opcode(opcode));
171175
),
172176

173177
TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, flags 0x%x, %s queue, work %p",
174178
__entry->ctx, __entry->req, __entry->user_data,
175-
io_uring_get_opcode(__entry->opcode),
179+
__get_str(op_str),
176180
__entry->flags, __entry->rw ? "hashed" : "normal", __entry->work)
177181
);
178182

@@ -198,18 +202,22 @@ TRACE_EVENT(io_uring_defer,
198202
__field( void *, req )
199203
__field( unsigned long long, data )
200204
__field( u8, opcode )
205+
206+
__string( op_str, io_uring_get_opcode(opcode) )
201207
),
202208

203209
TP_fast_assign(
204210
__entry->ctx = ctx;
205211
__entry->req = req;
206212
__entry->data = user_data;
207213
__entry->opcode = opcode;
214+
215+
__assign_str(op_str, io_uring_get_opcode(opcode));
208216
),
209217

210218
TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s",
211219
__entry->ctx, __entry->req, __entry->data,
212-
io_uring_get_opcode(__entry->opcode))
220+
__get_str(op_str))
213221
);
214222

215223
/**
@@ -298,6 +306,8 @@ TRACE_EVENT(io_uring_fail_link,
298306
__field( unsigned long long, user_data )
299307
__field( u8, opcode )
300308
__field( void *, link )
309+
310+
__string( op_str, io_uring_get_opcode(opcode) )
301311
),
302312

303313
TP_fast_assign(
@@ -306,11 +316,13 @@ TRACE_EVENT(io_uring_fail_link,
306316
__entry->user_data = user_data;
307317
__entry->opcode = opcode;
308318
__entry->link = link;
319+
320+
__assign_str(op_str, io_uring_get_opcode(opcode));
309321
),
310322

311323
TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, link %p",
312324
__entry->ctx, __entry->req, __entry->user_data,
313-
io_uring_get_opcode(__entry->opcode), __entry->link)
325+
__get_str(op_str), __entry->link)
314326
);
315327

316328
/**
@@ -390,6 +402,8 @@ TRACE_EVENT(io_uring_submit_sqe,
390402
__field( u32, flags )
391403
__field( bool, force_nonblock )
392404
__field( bool, sq_thread )
405+
406+
__string( op_str, io_uring_get_opcode(opcode) )
393407
),
394408

395409
TP_fast_assign(
@@ -400,11 +414,13 @@ TRACE_EVENT(io_uring_submit_sqe,
400414
__entry->flags = flags;
401415
__entry->force_nonblock = force_nonblock;
402416
__entry->sq_thread = sq_thread;
417+
418+
__assign_str(op_str, io_uring_get_opcode(opcode));
403419
),
404420

405421
TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, flags 0x%x, "
406422
"non block %d, sq_thread %d", __entry->ctx, __entry->req,
407-
__entry->user_data, io_uring_get_opcode(__entry->opcode),
423+
__entry->user_data, __get_str(op_str),
408424
__entry->flags, __entry->force_nonblock, __entry->sq_thread)
409425
);
410426

@@ -435,6 +451,8 @@ TRACE_EVENT(io_uring_poll_arm,
435451
__field( u8, opcode )
436452
__field( int, mask )
437453
__field( int, events )
454+
455+
__string( op_str, io_uring_get_opcode(opcode) )
438456
),
439457

440458
TP_fast_assign(
@@ -444,11 +462,13 @@ TRACE_EVENT(io_uring_poll_arm,
444462
__entry->opcode = opcode;
445463
__entry->mask = mask;
446464
__entry->events = events;
465+
466+
__assign_str(op_str, io_uring_get_opcode(opcode));
447467
),
448468

449469
TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask 0x%x, events 0x%x",
450470
__entry->ctx, __entry->req, __entry->user_data,
451-
io_uring_get_opcode(__entry->opcode),
471+
__get_str(op_str),
452472
__entry->mask, __entry->events)
453473
);
454474

@@ -474,6 +494,8 @@ TRACE_EVENT(io_uring_task_add,
474494
__field( unsigned long long, user_data )
475495
__field( u8, opcode )
476496
__field( int, mask )
497+
498+
__string( op_str, io_uring_get_opcode(opcode) )
477499
),
478500

479501
TP_fast_assign(
@@ -482,11 +504,13 @@ TRACE_EVENT(io_uring_task_add,
482504
__entry->user_data = user_data;
483505
__entry->opcode = opcode;
484506
__entry->mask = mask;
507+
508+
__assign_str(op_str, io_uring_get_opcode(opcode));
485509
),
486510

487511
TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask %x",
488512
__entry->ctx, __entry->req, __entry->user_data,
489-
io_uring_get_opcode(__entry->opcode),
513+
__get_str(op_str),
490514
__entry->mask)
491515
);
492516

@@ -523,6 +547,8 @@ TRACE_EVENT(io_uring_req_failed,
523547
__field( u64, pad1 )
524548
__field( u64, addr3 )
525549
__field( int, error )
550+
551+
__string( op_str, io_uring_get_opcode(sqe->opcode) )
526552
),
527553

528554
TP_fast_assign(
@@ -542,6 +568,8 @@ TRACE_EVENT(io_uring_req_failed,
542568
__entry->pad1 = sqe->__pad2[0];
543569
__entry->addr3 = sqe->addr3;
544570
__entry->error = error;
571+
572+
__assign_str(op_str, io_uring_get_opcode(sqe->opcode));
545573
),
546574

547575
TP_printk("ring %p, req %p, user_data 0x%llx, "
@@ -550,7 +578,7 @@ TRACE_EVENT(io_uring_req_failed,
550578
"personality=%d, file_index=%d, pad=0x%llx, addr3=%llx, "
551579
"error=%d",
552580
__entry->ctx, __entry->req, __entry->user_data,
553-
io_uring_get_opcode(__entry->opcode),
581+
__get_str(op_str),
554582
__entry->flags, __entry->ioprio,
555583
(unsigned long long)__entry->off,
556584
(unsigned long long) __entry->addr, __entry->len,

0 commit comments

Comments
 (0)