Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Fix usage of max_stack sysctl

We cannot limit processing stacks from the current value of the sysctl,
as we may be processing perf.data files, possibly from other machines.

Instead use the old PERF_MAX_STACK_DEPTH, the sysctl default, that can
be overriden using --max-stack or equivalent.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Fixes: 4cb93446c587 ("perf tools: Set the maximum allowed stack from /proc/sys/kernel/perf_event_max_stack")
Link: http://lkml.kernel.org/n/tip-eqeutsr7n7wy0c36z24ytvii@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+8 -11
+1 -1
tools/perf/Documentation/perf-report.txt
··· 248 248 Note that when using the --itrace option the synthesized callchain size 249 249 will override this value if the synthesized callchain size is bigger. 250 250 251 - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. 251 + Default: 127 252 252 253 253 -G:: 254 254 --inverted::
+1 -1
tools/perf/Documentation/perf-script.txt
··· 267 267 Note that when using the --itrace option the synthesized callchain size 268 268 will override this value if the synthesized callchain size is bigger. 269 269 270 - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. 270 + Default: 127 271 271 272 272 --ns:: 273 273 Use 9 decimal places when displaying time (i.e. show the nanoseconds)
+2 -1
tools/perf/Documentation/perf-trace.txt
··· 143 143 Implies '--call-graph dwarf' when --call-graph not present on the 144 144 command line, on systems where DWARF unwinding was built in. 145 145 146 - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. 146 + Default: /proc/sys/kernel/perf_event_max_stack when present for 147 + live sessions (without --input/-i), 127 otherwise. 147 148 148 149 --min-stack:: 149 150 Set the stack depth limit when parsing the callchain, anything
+1 -1
tools/perf/builtin-report.c
··· 691 691 .ordered_events = true, 692 692 .ordering_requires_timestamps = true, 693 693 }, 694 - .max_stack = sysctl_perf_event_max_stack, 694 + .max_stack = PERF_MAX_STACK_DEPTH, 695 695 .pretty_printing_style = "normal", 696 696 .socket_filter = -1, 697 697 };
-2
tools/perf/builtin-script.c
··· 2067 2067 NULL 2068 2068 }; 2069 2069 2070 - scripting_max_stack = sysctl_perf_event_max_stack; 2071 - 2072 2070 setup_scripting(); 2073 2071 2074 2072 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
+1 -1
tools/perf/builtin-trace.c
··· 2905 2905 mmap_pages_user_set = false; 2906 2906 2907 2907 if (trace.max_stack == UINT_MAX) { 2908 - trace.max_stack = sysctl_perf_event_max_stack; 2908 + trace.max_stack = input_name ? PERF_MAX_STACK_DEPTH : sysctl_perf_event_max_stack; 2909 2909 max_stack_user_set = false; 2910 2910 } 2911 2911
+1 -2
tools/perf/util/db-export.c
··· 298 298 */ 299 299 callchain_param.order = ORDER_CALLER; 300 300 err = thread__resolve_callchain(thread, &callchain_cursor, evsel, 301 - sample, NULL, NULL, 302 - sysctl_perf_event_max_stack); 301 + sample, NULL, NULL, PERF_MAX_STACK_DEPTH); 303 302 if (err) { 304 303 callchain_param.order = saved_order; 305 304 return NULL;
+1 -2
tools/perf/util/scripting-engines/trace-event-perl.c
··· 264 264 goto exit; 265 265 266 266 if (thread__resolve_callchain(al->thread, &callchain_cursor, evsel, 267 - sample, NULL, NULL, 268 - sysctl_perf_event_max_stack) != 0) { 267 + sample, NULL, NULL, scripting_max_stack) != 0) { 269 268 pr_err("Failed to resolve callchain. Skipping\n"); 270 269 goto exit; 271 270 }