linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf: Disable user space dumps for function trace event
@ 2014-03-02 15:56 Jiri Olsa
  2014-03-02 15:56 ` [PATCH 1/3] perf: Disallow user space callchains " Jiri Olsa
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jiri Olsa @ 2014-03-02 15:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver,
	Steven Rostedt

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


Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
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(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] perf: Disallow user space callchains for function trace event
  2014-03-02 15:56 [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
@ 2014-03-02 15:56 ` Jiri Olsa
  2014-03-11 12:38   ` [tip:perf/core] perf: Disallow user-space callchains for function trace events tip-bot for Jiri Olsa
  2014-03-02 15:56 ` [PATCH 2/3] perf: Disallow user space stack dump for function trace event Jiri Olsa
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2014-03-02 15:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver,
	Steven Rostedt

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

Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_event_perf.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index e854f42..d5e01c3 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -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))
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] perf: Disallow user space stack dump for function trace event
  2014-03-02 15:56 [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
  2014-03-02 15:56 ` [PATCH 1/3] perf: Disallow user space callchains " Jiri Olsa
@ 2014-03-02 15:56 ` Jiri Olsa
  2014-03-02 16:59   ` Steven Rostedt
  2014-03-11 12:38   ` [tip:perf/core] perf: Disallow user-space stack dumps for function trace events tip-bot for Jiri Olsa
  2014-03-02 15:56 ` [PATCH 3/3] perf tools: Disable user space callchain/stack for function trace event Jiri Olsa
  2014-03-02 16:42 ` [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
  3 siblings, 2 replies; 9+ messages in thread
From: Jiri Olsa @ 2014-03-02 15:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver,
	Steven Rostedt

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

Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_event_perf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index d5e01c3..c894614 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -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 */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] perf tools: Disable user space callchain/stack for function trace event
  2014-03-02 15:56 [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
  2014-03-02 15:56 ` [PATCH 1/3] perf: Disallow user space callchains " Jiri Olsa
  2014-03-02 15:56 ` [PATCH 2/3] perf: Disallow user space stack dump for function trace event Jiri Olsa
@ 2014-03-02 15:56 ` Jiri Olsa
  2014-03-11 12:38   ` [tip:perf/core] perf tools: Disable user-space callchain/ stack dumps for function trace events tip-bot for Jiri Olsa
  2014-03-02 16:42 ` [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
  3 siblings, 1 reply; 9+ messages in thread
From: Jiri Olsa @ 2014-03-02 15:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver,
	Steven Rostedt

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

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 tools/perf/util/evsel.c | 41 ++++++++++++++++++++++++++++++-----------
 tools/perf/util/evsel.h | 18 ++++++++++++++++++
 2 files changed, 48 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index adc94dd..26b67b1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index f1b3256..0c9926c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] perf: Disable user space dumps for function trace event
  2014-03-02 15:56 [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
                   ` (2 preceding siblings ...)
  2014-03-02 15:56 ` [PATCH 3/3] perf tools: Disable user space callchain/stack for function trace event Jiri Olsa
@ 2014-03-02 16:42 ` Jiri Olsa
  3 siblings, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2014-03-02 16:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver,
	Steven Rostedt

On Sun, Mar 02, 2014 at 04:56:37PM +0100, Jiri Olsa wrote:
> 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:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/function_trace_fixies_1

jirka

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] perf: Disallow user space stack dump for function trace event
  2014-03-02 15:56 ` [PATCH 2/3] perf: Disallow user space stack dump for function trace event Jiri Olsa
@ 2014-03-02 16:59   ` Steven Rostedt
  2014-03-11 12:38   ` [tip:perf/core] perf: Disallow user-space stack dumps for function trace events tip-bot for Jiri Olsa
  1 sibling, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2014-03-02 16:59 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, H. Peter Anvin, Vince Weaver

On Sun,  2 Mar 2014 16:56:39 +0100
Jiri Olsa <jolsa@redhat.com> 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).

Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1402211521040.6395@vincent-weaver-1.um.maine.edu

-- Steve

> 
> Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Vince Weaver <vincent.weaver@maine.edu>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> ---
>  kernel/trace/trace_event_perf.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
> index d5e01c3..c894614 100644
> --- a/kernel/trace/trace_event_perf.c
> +++ b/kernel/trace/trace_event_perf.c
> @@ -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 */


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf: Disallow user-space callchains for function trace events
  2014-03-02 15:56 ` [PATCH 1/3] perf: Disallow user space callchains " Jiri Olsa
@ 2014-03-11 12:38   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-03-11 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, hpa, mingo, a.p.zijlstra, peterz, acme,
	jolsa, vincent.weaver, rostedt, tglx

Commit-ID:  cfa77bc4af2c75c0781ee76cde2dd104c6c8e2b7
Gitweb:     http://git.kernel.org/tip/cfa77bc4af2c75c0781ee76cde2dd104c6c8e2b7
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Sun, 2 Mar 2014 16:56:38 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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

Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1393775800-13524-2-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/trace/trace_event_perf.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index e854f42..d5e01c3 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -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))

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf: Disallow user-space stack dumps for function trace events
  2014-03-02 15:56 ` [PATCH 2/3] perf: Disallow user space stack dump for function trace event Jiri Olsa
  2014-03-02 16:59   ` Steven Rostedt
@ 2014-03-11 12:38   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-03-11 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, hpa, mingo, a.p.zijlstra, peterz, acme,
	jolsa, vincent.weaver, rostedt, tglx

Commit-ID:  63c45f4ba533e9749da16298db53e491c25d805b
Gitweb:     http://git.kernel.org/tip/63c45f4ba533e9749da16298db53e491c25d805b
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Sun, 2 Mar 2014 16:56:39 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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

Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1393775800-13524-3-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/trace/trace_event_perf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index d5e01c3..c894614 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -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 */

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf tools: Disable user-space callchain/ stack dumps for function trace events
  2014-03-02 15:56 ` [PATCH 3/3] perf tools: Disable user space callchain/stack for function trace event Jiri Olsa
@ 2014-03-11 12:38   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-03-11 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, hpa, mingo, peterz, acme, jolsa,
	vincent.weaver, rostedt, tglx

Commit-ID:  6bedfab68666afac1b03f8d62ee037c6ab82fbc5
Gitweb:     http://git.kernel.org/tip/6bedfab68666afac1b03f8d62ee037c6ab82fbc5
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Sun, 2 Mar 2014 16:56:40 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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.
  ...

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1393775800-13524-4-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 tools/perf/util/evsel.c | 41 ++++++++++++++++++++++++++++++-----------
 tools/perf/util/evsel.h | 18 ++++++++++++++++++
 2 files changed, 48 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index adc94dd..26b67b1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index f1b3256..0c9926c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -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;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-11 12:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-02 15:56 [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa
2014-03-02 15:56 ` [PATCH 1/3] perf: Disallow user space callchains " Jiri Olsa
2014-03-11 12:38   ` [tip:perf/core] perf: Disallow user-space callchains for function trace events tip-bot for Jiri Olsa
2014-03-02 15:56 ` [PATCH 2/3] perf: Disallow user space stack dump for function trace event Jiri Olsa
2014-03-02 16:59   ` Steven Rostedt
2014-03-11 12:38   ` [tip:perf/core] perf: Disallow user-space stack dumps for function trace events tip-bot for Jiri Olsa
2014-03-02 15:56 ` [PATCH 3/3] perf tools: Disable user space callchain/stack for function trace event Jiri Olsa
2014-03-11 12:38   ` [tip:perf/core] perf tools: Disable user-space callchain/ stack dumps for function trace events tip-bot for Jiri Olsa
2014-03-02 16:42 ` [PATCH 0/3] perf: Disable user space dumps for function trace event Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).