[PATCH 05/17] perf: Add attribute to filter out user callchains

From: Jiri Olsa
Date: Wed May 02 2012 - 07:41:47 EST


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@xxxxxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
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 2e5f486..4be0de4 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -275,7 +275,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 b9206c4..5aebaea 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4138,8 +4138,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 ed8ab26..b18465b 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -121,7 +121,8 @@ DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)

/* 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.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/