Re: [PATCH 08/16] tracing: have event_trace_printk use static tracer

Steven Rostedt
2009-03-13T03:08:38Z

On Thu, 12 Mar 2009, Andrew Morton wrote:

> On Thu, 12 Mar 2009 22:37:12 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > + static const char *trace_printk_fmt \
> > + __attribute__((section("__trace_printk_fmt"))) = \
> > + __builtin_constant_p(fmt) ? fmt : NULL; \
>
> hm. Does this put trace_printk_fmt into the __trace_printk_fmt
> section, or does it put *trace_printk_fmt in there?

We save the pointer into that section:

0xc0432100: "my format is to print this number %d\n"

[...]

section <__trace_printk_fmt>:
[...]
0xc0483210: 0xc0432100 (trace_printk_fmt)

It would be difficult to make the string be located in the section when
the caller simply does:

trace_printk("my format is to print this number %d\n", mynum);

Although I guess we could try by using [] = fmt, but the pointer just
seemed easier.

Note, for modules, we have a hash of all strings/pointers. When a module
is loaded, we copy the strings into the hash (if it is not already there)
and keep it loaded, even if the module is removed. This is because the
pointer to this string would still be around inside the trace buffer.

-- Steve