[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1448566489-25922-3-git-send-email-jolsa@kernel.org>
Date: Thu, 26 Nov 2015 20:34:48 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: [PATCH 2/3] perf: Move exclude_kernel tracepoint check to init event
We suppress events with attr::exclude_kernel set when
the event is generated, so following capture will
give no warning and produce no data:
$ sudo perf record -e sched:sched_switch:u ls
$ sudo /perf script | wc -l
0
Checking the attr::exclude_kernel at the event init
time and failing right away:
$ sudo perf record -e sched:sched_switch:u ls
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (sched:sched_switch).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
kernel/events/core.c | 5 -----
kernel/trace/trace_event_perf.c | 15 +++++++++++++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5854fcf7f05a..9fb9d5ef6825 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6938,11 +6938,6 @@ static int perf_tp_event_match(struct perf_event *event,
{
if (event->hw.state & PERF_HES_STOPPED)
return 0;
- /*
- * All tracepoints are from kernel-space.
- */
- if (event->attr.exclude_kernel)
- return 0;
if (!perf_tp_filter_match(event, data))
return 0;
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index c41463af3298..637268855296 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -182,11 +182,26 @@ static void perf_trace_event_close(struct perf_event *p_event)
tp_event->class->reg(tp_event, TRACE_REG_PERF_CLOSE, p_event);
}
+static int perf_trace_event_attr(struct perf_event *event)
+{
+ /*
+ * All tracepoints are from kernel-space.
+ */
+ if (event->attr.exclude_kernel)
+ return -EINVAL;
+
+ return 0;
+}
+
static int perf_trace_event_init(struct trace_event_call *tp_event,
struct perf_event *p_event)
{
int ret;
+ ret = perf_trace_event_attr(p_event);
+ if (ret)
+ return ret;
+
ret = perf_trace_event_perm(tp_event, p_event);
if (ret)
return ret;
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists