Recently, I'm tracing the io_uring in Linux kernel. I found a function trace_io_uring_submit_sqe was called in io_uring.c. Through searching symbol on Github mirror repository or on elixir.bootlin, I can't found the definition of its. Are there any other way to find it or it just doesn't exist?
Where is the function: trace_io_uring_submit_sqe in Linux kernel?
278 Views Asked by Steven At
1
This symbol is created dynamically using a macro, that's why you can't find it in the sources.
The file trace/events/io_uring.h is included on line 84, and it contains this usage of macro
TRACE_EVENT:The
TRACE_EVENTmacro is defined in linux/tracepoint.h using another macro,DECLARE_TRACE.DECLARE_TRACEis defined in the same file on line 418 and uses__DECLARE_TRACEwhich is defined in the same file again, on line 241 or 341 depending on the value of the macroTRACEPOINTS_ENABLEDon line 162.The
__DECLARE_TRACEmacro begins with:This line specifically:
expands into a declaration of a
static inline voidfunction whose name is thenamepassed down fromTRACE_EVENTwith a prefixtrace_prepended to it (##is used for string concatenation in macros), which in your case results in a name oftrace_io_uring_submit_sqe.Here you may find documentation of tracing.
How to recognize dynamic code generation using macros?
If you look throughout the
io_uring.cfile you will find a few functions with names following the formula oftrace_ + some_function. At the same time, none of them can be found in the source code. This often means these symbols are generated using a macro. In such cases you could try looking for the common prefix instead of the whole symbol. If you search fortrace_on github you will find multiple similar macros which could have given you an idea of what is happening.