Re: [PATCH] tracing: use %ps format string to print symbols

From: Arnd Bergmann
Date: Fri Oct 15 2021 - 10:41:38 EST


On Fri, Oct 15, 2021 at 3:57 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Fri, 15 Oct 2021 10:34:31 +0200
> Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> > From: Arnd Bergmann <arnd@xxxxxxxx>
> >
> > clang started warning about excessive stack usage in
> > hist_trigger_print_key()
> >
> > kernel/trace/trace_events_hist.c:4723:13: error: stack frame size (1336) exceeds limit (1024) in function 'hist_trigger_print_key' [-Werror,-Wframe-larger-than]
> >
> > The problem is that there are two 512-byte arrays on the stack if
> > hist_trigger_stacktrace_print() gets inlined. I don't think this has
> > changed in the past five years, but something probably changed the
> > inlining decisions made by the compiler, so the problem is now made
> > more obvious.
>
> Could we just add "noinline" attribute to that function?

It would avoid the warning, but not reduce the overall stack
usage. If that's good enough for you, I'm fine with that as well.

> > @@ -4715,8 +4714,7 @@ static void hist_trigger_stacktrace_print(struct seq_file *m,
> > return;
> >
> > seq_printf(m, "%*c", 1 + spaces, ' ');
> > - sprint_symbol(str, stacktrace_entries[i]);
> > - seq_printf(m, "%s\n", str);
> > + seq_printf(m, "%pS\n", stacktrace_entries[i]);

I just noticed this needs an extra cast to (void*) to avoid a warning
with clang,
not sure why I saw it build cleanly before.

> > @@ -4747,14 +4744,12 @@ static void hist_trigger_print_key(struct seq_file *m,
> > seq_printf(m, "%s: %llx", field_name, uval);
> > } else if (key_field->flags & HIST_FIELD_FL_SYM) {
> > uval = *(u64 *)(key + key_field->offset);
> > - sprint_symbol_no_offset(str, uval);
> > - seq_printf(m, "%s: [%llx] %-45s", field_name,
> > - uval, str);
> > + seq_printf(m, "%s: [%llx] %-45ps", field_name,
> > + uval, (void *)uval);
> > } else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) {
> > uval = *(u64 *)(key + key_field->offset);
> > - sprint_symbol(str, uval);
> > - seq_printf(m, "%s: [%llx] %-55s", field_name,
> > - uval, str);
> > + seq_printf(m, "%s: [%llx] %-55ps", field_name,
> > + uval, (void *)uval);
>
> The above requires "Ps" not "ps".

you mean "%-55pS", right?

> But other than that, I could test if this doesn't change the formatting and
> functionality at all.

Ok, let me know if I should resend with the two small changes I mentioned,
or if you want to just go with the 'noinline_for_stack' annotation.

Arnd