lkml.org 
[lkml]   [2012]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/15] perf: Add attribute to filter out user callchains
Date
Add the new exclude_user_callchain attribute to filter out
frame pointer based user callchains. This is something we
want to select when we use the dwarf cfi callchain mode,
because frame pointer based user callchains are useless in
this mode.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
include/linux/perf_event.h | 4 +++-
kernel/events/callchain.c | 4 ++--
kernel/events/core.c | 3 ++-
kernel/events/internal.h | 3 ++-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 5852b4c..785a67a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -255,7 +255,9 @@ struct perf_event_attr {
exclude_host : 1, /* don't count in host */
exclude_guest : 1, /* don't count in guest */

- __reserved_1 : 43;
+ exclude_user_callchain : 1, /* only record kernel callchains */
+
+ __reserved_1 : 42;

union {
__u32 wakeup_events; /* wakeup every n events */
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 6581a04..884e997 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -153,7 +153,7 @@ put_callchain_entry(int rctx)
put_recursion_context(__get_cpu_var(callchain_recursion), rctx);
}

-struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
+struct perf_callchain_entry *perf_callchain(struct pt_regs *regs, int user)
{
int rctx;
struct perf_callchain_entry *entry;
@@ -177,7 +177,7 @@ struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
regs = NULL;
}

- if (regs) {
+ if (user && regs) {
perf_callchain_store(entry, PERF_CONTEXT_USER);
perf_callchain_user(entry, regs);
}
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 0468987..2df82df 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4117,8 +4117,9 @@ void perf_prepare_sample(struct perf_event_header *header,

if (sample_type & PERF_SAMPLE_CALLCHAIN) {
int size = 1;
+ int user = !event->attr.exclude_user_callchain;

- data->callchain = perf_callchain(regs);
+ data->callchain = perf_callchain(regs, user);

if (data->callchain)
size += data->callchain->nr;
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index 1ae5270..b3ade19 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -115,7 +115,8 @@ DEFINE_PERF_OUTPUT_COPY(__output_copy, memcpy_common)
DEFINE_PERF_OUTPUT_COPY(__output_copy_user_gup, copy_from_user_gup)

/* Callchain handling */
-extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);
+extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs,
+ int user);
extern int get_callchain_buffers(void);
extern void put_callchain_buffers(void);

--
1.7.1


\
 
 \ /
  Last update: 2012-03-28 14:41    [from the cache]
©2003-2011 Jasper Spaans