aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-27 09:16:24 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-27 09:29:07 -0400
commit4cb93446c587d56e2a54f4f83113daba2c0b6dee (patch)
treea251b1d510831dc071eadbbbe3e38a85fe643365
parentc5dfd78eb79851e278b7973031b9ca363da87a7e (diff)
perf tools: Set the maximum allowed stack from /proc/sys/kernel/perf_event_max_stack
There is an upper limit to what tooling considers a valid callchain, and it was tied to the hardcoded value in the kernel, PERF_MAX_STACK_DEPTH (127), now that this can be tuned via a sysctl, make it read it and use that as the upper limit, falling back to PERF_MAX_STACK_DEPTH for kernels where this sysctl isn't present. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-yjqsd30nnkogvj5oyx9ghir9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-report.txt2
-rw-r--r--tools/perf/Documentation/perf-script.txt2
-rw-r--r--tools/perf/Documentation/perf-top.txt2
-rw-r--r--tools/perf/Documentation/perf-trace.txt2
-rw-r--r--tools/perf/builtin-report.c4
-rw-r--r--tools/perf/builtin-script.c4
-rw-r--r--tools/perf/builtin-top.c4
-rw-r--r--tools/perf/builtin-trace.c4
-rw-r--r--tools/perf/perf.c5
-rw-r--r--tools/perf/tests/hists_cumulate.c2
-rw-r--r--tools/perf/tests/hists_filter.c2
-rw-r--r--tools/perf/tests/hists_output.c2
-rw-r--r--tools/perf/util/machine.c6
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c2
-rw-r--r--tools/perf/util/util.c2
-rw-r--r--tools/perf/util/util.h1
16 files changed, 28 insertions, 18 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 496d42cdf02b..ebaf849e30ef 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -248,7 +248,7 @@ OPTIONS
248 Note that when using the --itrace option the synthesized callchain size 248 Note that when using the --itrace option the synthesized callchain size
249 will override this value if the synthesized callchain size is bigger. 249 will override this value if the synthesized callchain size is bigger.
250 250
251 Default: 127 251 Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
252 252
253-G:: 253-G::
254--inverted:: 254--inverted::
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 4fc44c75263f..a856a1095893 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -267,7 +267,7 @@ include::itrace.txt[]
267 Note that when using the --itrace option the synthesized callchain size 267 Note that when using the --itrace option the synthesized callchain size
268 will override this value if the synthesized callchain size is bigger. 268 will override this value if the synthesized callchain size is bigger.
269 269
270 Default: 127 270 Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
271 271
272--ns:: 272--ns::
273 Use 9 decimal places when displaying time (i.e. show the nanoseconds) 273 Use 9 decimal places when displaying time (i.e. show the nanoseconds)
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 19f046f027cd..91d638df3a6b 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -177,7 +177,7 @@ Default is to monitor all CPUS.
177 between information loss and faster processing especially for 177 between information loss and faster processing especially for
178 workloads that can have a very long callchain stack. 178 workloads that can have a very long callchain stack.
179 179
180 Default: 127 180 Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
181 181
182--ignore-callees=<regex>:: 182--ignore-callees=<regex>::
183 Ignore callees of the function(s) matching the given regex. 183 Ignore callees of the function(s) matching the given regex.
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index c075c002eaa4..6afe20121bc0 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -143,7 +143,7 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
143 Implies '--call-graph dwarf' when --call-graph not present on the 143 Implies '--call-graph dwarf' when --call-graph not present on the
144 command line, on systems where DWARF unwinding was built in. 144 command line, on systems where DWARF unwinding was built in.
145 145
146 Default: 127 146 Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
147 147
148--min-stack:: 148--min-stack::
149 Set the stack depth limit when parsing the callchain, anything 149 Set the stack depth limit when parsing the callchain, anything
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1d5be0bd426f..8d9b88af901d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -691,7 +691,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
691 .ordered_events = true, 691 .ordered_events = true,
692 .ordering_requires_timestamps = true, 692 .ordering_requires_timestamps = true,
693 }, 693 },
694 .max_stack = PERF_MAX_STACK_DEPTH, 694 .max_stack = sysctl_perf_event_max_stack,
695 .pretty_printing_style = "normal", 695 .pretty_printing_style = "normal",
696 .socket_filter = -1, 696 .socket_filter = -1,
697 }; 697 };
@@ -744,7 +744,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
744 OPT_INTEGER(0, "max-stack", &report.max_stack, 744 OPT_INTEGER(0, "max-stack", &report.max_stack,
745 "Set the maximum stack depth when parsing the callchain, " 745 "Set the maximum stack depth when parsing the callchain, "
746 "anything beyond the specified depth will be ignored. " 746 "anything beyond the specified depth will be ignored. "
747 "Default: " __stringify(PERF_MAX_STACK_DEPTH)), 747 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
748 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, 748 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
749 "alias for inverted call graph"), 749 "alias for inverted call graph"),
750 OPT_CALLBACK(0, "ignore-callees", NULL, "regex", 750 OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index f43b0c6f88f4..efca81679bb3 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2031,7 +2031,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2031 OPT_UINTEGER(0, "max-stack", &scripting_max_stack, 2031 OPT_UINTEGER(0, "max-stack", &scripting_max_stack,
2032 "Set the maximum stack depth when parsing the callchain, " 2032 "Set the maximum stack depth when parsing the callchain, "
2033 "anything beyond the specified depth will be ignored. " 2033 "anything beyond the specified depth will be ignored. "
2034 "Default: " __stringify(PERF_MAX_STACK_DEPTH)), 2034 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
2035 OPT_BOOLEAN('I', "show-info", &show_full_info, 2035 OPT_BOOLEAN('I', "show-info", &show_full_info,
2036 "display extended information from perf.data file"), 2036 "display extended information from perf.data file"),
2037 OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, 2037 OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
@@ -2067,6 +2067,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2067 NULL 2067 NULL
2068 }; 2068 };
2069 2069
2070 scripting_max_stack = sysctl_perf_event_max_stack;
2071
2070 setup_scripting(); 2072 setup_scripting();
2071 2073
2072 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage, 2074 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index c130a11d3a0d..da18517b1d40 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1103,7 +1103,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1103 }, 1103 },
1104 .proc_map_timeout = 500, 1104 .proc_map_timeout = 500,
1105 }, 1105 },
1106 .max_stack = PERF_MAX_STACK_DEPTH, 1106 .max_stack = sysctl_perf_event_max_stack,
1107 .sym_pcnt_filter = 5, 1107 .sym_pcnt_filter = 5,
1108 }; 1108 };
1109 struct record_opts *opts = &top.record_opts; 1109 struct record_opts *opts = &top.record_opts;
@@ -1171,7 +1171,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1171 "Accumulate callchains of children and show total overhead as well"), 1171 "Accumulate callchains of children and show total overhead as well"),
1172 OPT_INTEGER(0, "max-stack", &top.max_stack, 1172 OPT_INTEGER(0, "max-stack", &top.max_stack,
1173 "Set the maximum stack depth when parsing the callchain. " 1173 "Set the maximum stack depth when parsing the callchain. "
1174 "Default: " __stringify(PERF_MAX_STACK_DEPTH)), 1174 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
1175 OPT_CALLBACK(0, "ignore-callees", NULL, "regex", 1175 OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
1176 "ignore callees of these functions in call graphs", 1176 "ignore callees of these functions in call graphs",
1177 report_parse_ignore_callees_opt), 1177 report_parse_ignore_callees_opt),
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 48b00f042599..f4f3389c92c7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3106,7 +3106,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3106 OPT_UINTEGER(0, "max-stack", &trace.max_stack, 3106 OPT_UINTEGER(0, "max-stack", &trace.max_stack,
3107 "Set the maximum stack depth when parsing the callchain, " 3107 "Set the maximum stack depth when parsing the callchain, "
3108 "anything beyond the specified depth will be ignored. " 3108 "anything beyond the specified depth will be ignored. "
3109 "Default: " __stringify(PERF_MAX_STACK_DEPTH)), 3109 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
3110 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, 3110 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout,
3111 "per thread proc mmap processing timeout in ms"), 3111 "per thread proc mmap processing timeout in ms"),
3112 OPT_END() 3112 OPT_END()
@@ -3150,7 +3150,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3150 mmap_pages_user_set = false; 3150 mmap_pages_user_set = false;
3151 3151
3152 if (trace.max_stack == UINT_MAX) { 3152 if (trace.max_stack == UINT_MAX) {
3153 trace.max_stack = PERF_MAX_STACK_DEPTH; 3153 trace.max_stack = sysctl_perf_event_max_stack;
3154 max_stack_user_set = false; 3154 max_stack_user_set = false;
3155 } 3155 }
3156 3156
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 7b2df2b46525..83ffe7cd7330 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -17,6 +17,7 @@
17#include <subcmd/parse-options.h> 17#include <subcmd/parse-options.h>
18#include "util/bpf-loader.h" 18#include "util/bpf-loader.h"
19#include "util/debug.h" 19#include "util/debug.h"
20#include <api/fs/fs.h>
20#include <api/fs/tracing_path.h> 21#include <api/fs/tracing_path.h>
21#include <pthread.h> 22#include <pthread.h>
22#include <stdlib.h> 23#include <stdlib.h>
@@ -533,6 +534,7 @@ int main(int argc, const char **argv)
533{ 534{
534 const char *cmd; 535 const char *cmd;
535 char sbuf[STRERR_BUFSIZE]; 536 char sbuf[STRERR_BUFSIZE];
537 int value;
536 538
537 /* libsubcmd init */ 539 /* libsubcmd init */
538 exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT); 540 exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
@@ -542,6 +544,9 @@ int main(int argc, const char **argv)
542 page_size = sysconf(_SC_PAGE_SIZE); 544 page_size = sysconf(_SC_PAGE_SIZE);
543 cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); 545 cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
544 546
547 if (sysctl__read_int("kernel/perf_event_max_stack", &value) == 0)
548 sysctl_perf_event_max_stack = value;
549
545 cmd = extract_argv0_path(argv[0]); 550 cmd = extract_argv0_path(argv[0]);
546 if (!cmd) 551 if (!cmd)
547 cmd = "perf-help"; 552 cmd = "perf-help";
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index ed5aa9eaeb6c..4a2bbff9b1ee 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -101,7 +101,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
101 if (machine__resolve(machine, &al, &sample) < 0) 101 if (machine__resolve(machine, &al, &sample) < 0)
102 goto out; 102 goto out;
103 103
104 if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH, 104 if (hist_entry_iter__add(&iter, &al, sysctl_perf_event_max_stack,
105 NULL) < 0) { 105 NULL) < 0) {
106 addr_location__put(&al); 106 addr_location__put(&al);
107 goto out; 107 goto out;
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index b825d24f8186..e846f8c42013 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -81,7 +81,7 @@ static int add_hist_entries(struct perf_evlist *evlist,
81 81
82 al.socket = fake_samples[i].socket; 82 al.socket = fake_samples[i].socket;
83 if (hist_entry_iter__add(&iter, &al, 83 if (hist_entry_iter__add(&iter, &al,
84 PERF_MAX_STACK_DEPTH, NULL) < 0) { 84 sysctl_perf_event_max_stack, NULL) < 0) {
85 addr_location__put(&al); 85 addr_location__put(&al);
86 goto out; 86 goto out;
87 } 87 }
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index d3556fbe8c5c..7cd8738e842f 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -67,7 +67,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
67 if (machine__resolve(machine, &al, &sample) < 0) 67 if (machine__resolve(machine, &al, &sample) < 0)
68 goto out; 68 goto out;
69 69
70 if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH, 70 if (hist_entry_iter__add(&iter, &al, sysctl_perf_event_max_stack,
71 NULL) < 0) { 71 NULL) < 0) {
72 addr_location__put(&al); 72 addr_location__put(&al);
73 goto out; 73 goto out;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 656c1d7ee7d4..2cb95bbf9ea6 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1764,7 +1764,7 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
1764 */ 1764 */
1765 int mix_chain_nr = i + 1 + lbr_nr + 1; 1765 int mix_chain_nr = i + 1 + lbr_nr + 1;
1766 1766
1767 if (mix_chain_nr > PERF_MAX_STACK_DEPTH + PERF_MAX_BRANCH_DEPTH) { 1767 if (mix_chain_nr > (int)sysctl_perf_event_max_stack + PERF_MAX_BRANCH_DEPTH) {
1768 pr_warning("corrupted callchain. skipping...\n"); 1768 pr_warning("corrupted callchain. skipping...\n");
1769 return 0; 1769 return 0;
1770 } 1770 }
@@ -1825,7 +1825,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1825 * Based on DWARF debug information, some architectures skip 1825 * Based on DWARF debug information, some architectures skip
1826 * a callchain entry saved by the kernel. 1826 * a callchain entry saved by the kernel.
1827 */ 1827 */
1828 if (chain->nr < PERF_MAX_STACK_DEPTH) 1828 if (chain->nr < sysctl_perf_event_max_stack)
1829 skip_idx = arch_skip_callchain_idx(thread, chain); 1829 skip_idx = arch_skip_callchain_idx(thread, chain);
1830 1830
1831 /* 1831 /*
@@ -1886,7 +1886,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
1886 } 1886 }
1887 1887
1888check_calls: 1888check_calls:
1889 if (chain->nr > PERF_MAX_STACK_DEPTH && (int)chain->nr > max_stack) { 1889 if (chain->nr > sysctl_perf_event_max_stack && (int)chain->nr > max_stack) {
1890 pr_warning("corrupted callchain. skipping...\n"); 1890 pr_warning("corrupted callchain. skipping...\n");
1891 return 0; 1891 return 0;
1892 } 1892 }
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index ae1cebc307c5..62c7f6988e0e 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -265,7 +265,7 @@ static SV *perl_process_callchain(struct perf_sample *sample,
265 265
266 if (thread__resolve_callchain(al->thread, &callchain_cursor, evsel, 266 if (thread__resolve_callchain(al->thread, &callchain_cursor, evsel,
267 sample, NULL, NULL, 267 sample, NULL, NULL,
268 PERF_MAX_STACK_DEPTH) != 0) { 268 sysctl_perf_event_max_stack) != 0) {
269 pr_err("Failed to resolve callchain. Skipping\n"); 269 pr_err("Failed to resolve callchain. Skipping\n");
270 goto exit; 270 goto exit;
271 } 271 }
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 9473d46c00bb..619ba2061b62 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -33,6 +33,8 @@ struct callchain_param callchain_param = {
33unsigned int page_size; 33unsigned int page_size;
34int cacheline_size; 34int cacheline_size;
35 35
36unsigned int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH;
37
36bool test_attr__enabled; 38bool test_attr__enabled;
37 39
38bool perf_host = true; 40bool perf_host = true;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 26a924651e7b..88f607af1f47 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -267,6 +267,7 @@ void sighandler_dump_stack(int sig);
267 267
268extern unsigned int page_size; 268extern unsigned int page_size;
269extern int cacheline_size; 269extern int cacheline_size;
270extern unsigned int sysctl_perf_event_max_stack;
270 271
271struct parse_tag { 272struct parse_tag {
272 char tag; 273 char tag;