perf: Factorize callchain context handling
authorFrederic Weisbecker <fweisbec@gmail.com>
Thu, 1 Jul 2010 00:31:21 +0000 (02:31 +0200)
committerFrederic Weisbecker <fweisbec@gmail.com>
Wed, 18 Aug 2010 23:32:11 +0000 (01:32 +0200)
Store the kernel and user contexts from the generic layer instead
of archs, this gathers some repetitive code.

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>
arch/arm/kernel/perf_event.c
arch/powerpc/kernel/perf_callchain.c
arch/sh/kernel/perf_callchain.c
arch/sparc/kernel/perf_event.c
arch/x86/kernel/cpu/perf_event.c
kernel/perf_event.c

index 0e3bbdb159278e632e2194a8d94ed5bdb9951ae3..64ca8c3ab94b9c0ebf08ba0791f3c4e24c1e663e 100644 (file)
@@ -3049,7 +3049,6 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
 {
        struct frame_tail *tail;
 
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
 
        tail = (struct frame_tail *)regs->ARM_fp - 1;
 
@@ -3076,7 +3075,6 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
 {
        struct stackframe fr;
 
-       perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
        fr.fp = regs->ARM_fp;
        fr.sp = regs->ARM_sp;
        fr.lr = regs->ARM_lr;
index f7a85ede840730afc01f61bc56f5ec4692b3caca..d05ae4204bbf3d3ddcc84266476b736a6790715c 100644 (file)
@@ -57,7 +57,6 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
 
        lr = regs->link;
        sp = regs->gpr[1];
-       perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
        perf_callchain_store(entry, regs->nip);
 
        if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
@@ -234,7 +233,6 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
        next_ip = regs->nip;
        lr = regs->link;
        sp = regs->gpr[1];
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
        perf_callchain_store(entry, next_ip);
 
        for (;;) {
@@ -435,7 +433,6 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
        next_ip = regs->nip;
        lr = regs->link;
        sp = regs->gpr[1];
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
        perf_callchain_store(entry, next_ip);
 
        while (entry->nr < PERF_MAX_STACK_DEPTH) {
index ef076a91292addd85a1819a3daa9a80eb1889182..d5ca1ef50fa9694a1942a8c304bd2c5aa69d9388 100644 (file)
@@ -47,7 +47,6 @@ static const struct stacktrace_ops callchain_ops = {
 void
 perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
 {
-       perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
        perf_callchain_store(entry, regs->pc);
 
        unwind_stack(NULL, regs, NULL, &callchain_ops, entry);
index 460162d74aba8bee703bf78b1715284515b8a52c..4bc4029385750c8b1999384f4e7702d72b54a9de 100644 (file)
@@ -1293,7 +1293,6 @@ void perf_callchain_kernel(struct perf_callchain_entry *entry,
 
        stack_trace_flush();
 
-       perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
        perf_callchain_store(entry, regs->tpc);
 
        ksp = regs->u_regs[UREG_I6];
@@ -1337,7 +1336,6 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
 {
        unsigned long ufp;
 
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
        perf_callchain_store(entry, regs->tpc);
 
        ufp = regs->u_regs[UREG_I6] + STACK_BIAS;
@@ -1360,7 +1358,6 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
 {
        unsigned long ufp;
 
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
        perf_callchain_store(entry, regs->tpc);
 
        ufp = regs->u_regs[UREG_I6] & 0xffffffffUL;
index 39f8421b86e62978d92b9643679c87c8a2d69a41..a3c922288cc063ace45b012da1bed1a86e6ed058 100644 (file)
@@ -1608,7 +1608,6 @@ static const struct stacktrace_ops backtrace_ops = {
 void
 perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
 {
-       perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
        perf_callchain_store(entry, regs->ip);
 
        dump_trace(NULL, regs, NULL, regs->bp, &backtrace_ops, entry);
@@ -1660,7 +1659,6 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
 
        fp = (void __user *)regs->bp;
 
-       perf_callchain_store(entry, PERF_CONTEXT_USER);
        perf_callchain_store(entry, regs->ip);
 
        if (perf_callchain_user32(regs, entry))
index 02efde6c87980cb657d03a90834f7dcbe7ed66bf..615d024894cf6c110452f8c2d425238acde529dc 100644 (file)
@@ -2969,6 +2969,7 @@ static struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
        entry->nr = 0;
 
        if (!user_mode(regs)) {
+               perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
                perf_callchain_kernel(entry, regs);
                if (current->mm)
                        regs = task_pt_regs(current);
@@ -2976,8 +2977,10 @@ static struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
                        regs = NULL;
        }
 
-       if (regs)
+       if (regs) {
+               perf_callchain_store(entry, PERF_CONTEXT_USER);
                perf_callchain_user(entry, regs);
+       }
 
        return entry;
 }