Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Tom Zanussi <zanussi@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	 Ingo Molnar <mingo@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Qiujun Huang <hqjagain@gmail.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] [v2] tracing: use %ps format string to print symbols
Date: Mon, 18 Oct 2021 09:42:47 -0500	[thread overview]
Message-ID: <d4ad897585ddc815c188bbf0b3b8cec1cb40b7a4.camel@kernel.org> (raw)
In-Reply-To: <20211018132538.2468989-1-arnd@kernel.org>

Hi Arnd,

On Mon, 2021-10-18 at 15:25 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Rather than printing the symbol names into separate buffers, it
> seems we can simply use the special %ps format string modifier
> to print the pointers symbolically and get rid of both buffers.
> 
> Marking hist_trigger_stacktrace_print() would be a simpler
> way of avoiding the warning, but that would not address the
> excessive stack usage.
> 
> Fixes: 69a0200c2e25 ("tracing: Add hist trigger support for
> stacktraces as keys")
> Link: 
> https://lore.kernel.org/all/20211015095704.49a99859@gandalf.local.home/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Changes in v2:
>  - Use %pS instead of %ps to include offset in third string
>  - add (void*) cast to avoid compile-time warnings
> 
> This is still only compile-tested to ensure that the warning
> goes away, I have not validated what it does to the formatting.


This looks fine to me, thanks for the patch!

Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Tested-by: Tom Zanussi <zanussi@kernel.org>


> ---
>  kernel/trace/trace_events_hist.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_hist.c
> b/kernel/trace/trace_events_hist.c
> index a6061a69aa84..d6d4362c273c 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -4706,7 +4706,6 @@ static void
> hist_trigger_stacktrace_print(struct seq_file *m,
>  					  unsigned long
> *stacktrace_entries,
>  					  unsigned int max_entries)
>  {
> -	char str[KSYM_SYMBOL_LEN];
>  	unsigned int spaces = 8;
>  	unsigned int i;
>  
> @@ -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", (void*)stacktrace_entries[i]);
>  	}
>  }
>  
> @@ -4726,7 +4724,6 @@ static void hist_trigger_print_key(struct
> seq_file *m,
>  				   struct tracing_map_elt *elt)
>  {
>  	struct hist_field *key_field;
> -	char str[KSYM_SYMBOL_LEN];
>  	bool multiline = false;
>  	const char *field_name;
>  	unsigned int i;
> @@ -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);
>  		} else if (key_field->flags & HIST_FIELD_FL_EXECNAME) {
>  			struct hist_elt_data *elt_data = elt-
> >private_data;
>  			char *comm;


  reply	other threads:[~2021-10-18 14:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 13:25 [PATCH] [v2] tracing: use %ps format string to print symbols Arnd Bergmann
2021-10-18 14:42 ` Tom Zanussi [this message]
2021-10-19 15:32   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4ad897585ddc815c188bbf0b3b8cec1cb40b7a4.camel@kernel.org \
    --to=zanussi@kernel.org \
    --cc=42.hyeyoo@gmail.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=hqjagain@gmail.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox