All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tom Zanussi <zanussi@kernel.org>, Arnd Bergmann <arnd@arndb.de>
Subject: [for-next][PATCH 32/40] tracing: use %ps format string to print symbols
Date: Fri, 22 Oct 2021 16:48:28 -0400	[thread overview]
Message-ID: <20211022204844.089918832@goodmis.org> (raw)
In-Reply-To: 20211022204756.099054287@goodmis.org

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.

Link: https://lkml.kernel.org/r/20211019153337.294790-1-arnd@kernel.org

Fixes: 69a0200c2e25 ("tracing: Add hist trigger support for stacktraces as keys")
Link: https://lore.kernel.org/all/20211015095704.49a99859@gandalf.local.home/
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Tested-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.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..b64aed538628 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 *)(uintptr_t)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 *)(uintptr_t)uval);
 		} else if (key_field->flags & HIST_FIELD_FL_EXECNAME) {
 			struct hist_elt_data *elt_data = elt->private_data;
 			char *comm;
-- 
2.33.0

  parent reply	other threads:[~2021-10-22 20:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 20:47 [for-next][PATCH 00/40] tracing: Updates for 5.16 Steven Rostedt
2021-10-22 20:47 ` [for-next][PATCH 01/40] tracing: Initialize upper and lower vars in pid_list_refill_irq() Steven Rostedt
2021-10-22 20:47 ` [for-next][PATCH 02/40] tracefs: Have tracefs directories not set OTH permission bits by default Steven Rostedt
2021-10-22 20:47 ` [for-next][PATCH 03/40] tracing: Disable "other" permission bits in the tracefs files Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 04/40] ftrace: Cleanup ftrace_dyn_arch_init() Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 05/40] bootconfig: Allocate xbc_data inside xbc_init() Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 06/40] bootconfig: Add xbc_get_info() for the node information Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 07/40] tools/bootconfig: Run test script when build all Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 08/40] bootconfig: Rename xbc_destroy_all() to xbc_exit() Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 09/40] bootconfig: Split parse-tree part from xbc_init Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 10/40] bootconfig: Remove unused debug function Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 11/40] tools/bootconfig: Print all error message in stderr Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 12/40] bootconfig: Replace u16 and u32 with uint16_t and uint32_t Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 13/40] bootconfig: Cleanup dummy headers in tools/bootconfig Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 14/40] ftrace: Add unit test for removing trace function Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 15/40] tracing: in_irq() cleanup Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 16/40] tracing: Use linker magic instead of recasting ftrace_ops_list_func() Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 17/40] tracing/cfi: Fix cmp_entries_* functions signature mismatch Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 18/40] tracing: Reuse logic from perfs get_recursion_context() Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 19/40] tracing/perf: Add interrupt_context_level() helper Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 20/40] x86/ftrace: Remove extra orig rax move Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 21/40] x86/ftrace: Remove fault protection code in prepare_ftrace_return Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 22/40] ftrace/x86_64: Have function graph tracer depend on DYNAMIC_FTRACE Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 23/40] x86/ftrace: Make function graph use ftrace directly Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 24/40] tracing: Add trampoline/graph selftest Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 25/40] tracing: Fix selftest config check for function graph start up test Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 26/40] ftrace: Add ftrace_add_rec_direct function Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 27/40] ftrace: Add multi direct register/unregister interface Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 28/40] ftrace: Add multi direct modify interface Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 29/40] ftrace/samples: Add multi direct interface test module Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 30/40] ftrace/direct: Do not disable when switching direct callers Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 31/40] tracing: Explain the trace recursion transition bit better Steven Rostedt
2021-10-22 20:48 ` Steven Rostedt [this message]
2021-10-22 20:48 ` [for-next][PATCH 33/40] kprobes: convert tests to kunit Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 34/40] x86/unwind: Compile kretprobe fixup code only if CONFIG_KRETPROBES=y Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 35/40] arm64: kprobes: Record frame pointer with kretprobe instance Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 36/40] arm64: kprobes: Make a frame pointer on __kretprobe_trampoline Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 37/40] arm64: Recover kretprobe modified return address in stacktrace Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 38/40] ARM: clang: Do not rely on lr register for stacktrace Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 39/40] ARM: kprobes: Make a frame pointer on __kretprobe_trampoline Steven Rostedt
2021-10-22 20:48 ` [for-next][PATCH 40/40] ARM: Recover kretprobe modified return address in stacktrace Steven Rostedt

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=20211022204844.089918832@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=zanussi@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.