Skip to content

Commit fe17608

Browse files
committed
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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Brendan Gregg <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: He Kuang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Milian Wolff <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: Wang Nan <[email protected]> Cc: Zefan Li <[email protected]> Fixes: 4cb9344 ("perf tools: Set the maximum allowed stack from /proc/sys/kernel/perf_event_max_stack") Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent bf8bddb commit fe17608

File tree

8 files changed

+8
-11
lines changed

8 files changed

+8
-11
lines changed

tools/perf/Documentation/perf-report.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ OPTIONS
248248
Note that when using the --itrace option the synthesized callchain size
249249
will override this value if the synthesized callchain size is bigger.
250250

251-
Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
251+
Default: 127
252252

253253
-G::
254254
--inverted::

tools/perf/Documentation/perf-script.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ include::itrace.txt[]
267267
Note that when using the --itrace option the synthesized callchain size
268268
will override this value if the synthesized callchain size is bigger.
269269

270-
Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
270+
Default: 127
271271

272272
--ns::
273273
Use 9 decimal places when displaying time (i.e. show the nanoseconds)

tools/perf/Documentation/perf-trace.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
143143
Implies '--call-graph dwarf' when --call-graph not present on the
144144
command line, on systems where DWARF unwinding was built in.
145145

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.
147148

148149
--min-stack::
149150
Set the stack depth limit when parsing the callchain, anything

tools/perf/builtin-report.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
691691
.ordered_events = true,
692692
.ordering_requires_timestamps = true,
693693
},
694-
.max_stack = sysctl_perf_event_max_stack,
694+
.max_stack = PERF_MAX_STACK_DEPTH,
695695
.pretty_printing_style = "normal",
696696
.socket_filter = -1,
697697
};

tools/perf/builtin-script.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,8 +2067,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
20672067
NULL
20682068
};
20692069

2070-
scripting_max_stack = sysctl_perf_event_max_stack;
2071-
20722070
setup_scripting();
20732071

20742072
argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,

tools/perf/builtin-trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
29052905
mmap_pages_user_set = false;
29062906

29072907
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;
29092909
max_stack_user_set = false;
29102910
}
29112911

tools/perf/util/db-export.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
298298
*/
299299
callchain_param.order = ORDER_CALLER;
300300
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);
303302
if (err) {
304303
callchain_param.order = saved_order;
305304
return NULL;

tools/perf/util/scripting-engines/trace-event-perl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ static SV *perl_process_callchain(struct perf_sample *sample,
264264
goto exit;
265265

266266
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) {
269268
pr_err("Failed to resolve callchain. Skipping\n");
270269
goto exit;
271270
}

0 commit comments

Comments
 (0)