aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/perf_callchain.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2010-06-29 13:34:05 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-08-18 19:30:11 -0400
commit70791ce9ba68a5921c9905ef05d23f62a90bc10c (patch)
tree9711ff02cb910e1d8709c09512dbe7e94224bdd8 /arch/powerpc/kernel/perf_callchain.c
parentc1a65932fd7216fdc9a0db8bbffe1d47842f862c (diff)
perf: Generalize callchain_store()
callchain_store() is the same on every archs, inline it in perf_event.h and rename it to perf_callchain_store() to avoid any collision. This removes 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>
Diffstat (limited to 'arch/powerpc/kernel/perf_callchain.c')
-rw-r--r--arch/powerpc/kernel/perf_callchain.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/arch/powerpc/kernel/perf_callchain.c b/arch/powerpc/kernel/perf_callchain.c
index 95ad9dad298e..a286c2e5a3ea 100644
--- a/arch/powerpc/kernel/perf_callchain.c
+++ b/arch/powerpc/kernel/perf_callchain.c
@@ -23,18 +23,6 @@
23#include "ppc32.h" 23#include "ppc32.h"
24#endif 24#endif
25 25
26/*
27 * Store another value in a callchain_entry.
28 */
29static inline void callchain_store(struct perf_callchain_entry *entry, u64 ip)
30{
31 unsigned int nr = entry->nr;
32
33 if (nr < PERF_MAX_STACK_DEPTH) {
34 entry->ip[nr] = ip;
35 entry->nr = nr + 1;
36 }
37}
38 26
39/* 27/*
40 * Is sp valid as the address of the next kernel stack frame after prev_sp? 28 * Is sp valid as the address of the next kernel stack frame after prev_sp?
@@ -69,8 +57,8 @@ static void perf_callchain_kernel(struct pt_regs *regs,
69 57
70 lr = regs->link; 58 lr = regs->link;
71 sp = regs->gpr[1]; 59 sp = regs->gpr[1];
72 callchain_store(entry, PERF_CONTEXT_KERNEL); 60 perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
73 callchain_store(entry, regs->nip); 61 perf_callchain_store(entry, regs->nip);
74 62
75 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD)) 63 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
76 return; 64 return;
@@ -89,7 +77,7 @@ static void perf_callchain_kernel(struct pt_regs *regs,
89 next_ip = regs->nip; 77 next_ip = regs->nip;
90 lr = regs->link; 78 lr = regs->link;
91 level = 0; 79 level = 0;
92 callchain_store(entry, PERF_CONTEXT_KERNEL); 80 perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
93 81
94 } else { 82 } else {
95 if (level == 0) 83 if (level == 0)
@@ -111,7 +99,7 @@ static void perf_callchain_kernel(struct pt_regs *regs,
111 ++level; 99 ++level;
112 } 100 }
113 101
114 callchain_store(entry, next_ip); 102 perf_callchain_store(entry, next_ip);
115 if (!valid_next_sp(next_sp, sp)) 103 if (!valid_next_sp(next_sp, sp))
116 return; 104 return;
117 sp = next_sp; 105 sp = next_sp;
@@ -246,8 +234,8 @@ static void perf_callchain_user_64(struct pt_regs *regs,
246 next_ip = regs->nip; 234 next_ip = regs->nip;
247 lr = regs->link; 235 lr = regs->link;
248 sp = regs->gpr[1]; 236 sp = regs->gpr[1];
249 callchain_store(entry, PERF_CONTEXT_USER); 237 perf_callchain_store(entry, PERF_CONTEXT_USER);
250 callchain_store(entry, next_ip); 238 perf_callchain_store(entry, next_ip);
251 239
252 for (;;) { 240 for (;;) {
253 fp = (unsigned long __user *) sp; 241 fp = (unsigned long __user *) sp;
@@ -276,14 +264,14 @@ static void perf_callchain_user_64(struct pt_regs *regs,
276 read_user_stack_64(&uregs[PT_R1], &sp)) 264 read_user_stack_64(&uregs[PT_R1], &sp))
277 return; 265 return;
278 level = 0; 266 level = 0;
279 callchain_store(entry, PERF_CONTEXT_USER); 267 perf_callchain_store(entry, PERF_CONTEXT_USER);
280 callchain_store(entry, next_ip); 268 perf_callchain_store(entry, next_ip);
281 continue; 269 continue;
282 } 270 }
283 271
284 if (level == 0) 272 if (level == 0)
285 next_ip = lr; 273 next_ip = lr;
286 callchain_store(entry, next_ip); 274 perf_callchain_store(entry, next_ip);
287 ++level; 275 ++level;
288 sp = next_sp; 276 sp = next_sp;
289 } 277 }
@@ -447,8 +435,8 @@ static void perf_callchain_user_32(struct pt_regs *regs,
447 next_ip = regs->nip; 435 next_ip = regs->nip;
448 lr = regs->link; 436 lr = regs->link;
449 sp = regs->gpr[1]; 437 sp = regs->gpr[1];
450 callchain_store(entry, PERF_CONTEXT_USER); 438 perf_callchain_store(entry, PERF_CONTEXT_USER);
451 callchain_store(entry, next_ip); 439 perf_callchain_store(entry, next_ip);
452 440
453 while (entry->nr < PERF_MAX_STACK_DEPTH) { 441 while (entry->nr < PERF_MAX_STACK_DEPTH) {
454 fp = (unsigned int __user *) (unsigned long) sp; 442 fp = (unsigned int __user *) (unsigned long) sp;
@@ -470,14 +458,14 @@ static void perf_callchain_user_32(struct pt_regs *regs,
470 read_user_stack_32(&uregs[PT_R1], &sp)) 458 read_user_stack_32(&uregs[PT_R1], &sp))
471 return; 459 return;
472 level = 0; 460 level = 0;
473 callchain_store(entry, PERF_CONTEXT_USER); 461 perf_callchain_store(entry, PERF_CONTEXT_USER);
474 callchain_store(entry, next_ip); 462 perf_callchain_store(entry, next_ip);
475 continue; 463 continue;
476 } 464 }
477 465
478 if (level == 0) 466 if (level == 0)
479 next_ip = lr; 467 next_ip = lr;
480 callchain_store(entry, next_ip); 468 perf_callchain_store(entry, next_ip);
481 ++level; 469 ++level;
482 sp = next_sp; 470 sp = next_sp;
483 } 471 }