perf tools: Fix usage of max_stack sysctl
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 19 May 2016 14:34:06 +0000 (11:34 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 20 May 2016 14:43:56 +0000 (11:43 -0300)
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>
tools/perf/Documentation/perf-report.txt
tools/perf/Documentation/perf-script.txt
tools/perf/Documentation/perf-trace.txt
tools/perf/builtin-report.c
tools/perf/builtin-script.c
tools/perf/builtin-trace.c
tools/perf/util/db-export.c
tools/perf/util/scripting-engines/trace-event-perl.c

index ebaf849e30efd15bce04edb37252fb4aed66441f..496d42cdf02b153593d22abc28366fd16f6090ce 100644 (file)
@@ -248,7 +248,7 @@ OPTIONS
        Note that when using the --itrace option the synthesized callchain size
        will override this value if the synthesized callchain size is bigger.
 
-       Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
+       Default: 127
 
 -G::
 --inverted::
index a856a1095893cab0a0d3f7fdff39820090c99422..4fc44c75263fdb803315394e8353d77063f69e6a 100644 (file)
@@ -267,7 +267,7 @@ include::itrace.txt[]
         Note that when using the --itrace option the synthesized callchain size
         will override this value if the synthesized callchain size is bigger.
 
-        Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
+        Default: 127
 
 --ns::
        Use 9 decimal places when displaying time (i.e. show the nanoseconds)
index 6afe20121bc06d671931a3d22d6eeca2ca35c0a6..1ab0782369b1faa9bbe6758ed0e3439c414eb7e1 100644 (file)
@@ -143,7 +143,8 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
         Implies '--call-graph dwarf' when --call-graph not present on the
         command line, on systems where DWARF unwinding was built in.
 
-        Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
+        Default: /proc/sys/kernel/perf_event_max_stack when present for
+                 live sessions (without --input/-i), 127 otherwise.
 
 --min-stack::
         Set the stack depth limit when parsing the callchain, anything
index 87d40e3c4078ee99740e4563ebff885792ec9aff..9bc71c6a54f657b72dbafec38b45e073eca50b23 100644 (file)
@@ -691,7 +691,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
                        .ordered_events  = true,
                        .ordering_requires_timestamps = true,
                },
-               .max_stack               = sysctl_perf_event_max_stack,
+               .max_stack               = PERF_MAX_STACK_DEPTH,
                .pretty_printing_style   = "normal",
                .socket_filter           = -1,
        };
index efca81679bb314624b88d024c52b63f2fc54729c..0a83f4bacc7cb03ebbda25fa350442b76b150cc4 100644 (file)
@@ -2067,8 +2067,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
                NULL
        };
 
-       scripting_max_stack = sysctl_perf_event_max_stack;
-
        setup_scripting();
 
        argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
index a2f3aa09c7f43a6cb92185721ebc011d2b6dc6bf..7401de71d0974f53e923a42d85514046bd702d75 100644 (file)
@@ -2905,7 +2905,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
                mmap_pages_user_set = false;
 
        if (trace.max_stack == UINT_MAX) {
-               trace.max_stack = sysctl_perf_event_max_stack;
+               trace.max_stack = input_name ? PERF_MAX_STACK_DEPTH : sysctl_perf_event_max_stack;
                max_stack_user_set = false;
        }
 
index 8d96c80cc67e629f0ef576ae24c1266e468df91f..c9a6dc173e74eb77f56673c6a609a5a92c788498 100644 (file)
@@ -298,8 +298,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
         */
        callchain_param.order = ORDER_CALLER;
        err = thread__resolve_callchain(thread, &callchain_cursor, evsel,
-                                       sample, NULL, NULL,
-                                       sysctl_perf_event_max_stack);
+                                       sample, NULL, NULL, PERF_MAX_STACK_DEPTH);
        if (err) {
                callchain_param.order = saved_order;
                return NULL;
index 62c7f6988e0e584cb16f6deab30a84b3b8672971..5d1eb1ccd96c3e0cf73449c97aaee9246d1f9619 100644 (file)
@@ -264,8 +264,7 @@ static SV *perl_process_callchain(struct perf_sample *sample,
                goto exit;
 
        if (thread__resolve_callchain(al->thread, &callchain_cursor, evsel,
-                                     sample, NULL, NULL,
-                                     sysctl_perf_event_max_stack) != 0) {
+                                     sample, NULL, NULL, scripting_max_stack) != 0) {
                pr_err("Failed to resolve callchain. Skipping\n");
                goto exit;
        }