1TRACE_PRINTK(9)                  Driver Basics                 TRACE_PRINTK(9)
2
3
4

NAME

6       trace_printk - printf formatting in the ftrace buffer
7

SYNOPSIS

9       trace_printk(fmt, ...);
10

ARGUMENTS

12       fmt
13           the printf format for printing
14
15       ...
16           variable arguments
17

NOTE

19       __trace_printk is an internal function for trace_printk and the ip is
20       passed in via the trace_printk macro.
21
22       This function allows a kernel developer to debug fast path sections
23       that printk is not appropriate for. By scattering in various printk
24       like tracing in the code, a developer can quickly see where problems
25       are occurring.
26
27       This is intended as a debugging tool for the developer only. Please
28       refrain from leaving trace_printks scattered around in your code.
29       (Extra memory is used for special buffers that are allocated when
30       trace_printk is used)
31
32       A little optization trick is done here. If there's only one argument,
33       there's no need to scan the string for printf formats. The trace_puts
34       will suffice. But how can we take advantage of using trace_puts when
35       trace_printk has only one argument? By stringifying the args and
36       checking the size we can tell whether or not there are args.
37       __stringify((__VA_ARGS__)) will turn into “()\0” with a size of 3 when
38       there are no args, anything else will be bigger. All we need to do is
39       define a string to this, and then take its size and compare to 3. If
40       it's bigger, use do_trace_printk otherwise, optimize it to trace_puts.
41       Then just let gcc optimize the rest.
42
44Kernel Hackers Manual 3.10         June 2019                   TRACE_PRINTK(9)
Impressum