perf: Disable user space dumps for function trace event
Subsystems (2)
cover perf: Disable user space dumps for function trace event
hi,
recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
Disabling user space callchain and stack dump for
function trace event. Plus updating the perf tool
to keep up with those changes.
Reachable here:
thanks,
jirka
---
Jiri Olsa (3):
perf: Disallow user space callchains for function trace event
perf: Disallow user space stack dump for function trace event perf tools: Disable user space callchain/stack for function trace event
kernel/trace/trace_event_perf.c | 22 +++++++++++++++++++--- tools/perf/util/evsel.c | 41 ++++++++++++++++++++++++++++++----------- tools/perf/util/evsel.h | 18 ++++++++++++++++++ 3 files changed, 67 insertions(+), 14 deletions(-)
PATCH 1/3 perf: Disallow user space callchains for function trace event
Disabling user callchains for function trace event.
Recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
--- kernel/trace/trace_event_perf.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace_event_perf.c +12 -3
@@ -31,9 +31,18 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event, }/* The ftrace function trace is allowed only for root. */ -if (ftrace_event_is_function (tp_event) && -perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) -return -EPERM ; +if (ftrace_event_is_function (tp_event)) { +if (perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) +return -EPERM ; + +/* +* We don't allow user space callchains for function trace +* event, due to issues with page faults while tracing page +* fault handler and its overall trickiness nature. +*/ +if (!p_event->attr.exclude_callchain_user) +return -EINVAL ; + }/* No tracing, just counting, so no obvious leak */ if (!(p_event->attr.sample_type &PERF_SAMPLE_RAW ))
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Disallow user-space callchains for function trace events
perf: Disallow user-space callchains for function trace events
Commit-ID: cfa77bc4af2c75c0781ee76cde2dd104c6c8e2b7 Gitweb: http://git.kernel.org/tip/cfa77bc4af2c75c0781ee76cde2dd104c6c8e2b7 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 2 Mar 2014 16:56:38 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Mar 2014 11:57:57 +0100
perf: Disallow user-space callchains for function trace events
Recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
--- kernel/trace/trace_event_perf.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace_event_perf.c +12 -3
@@ -31,9 +31,18 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event, }/* The ftrace function trace is allowed only for root. */ -if (ftrace_event_is_function (tp_event) && -perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) -return -EPERM ; +if (ftrace_event_is_function (tp_event)) { +if (perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN )) +return -EPERM ; + +/* +* We don't allow user space callchains for function trace +* event, due to issues with page faults while tracing page +* fault handler and its overall trickiness nature. +*/ +if (!p_event->attr.exclude_callchain_user) +return -EINVAL ; + }/* No tracing, just counting, so no obvious leak */ if (!(p_event->attr.sample_type &PERF_SAMPLE_RAW ))
PATCH 2/3 perf: Disallow user space stack dump for function trace event
In reply to Jiri OlsaDisabling user space stack dump for function trace event.
Recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
The user space stack dump is just another source of the this issue.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
--- kernel/trace/trace_event_perf.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/trace/trace_event_perf.c +7 -0
@@ -42,6 +42,13 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,*/ if (!p_event->attr.exclude_callchain_user)return -EINVAL ; + +/* +* Same reason to disable user stack dump as for user space +* callchains above. +*/ +if (p_event->attr.sample_type &PERF_SAMPLE_STACK_USER ) +return -EINVAL ; }/* No tracing, just counting, so no obvious leak */
Signature · 1 line
1.8.3.1
Steven Rostedt
maintainerRe: [PATCH 2/3] perf: Disallow user space stack dump for function trace event
Quoted 11 lines · On Sun, 2 Mar 2014 16:56:39 +0100 Jiri Olsa <[email protected]> wrote:
Disabling user space stack dump for function trace event.
Recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
The user space stack dump is just another source of the this issue.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
For Linux git change logs, it's more preferable to use the kernel.org link (it may go to the same place, but at least kernel.org has more control of where it goes in the future).
-- Steve
Quoted 32 lines
Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Jiri Olsa <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Vince Weaver <[email protected]>Cc Steven Rostedt <[email protected]>--- kernel/trace/trace_event_perf.c | 7 +++++++ 1 file changed, 7 insertions(+)kernel/trace/trace_event_perf.c +7
-0@@ -42,6 +42,13 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,*/ if (!p_event->attr.exclude_callchain_user)return -EINVAL ; + +/* +* Same reason to disable user stack dump as for user space +* callchains above. +*/ +if (p_event->attr.sample_type &PERF_SAMPLE_STACK_USER ) +return -EINVAL ; }/* No tracing, just counting, so no obvious leak */
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Disallow user-space stack dumps for function trace events
In reply to Jiri Olsaperf: Disallow user-space stack dumps for function trace events
Commit-ID: 63c45f4ba533e9749da16298db53e491c25d805b Gitweb: http://git.kernel.org/tip/63c45f4ba533e9749da16298db53e491c25d805b Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 2 Mar 2014 16:56:39 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Mar 2014 11:57:58 +0100
perf: Disallow user-space stack dumps for function trace events
Recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
The user space stack dump is just another source of the this issue.
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
--- kernel/trace/trace_event_perf.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/trace/trace_event_perf.c +7 -0
@@ -42,6 +42,13 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,*/ if (!p_event->attr.exclude_callchain_user)return -EINVAL ; + +/* +* Same reason to disable user stack dump as for user space +* callchains above. +*/ +if (p_event->attr.sample_type &PERF_SAMPLE_STACK_USER ) +return -EINVAL ; }/* No tracing, just counting, so no obvious leak */
PATCH 3/3 perf tools: Disable user space callchain/stack for function trace event
In reply to Jiri OlsaUser space callchains and user space stack dump were disabled for function trace event. Mailing list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
Catching up with perf and disabling user space callchains and DWARF unwind (uses user stack dump) for function trace event.
Adding following warnings when callchains are used for function trace event:
# perf record -g -e ftrace:function ... Disabling user space callchains for function trace event. ...
# ./perf record --call-graph=dwarf -e ftrace:function ... Cannot use DWARF unwind for function trace event, falling back to framepointers. Disabling user space callchains for function trace event. ...
--- tools/perf/util/evsel.c | 41 ++++++++++++++++++++++++++++++----------- tools/perf/util/evsel.h | 18 ++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-)
tools/perf/util/evsel.c +30 -11
@@ -500,6 +500,34 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)return ret; } +static void +perf_evsel__config_callgraph (struct perf_evsel *evsel, +struct record_opts *opts) +{ +bool function =perf_evsel__is_function_event (evsel); +struct perf_event_attr *attr = &evsel->attr; + +perf_evsel__set_sample_bit (evsel,CALLCHAIN ); + +if (opts->call_graph ==CALLCHAIN_DWARF ) { +if (!function) { +perf_evsel__set_sample_bit (evsel,REGS_USER ); +perf_evsel__set_sample_bit (evsel,STACK_USER ); + attr->sample_regs_user =PERF_REGS_MASK ; + attr->sample_stack_user = opts->stack_dump_size; + attr->exclude_callchain_user =1 ; + }else { +pr_info ("Cannot use DWARF unwind for function trace event," +" falling back to framepointers.\n" ); + } + } + +if (function) { +pr_info ("Disabling user space callchains for function trace event.\n" ); + attr->exclude_callchain_user =1 ; + } +} +/* * The enable_on_exec/disabled value strategy: *
@@ -595,17 +623,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->mmap_data = track; } -if (opts->call_graph_enabled) { -perf_evsel__set_sample_bit (evsel,CALLCHAIN ); - -if (opts->call_graph ==CALLCHAIN_DWARF ) { -perf_evsel__set_sample_bit (evsel,REGS_USER ); -perf_evsel__set_sample_bit (evsel,STACK_USER ); - attr->sample_regs_user =PERF_REGS_MASK ; - attr->sample_stack_user = opts->stack_dump_size; - attr->exclude_callchain_user =1 ; - } - } +if (opts->call_graph_enabled) +perf_evsel__config_callgraph (evsel, opts);if (target__has_cpu (&opts->target))perf_evsel__set_sample_bit (evsel,CPU );
tools/perf/util/evsel.h +18 -0
@@ -315,6 +315,24 @@ static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel)return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; } +/** +* perf_evsel__is_function_event - Return whether given evsel is a function +* trace event +* +* @evsel - evsel selector to be tested +* +* Return %true if event is function trace event +*/ +static inline bool perf_evsel__is_function_event (struct perf_evsel *evsel) +{ +#define FUNCTION_EVENT "ftrace:function" + +return evsel->name && + !strncmp (FUNCTION_EVENT , evsel->name,sizeof (FUNCTION_EVENT )); + +#undef FUNCTION_EVENT +} +struct perf_attr_details {bool freq;bool verbose;
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Disable user-space callchain/ stack dumps for function trace events
perf tools: Disable user-space callchain/stack dumps for function trace events
Commit-ID: 6bedfab68666afac1b03f8d62ee037c6ab82fbc5 Gitweb: http://git.kernel.org/tip/6bedfab68666afac1b03f8d62ee037c6ab82fbc5 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 2 Mar 2014 16:56:40 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Mar 2014 11:57:59 +0100
perf tools: Disable user-space callchain/stack dumps for function trace events
User space callchains and user space stack dump were disabled for function trace event. Mailing list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2
Catching up with perf and disabling user space callchains and DWARF unwind (uses user stack dump) for function trace event.
Adding following warnings when callchains are used for function trace event:
# perf record -g -e ftrace:function ... Disabling user space callchains for function trace event. ...
# ./perf record --call-graph=dwarf -e ftrace:function ... Cannot use DWARF unwind for function trace event, falling back to framepointers. Disabling user space callchains for function trace event. ...
--- tools/perf/util/evsel.c | 41 ++++++++++++++++++++++++++++++----------- tools/perf/util/evsel.h | 18 ++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-)
tools/perf/util/evsel.c +30 -11
@@ -500,6 +500,34 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)return ret; } +static void +perf_evsel__config_callgraph (struct perf_evsel *evsel, +struct record_opts *opts) +{ +bool function =perf_evsel__is_function_event (evsel); +struct perf_event_attr *attr = &evsel->attr; + +perf_evsel__set_sample_bit (evsel,CALLCHAIN ); + +if (opts->call_graph ==CALLCHAIN_DWARF ) { +if (!function) { +perf_evsel__set_sample_bit (evsel,REGS_USER ); +perf_evsel__set_sample_bit (evsel,STACK_USER ); + attr->sample_regs_user =PERF_REGS_MASK ; + attr->sample_stack_user = opts->stack_dump_size; + attr->exclude_callchain_user =1 ; + }else { +pr_info ("Cannot use DWARF unwind for function trace event," +" falling back to framepointers.\n" ); + } + } + +if (function) { +pr_info ("Disabling user space callchains for function trace event.\n" ); + attr->exclude_callchain_user =1 ; + } +} +/* * The enable_on_exec/disabled value strategy: *
@@ -595,17 +623,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->mmap_data = track; } -if (opts->call_graph_enabled) { -perf_evsel__set_sample_bit (evsel,CALLCHAIN ); - -if (opts->call_graph ==CALLCHAIN_DWARF ) { -perf_evsel__set_sample_bit (evsel,REGS_USER ); -perf_evsel__set_sample_bit (evsel,STACK_USER ); - attr->sample_regs_user =PERF_REGS_MASK ; - attr->sample_stack_user = opts->stack_dump_size; - attr->exclude_callchain_user =1 ; - } - } +if (opts->call_graph_enabled) +perf_evsel__config_callgraph (evsel, opts);if (target__has_cpu (&opts->target))perf_evsel__set_sample_bit (evsel,CPU );
tools/perf/util/evsel.h +18 -0
@@ -315,6 +315,24 @@ static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel)return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; } +/** +* perf_evsel__is_function_event - Return whether given evsel is a function +* trace event +* +* @evsel - evsel selector to be tested +* +* Return %true if event is function trace event +*/ +static inline bool perf_evsel__is_function_event (struct perf_evsel *evsel) +{ +#define FUNCTION_EVENT "ftrace:function" + +return evsel->name && + !strncmp (FUNCTION_EVENT , evsel->name,sizeof (FUNCTION_EVENT )); + +#undef FUNCTION_EVENT +} +struct perf_attr_details {bool freq;bool verbose;
Quoted 5 lines · Jiri Olsa
hi,
recent issues with user space callchains processing within page fault handler tracing showed as Peter said 'there's just too much fail surface'.
Quoted 8 lines
Related list discussions:
http://marc.info/?t=139302086500001&r=1&w=2
http://marc.info/?t=139301437300003&r=1&w=2Disabling user space callchain and stack dump for function trace event. Plus updating the perf tool to keep up with those changes.
Reachable here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/function_trace_fixies_1
jirka