perf: Generalize some arch callchain code

- Most archs use one callchain buffer per cpu, except x86 that needs
  to deal with NMIs. Provide a default perf_callchain_buffer()
  implementation that x86 overrides.

- Centralize all the kernel/user regs handling and invoke new arch
  handlers from there: perf_callchain_user() / perf_callchain_kernel()
  That avoid all the user_mode(), current->mm checks and so...

- Invert some parameters in perf_callchain_*() helpers: entry to the
  left, regs to the right, following the traditional (dst, src).

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Tested-by: Will Deacon <will.deacon@arm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: David Miller <davem@davemloft.net>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Borislav Petkov <bp@amd64.org>
This commit is contained in:
Frederic Weisbecker
2010-06-30 23:03:51 +02:00
parent 70791ce9ba
commit 56962b4449
7 changed files with 90 additions and 180 deletions

View File

@ -2937,13 +2937,49 @@ void perf_event_do_pending(void)
__perf_pending_run();
}
DEFINE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);
/*
* Callchain support -- arch specific
*/
__weak struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
__weak struct perf_callchain_entry *perf_callchain_buffer(void)
{
return NULL;
return &__get_cpu_var(perf_callchain_entry);
}
__weak void perf_callchain_kernel(struct perf_callchain_entry *entry,
struct pt_regs *regs)
{
}
__weak void perf_callchain_user(struct perf_callchain_entry *entry,
struct pt_regs *regs)
{
}
static struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
{
struct perf_callchain_entry *entry;
entry = perf_callchain_buffer();
if (!entry)
return NULL;
entry->nr = 0;
if (!user_mode(regs)) {
perf_callchain_kernel(entry, regs);
if (current->mm)
regs = task_pt_regs(current);
else
regs = NULL;
}
if (regs)
perf_callchain_user(entry, regs);
return entry;
}