diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 19:44:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 19:44:39 -0400 |
commit | 4d4abdcb1dee03a4f9d6d2021622ed07e14dfd17 (patch) | |
tree | 4ed4c74b70240451065165fda5fb2059f8c6b1e5 /arch/mips | |
parent | 0342cbcfced2ee937d7c8e1c63f3d3082da7c7dc (diff) | |
parent | 7fcfd1abd6480d3b9ef17f5759c175e036e835cf (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (123 commits)
perf: Remove the nmi parameter from the oprofile_perf backend
x86, perf: Make copy_from_user_nmi() a library function
perf: Remove perf_event_attr::type check
x86, perf: P4 PMU - Fix typos in comments and style cleanup
perf tools: Make test use the preset debugfs path
perf tools: Add automated tests for events parsing
perf tools: De-opt the parse_events function
perf script: Fix display of IP address for non-callchain path
perf tools: Fix endian conversion reading event attr from file header
perf tools: Add missing 'node' alias to the hw_cache[] array
perf probe: Support adding probes on offline kernel modules
perf probe: Add probed module in front of function
perf probe: Introduce debuginfo to encapsulate dwarf information
perf-probe: Move dwarf library routines to dwarf-aux.{c, h}
perf probe: Remove redundant dwarf functions
perf probe: Move strtailcmp to string.c
perf probe: Rename DIE_FIND_CB_FOUND to DIE_FIND_CB_END
tracing/kprobe: Update symbol reference when loading module
tracing/kprobes: Support module init function probing
kprobes: Return -ENOENT if probe point doesn't exist
...
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/include/asm/stacktrace.h | 4 | ||||
-rw-r--r-- | arch/mips/kernel/perf_event.c | 2 | ||||
-rw-r--r-- | arch/mips/kernel/perf_event_mipsxx.c | 28 | ||||
-rw-r--r-- | arch/mips/kernel/process.c | 19 | ||||
-rw-r--r-- | arch/mips/kernel/traps.c | 8 | ||||
-rw-r--r-- | arch/mips/kernel/unaligned.c | 5 | ||||
-rw-r--r-- | arch/mips/math-emu/cp1emu.c | 3 | ||||
-rw-r--r-- | arch/mips/mm/fault.c | 8 | ||||
-rw-r--r-- | arch/mips/oprofile/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/oprofile/backtrace.c | 175 | ||||
-rw-r--r-- | arch/mips/oprofile/common.c | 1 | ||||
-rw-r--r-- | arch/mips/oprofile/op_impl.h | 2 |
12 files changed, 236 insertions, 21 deletions
diff --git a/arch/mips/include/asm/stacktrace.h b/arch/mips/include/asm/stacktrace.h index 0bf82818aa53..780ee2c2a2ac 100644 --- a/arch/mips/include/asm/stacktrace.h +++ b/arch/mips/include/asm/stacktrace.h | |||
@@ -7,6 +7,10 @@ | |||
7 | extern int raw_show_trace; | 7 | extern int raw_show_trace; |
8 | extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, | 8 | extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, |
9 | unsigned long pc, unsigned long *ra); | 9 | unsigned long pc, unsigned long *ra); |
10 | extern unsigned long unwind_stack_by_address(unsigned long stack_page, | ||
11 | unsigned long *sp, | ||
12 | unsigned long pc, | ||
13 | unsigned long *ra); | ||
10 | #else | 14 | #else |
11 | #define raw_show_trace 1 | 15 | #define raw_show_trace 1 |
12 | static inline unsigned long unwind_stack(struct task_struct *task, | 16 | static inline unsigned long unwind_stack(struct task_struct *task, |
diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c index a8244854d3dc..d0deaab9ace2 100644 --- a/arch/mips/kernel/perf_event.c +++ b/arch/mips/kernel/perf_event.c | |||
@@ -527,7 +527,7 @@ handle_associated_event(struct cpu_hw_events *cpuc, | |||
527 | if (!mipspmu_event_set_period(event, hwc, idx)) | 527 | if (!mipspmu_event_set_period(event, hwc, idx)) |
528 | return; | 528 | return; |
529 | 529 | ||
530 | if (perf_event_overflow(event, 0, data, regs)) | 530 | if (perf_event_overflow(event, data, regs)) |
531 | mipspmu->disable_event(idx); | 531 | mipspmu->disable_event(idx); |
532 | } | 532 | } |
533 | 533 | ||
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 75266ff4cc33..e5ad09a9baf7 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c | |||
@@ -377,6 +377,20 @@ static const struct mips_perf_event mipsxxcore_cache_map | |||
377 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | 377 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, |
378 | }, | 378 | }, |
379 | }, | 379 | }, |
380 | [C(NODE)] = { | ||
381 | [C(OP_READ)] = { | ||
382 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
383 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
384 | }, | ||
385 | [C(OP_WRITE)] = { | ||
386 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
387 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
388 | }, | ||
389 | [C(OP_PREFETCH)] = { | ||
390 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
391 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
392 | }, | ||
393 | }, | ||
380 | }; | 394 | }; |
381 | 395 | ||
382 | /* 74K core has completely different cache event map. */ | 396 | /* 74K core has completely different cache event map. */ |
@@ -480,6 +494,20 @@ static const struct mips_perf_event mipsxx74Kcore_cache_map | |||
480 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | 494 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, |
481 | }, | 495 | }, |
482 | }, | 496 | }, |
497 | [C(NODE)] = { | ||
498 | [C(OP_READ)] = { | ||
499 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
500 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
501 | }, | ||
502 | [C(OP_WRITE)] = { | ||
503 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
504 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
505 | }, | ||
506 | [C(OP_PREFETCH)] = { | ||
507 | [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
508 | [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID }, | ||
509 | }, | ||
510 | }, | ||
483 | }; | 511 | }; |
484 | 512 | ||
485 | #ifdef CONFIG_MIPS_MT_SMP | 513 | #ifdef CONFIG_MIPS_MT_SMP |
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index d2112d3cf115..c28fbe6107bc 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -373,18 +373,18 @@ unsigned long thread_saved_pc(struct task_struct *tsk) | |||
373 | 373 | ||
374 | 374 | ||
375 | #ifdef CONFIG_KALLSYMS | 375 | #ifdef CONFIG_KALLSYMS |
376 | /* used by show_backtrace() */ | 376 | /* generic stack unwinding function */ |
377 | unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, | 377 | unsigned long notrace unwind_stack_by_address(unsigned long stack_page, |
378 | unsigned long pc, unsigned long *ra) | 378 | unsigned long *sp, |
379 | unsigned long pc, | ||
380 | unsigned long *ra) | ||
379 | { | 381 | { |
380 | unsigned long stack_page; | ||
381 | struct mips_frame_info info; | 382 | struct mips_frame_info info; |
382 | unsigned long size, ofs; | 383 | unsigned long size, ofs; |
383 | int leaf; | 384 | int leaf; |
384 | extern void ret_from_irq(void); | 385 | extern void ret_from_irq(void); |
385 | extern void ret_from_exception(void); | 386 | extern void ret_from_exception(void); |
386 | 387 | ||
387 | stack_page = (unsigned long)task_stack_page(task); | ||
388 | if (!stack_page) | 388 | if (!stack_page) |
389 | return 0; | 389 | return 0; |
390 | 390 | ||
@@ -443,6 +443,15 @@ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, | |||
443 | *ra = 0; | 443 | *ra = 0; |
444 | return __kernel_text_address(pc) ? pc : 0; | 444 | return __kernel_text_address(pc) ? pc : 0; |
445 | } | 445 | } |
446 | EXPORT_SYMBOL(unwind_stack_by_address); | ||
447 | |||
448 | /* used by show_backtrace() */ | ||
449 | unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, | ||
450 | unsigned long pc, unsigned long *ra) | ||
451 | { | ||
452 | unsigned long stack_page = (unsigned long)task_stack_page(task); | ||
453 | return unwind_stack_by_address(stack_page, sp, pc, ra); | ||
454 | } | ||
446 | #endif | 455 | #endif |
447 | 456 | ||
448 | /* | 457 | /* |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index e9b3af27d844..b7517e3abc85 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -578,12 +578,12 @@ static int simulate_llsc(struct pt_regs *regs, unsigned int opcode) | |||
578 | { | 578 | { |
579 | if ((opcode & OPCODE) == LL) { | 579 | if ((opcode & OPCODE) == LL) { |
580 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 580 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, |
581 | 1, 0, regs, 0); | 581 | 1, regs, 0); |
582 | return simulate_ll(regs, opcode); | 582 | return simulate_ll(regs, opcode); |
583 | } | 583 | } |
584 | if ((opcode & OPCODE) == SC) { | 584 | if ((opcode & OPCODE) == SC) { |
585 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 585 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, |
586 | 1, 0, regs, 0); | 586 | 1, regs, 0); |
587 | return simulate_sc(regs, opcode); | 587 | return simulate_sc(regs, opcode); |
588 | } | 588 | } |
589 | 589 | ||
@@ -602,7 +602,7 @@ static int simulate_rdhwr(struct pt_regs *regs, unsigned int opcode) | |||
602 | int rd = (opcode & RD) >> 11; | 602 | int rd = (opcode & RD) >> 11; |
603 | int rt = (opcode & RT) >> 16; | 603 | int rt = (opcode & RT) >> 16; |
604 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 604 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, |
605 | 1, 0, regs, 0); | 605 | 1, regs, 0); |
606 | switch (rd) { | 606 | switch (rd) { |
607 | case 0: /* CPU number */ | 607 | case 0: /* CPU number */ |
608 | regs->regs[rt] = smp_processor_id(); | 608 | regs->regs[rt] = smp_processor_id(); |
@@ -640,7 +640,7 @@ static int simulate_sync(struct pt_regs *regs, unsigned int opcode) | |||
640 | { | 640 | { |
641 | if ((opcode & OPCODE) == SPEC0 && (opcode & FUNC) == SYNC) { | 641 | if ((opcode & OPCODE) == SPEC0 && (opcode & FUNC) == SYNC) { |
642 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 642 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, |
643 | 1, 0, regs, 0); | 643 | 1, regs, 0); |
644 | return 0; | 644 | return 0; |
645 | } | 645 | } |
646 | 646 | ||
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index cfea1adfa153..eb319b580353 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c | |||
@@ -111,8 +111,7 @@ static void emulate_load_store_insn(struct pt_regs *regs, | |||
111 | unsigned long value; | 111 | unsigned long value; |
112 | unsigned int res; | 112 | unsigned int res; |
113 | 113 | ||
114 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 114 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
115 | 1, 0, regs, 0); | ||
116 | 115 | ||
117 | /* | 116 | /* |
118 | * This load never faults. | 117 | * This load never faults. |
@@ -517,7 +516,7 @@ asmlinkage void do_ade(struct pt_regs *regs) | |||
517 | mm_segment_t seg; | 516 | mm_segment_t seg; |
518 | 517 | ||
519 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, | 518 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, |
520 | 1, 0, regs, regs->cp0_badvaddr); | 519 | 1, regs, regs->cp0_badvaddr); |
521 | /* | 520 | /* |
522 | * Did we catch a fault trying to load an instruction? | 521 | * Did we catch a fault trying to load an instruction? |
523 | * Or are we running in MIPS16 mode? | 522 | * Or are we running in MIPS16 mode? |
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index d32cb0503110..dbf2f93a5091 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c | |||
@@ -272,8 +272,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
272 | } | 272 | } |
273 | 273 | ||
274 | emul: | 274 | emul: |
275 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, | 275 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, xcp, 0); |
276 | 1, 0, xcp, 0); | ||
277 | MIPS_FPU_EMU_INC_STATS(emulated); | 276 | MIPS_FPU_EMU_INC_STATS(emulated); |
278 | switch (MIPSInst_OPCODE(ir)) { | 277 | switch (MIPSInst_OPCODE(ir)) { |
279 | case ldc1_op:{ | 278 | case ldc1_op:{ |
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 137ee76a0045..937cf3368164 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c | |||
@@ -145,7 +145,7 @@ good_area: | |||
145 | * the fault. | 145 | * the fault. |
146 | */ | 146 | */ |
147 | fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); | 147 | fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); |
148 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address); | 148 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); |
149 | if (unlikely(fault & VM_FAULT_ERROR)) { | 149 | if (unlikely(fault & VM_FAULT_ERROR)) { |
150 | if (fault & VM_FAULT_OOM) | 150 | if (fault & VM_FAULT_OOM) |
151 | goto out_of_memory; | 151 | goto out_of_memory; |
@@ -154,12 +154,10 @@ good_area: | |||
154 | BUG(); | 154 | BUG(); |
155 | } | 155 | } |
156 | if (fault & VM_FAULT_MAJOR) { | 156 | if (fault & VM_FAULT_MAJOR) { |
157 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, | 157 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); |
158 | 1, 0, regs, address); | ||
159 | tsk->maj_flt++; | 158 | tsk->maj_flt++; |
160 | } else { | 159 | } else { |
161 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, | 160 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); |
162 | 1, 0, regs, address); | ||
163 | tsk->min_flt++; | 161 | tsk->min_flt++; |
164 | } | 162 | } |
165 | 163 | ||
diff --git a/arch/mips/oprofile/Makefile b/arch/mips/oprofile/Makefile index 4b9d7044e26c..29f2f13eb31c 100644 --- a/arch/mips/oprofile/Makefile +++ b/arch/mips/oprofile/Makefile | |||
@@ -8,7 +8,7 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ | |||
8 | oprofilefs.o oprofile_stats.o \ | 8 | oprofilefs.o oprofile_stats.o \ |
9 | timer_int.o ) | 9 | timer_int.o ) |
10 | 10 | ||
11 | oprofile-y := $(DRIVER_OBJS) common.o | 11 | oprofile-y := $(DRIVER_OBJS) common.o backtrace.o |
12 | 12 | ||
13 | oprofile-$(CONFIG_CPU_MIPS32) += op_model_mipsxx.o | 13 | oprofile-$(CONFIG_CPU_MIPS32) += op_model_mipsxx.o |
14 | oprofile-$(CONFIG_CPU_MIPS64) += op_model_mipsxx.o | 14 | oprofile-$(CONFIG_CPU_MIPS64) += op_model_mipsxx.o |
diff --git a/arch/mips/oprofile/backtrace.c b/arch/mips/oprofile/backtrace.c new file mode 100644 index 000000000000..6854ed5097d2 --- /dev/null +++ b/arch/mips/oprofile/backtrace.c | |||
@@ -0,0 +1,175 @@ | |||
1 | #include <linux/oprofile.h> | ||
2 | #include <linux/sched.h> | ||
3 | #include <linux/mm.h> | ||
4 | #include <linux/uaccess.h> | ||
5 | #include <asm/ptrace.h> | ||
6 | #include <asm/stacktrace.h> | ||
7 | #include <linux/stacktrace.h> | ||
8 | #include <linux/kernel.h> | ||
9 | #include <asm/sections.h> | ||
10 | #include <asm/inst.h> | ||
11 | |||
12 | struct stackframe { | ||
13 | unsigned long sp; | ||
14 | unsigned long pc; | ||
15 | unsigned long ra; | ||
16 | }; | ||
17 | |||
18 | static inline int get_mem(unsigned long addr, unsigned long *result) | ||
19 | { | ||
20 | unsigned long *address = (unsigned long *) addr; | ||
21 | if (!access_ok(VERIFY_READ, addr, sizeof(unsigned long))) | ||
22 | return -1; | ||
23 | if (__copy_from_user_inatomic(result, address, sizeof(unsigned long))) | ||
24 | return -3; | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | /* | ||
29 | * These two instruction helpers were taken from process.c | ||
30 | */ | ||
31 | static inline int is_ra_save_ins(union mips_instruction *ip) | ||
32 | { | ||
33 | /* sw / sd $ra, offset($sp) */ | ||
34 | return (ip->i_format.opcode == sw_op || ip->i_format.opcode == sd_op) | ||
35 | && ip->i_format.rs == 29 && ip->i_format.rt == 31; | ||
36 | } | ||
37 | |||
38 | static inline int is_sp_move_ins(union mips_instruction *ip) | ||
39 | { | ||
40 | /* addiu/daddiu sp,sp,-imm */ | ||
41 | if (ip->i_format.rs != 29 || ip->i_format.rt != 29) | ||
42 | return 0; | ||
43 | if (ip->i_format.opcode == addiu_op || ip->i_format.opcode == daddiu_op) | ||
44 | return 1; | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * Looks for specific instructions that mark the end of a function. | ||
50 | * This usually means we ran into the code area of the previous function. | ||
51 | */ | ||
52 | static inline int is_end_of_function_marker(union mips_instruction *ip) | ||
53 | { | ||
54 | /* jr ra */ | ||
55 | if (ip->r_format.func == jr_op && ip->r_format.rs == 31) | ||
56 | return 1; | ||
57 | /* lui gp */ | ||
58 | if (ip->i_format.opcode == lui_op && ip->i_format.rt == 28) | ||
59 | return 1; | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | * TODO for userspace stack unwinding: | ||
65 | * - handle cases where the stack is adjusted inside a function | ||
66 | * (generally doesn't happen) | ||
67 | * - find optimal value for max_instr_check | ||
68 | * - try to find a way to handle leaf functions | ||
69 | */ | ||
70 | |||
71 | static inline int unwind_user_frame(struct stackframe *old_frame, | ||
72 | const unsigned int max_instr_check) | ||
73 | { | ||
74 | struct stackframe new_frame = *old_frame; | ||
75 | off_t ra_offset = 0; | ||
76 | size_t stack_size = 0; | ||
77 | unsigned long addr; | ||
78 | |||
79 | if (old_frame->pc == 0 || old_frame->sp == 0 || old_frame->ra == 0) | ||
80 | return -9; | ||
81 | |||
82 | for (addr = new_frame.pc; (addr + max_instr_check > new_frame.pc) | ||
83 | && (!ra_offset || !stack_size); --addr) { | ||
84 | union mips_instruction ip; | ||
85 | |||
86 | if (get_mem(addr, (unsigned long *) &ip)) | ||
87 | return -11; | ||
88 | |||
89 | if (is_sp_move_ins(&ip)) { | ||
90 | int stack_adjustment = ip.i_format.simmediate; | ||
91 | if (stack_adjustment > 0) | ||
92 | /* This marks the end of the previous function, | ||
93 | which means we overran. */ | ||
94 | break; | ||
95 | stack_size = (unsigned) stack_adjustment; | ||
96 | } else if (is_ra_save_ins(&ip)) { | ||
97 | int ra_slot = ip.i_format.simmediate; | ||
98 | if (ra_slot < 0) | ||
99 | /* This shouldn't happen. */ | ||
100 | break; | ||
101 | ra_offset = ra_slot; | ||
102 | } else if (is_end_of_function_marker(&ip)) | ||
103 | break; | ||
104 | } | ||
105 | |||
106 | if (!ra_offset || !stack_size) | ||
107 | return -1; | ||
108 | |||
109 | if (ra_offset) { | ||
110 | new_frame.ra = old_frame->sp + ra_offset; | ||
111 | if (get_mem(new_frame.ra, &(new_frame.ra))) | ||
112 | return -13; | ||
113 | } | ||
114 | |||
115 | if (stack_size) { | ||
116 | new_frame.sp = old_frame->sp + stack_size; | ||
117 | if (get_mem(new_frame.sp, &(new_frame.sp))) | ||
118 | return -14; | ||
119 | } | ||
120 | |||
121 | if (new_frame.sp > old_frame->sp) | ||
122 | return -2; | ||
123 | |||
124 | new_frame.pc = old_frame->ra; | ||
125 | *old_frame = new_frame; | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static inline void do_user_backtrace(unsigned long low_addr, | ||
131 | struct stackframe *frame, | ||
132 | unsigned int depth) | ||
133 | { | ||
134 | const unsigned int max_instr_check = 512; | ||
135 | const unsigned long high_addr = low_addr + THREAD_SIZE; | ||
136 | |||
137 | while (depth-- && !unwind_user_frame(frame, max_instr_check)) { | ||
138 | oprofile_add_trace(frame->ra); | ||
139 | if (frame->sp < low_addr || frame->sp > high_addr) | ||
140 | break; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | #ifndef CONFIG_KALLSYMS | ||
145 | static inline void do_kernel_backtrace(unsigned long low_addr, | ||
146 | struct stackframe *frame, | ||
147 | unsigned int depth) { } | ||
148 | #else | ||
149 | static inline void do_kernel_backtrace(unsigned long low_addr, | ||
150 | struct stackframe *frame, | ||
151 | unsigned int depth) | ||
152 | { | ||
153 | while (depth-- && frame->pc) { | ||
154 | frame->pc = unwind_stack_by_address(low_addr, | ||
155 | &(frame->sp), | ||
156 | frame->pc, | ||
157 | &(frame->ra)); | ||
158 | oprofile_add_trace(frame->ra); | ||
159 | } | ||
160 | } | ||
161 | #endif | ||
162 | |||
163 | void notrace op_mips_backtrace(struct pt_regs *const regs, unsigned int depth) | ||
164 | { | ||
165 | struct stackframe frame = { .sp = regs->regs[29], | ||
166 | .pc = regs->cp0_epc, | ||
167 | .ra = regs->regs[31] }; | ||
168 | const int userspace = user_mode(regs); | ||
169 | const unsigned long low_addr = ALIGN(frame.sp, THREAD_SIZE); | ||
170 | |||
171 | if (userspace) | ||
172 | do_user_backtrace(low_addr, &frame, depth); | ||
173 | else | ||
174 | do_kernel_backtrace(low_addr, &frame, depth); | ||
175 | } | ||
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c index f9eb1aba6345..d1f2d4c52d42 100644 --- a/arch/mips/oprofile/common.c +++ b/arch/mips/oprofile/common.c | |||
@@ -115,6 +115,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) | |||
115 | ops->start = op_mips_start; | 115 | ops->start = op_mips_start; |
116 | ops->stop = op_mips_stop; | 116 | ops->stop = op_mips_stop; |
117 | ops->cpu_type = lmodel->cpu_type; | 117 | ops->cpu_type = lmodel->cpu_type; |
118 | ops->backtrace = op_mips_backtrace; | ||
118 | 119 | ||
119 | printk(KERN_INFO "oprofile: using %s performance monitoring.\n", | 120 | printk(KERN_INFO "oprofile: using %s performance monitoring.\n", |
120 | lmodel->cpu_type); | 121 | lmodel->cpu_type); |
diff --git a/arch/mips/oprofile/op_impl.h b/arch/mips/oprofile/op_impl.h index f04b54fb37d1..7c2da27ece04 100644 --- a/arch/mips/oprofile/op_impl.h +++ b/arch/mips/oprofile/op_impl.h | |||
@@ -36,4 +36,6 @@ struct op_mips_model { | |||
36 | unsigned char num_counters; | 36 | unsigned char num_counters; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | void op_mips_backtrace(struct pt_regs * const regs, unsigned int depth); | ||
40 | |||
39 | #endif | 41 | #endif |