diff options
author | David S. Miller <davem@davemloft.net> | 2009-12-11 04:07:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-11 04:07:53 -0500 |
commit | 121dd5f2776522e03970916514b46e355480e538 (patch) | |
tree | 0235f760d5e40cb4982b52368e309eac00f8826d /arch/sparc | |
parent | c658ad1b4e1520511da8323aa5e60d444cc303ed (diff) |
sparc: Add alignment and emulation fault perf events.
This mirrors commit 196f02bf900c5eb6f85d889c4f70e7cc11fda7e8
(powerpc: perf_event: Add alignment-faults and emulation-faults software events)
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/unaligned_32.c | 15 | ||||
-rw-r--r-- | arch/sparc/kernel/unaligned_64.c | 23 | ||||
-rw-r--r-- | arch/sparc/kernel/visemul.c | 3 | ||||
-rw-r--r-- | arch/sparc/math-emu/math_32.c | 3 | ||||
-rw-r--r-- | arch/sparc/math-emu/math_64.c | 2 |
5 files changed, 20 insertions, 26 deletions
diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c index 6b1e6cde6fff..f8514e291e15 100644 --- a/arch/sparc/kernel/unaligned_32.c +++ b/arch/sparc/kernel/unaligned_32.c | |||
@@ -17,8 +17,7 @@ | |||
17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | #include <linux/smp.h> | 18 | #include <linux/smp.h> |
19 | #include <linux/smp_lock.h> | 19 | #include <linux/smp_lock.h> |
20 | 20 | #include <linux/perf_event.h> | |
21 | /* #define DEBUG_MNA */ | ||
22 | 21 | ||
23 | enum direction { | 22 | enum direction { |
24 | load, /* ld, ldd, ldh, ldsh */ | 23 | load, /* ld, ldd, ldh, ldsh */ |
@@ -29,12 +28,6 @@ enum direction { | |||
29 | invalid, | 28 | invalid, |
30 | }; | 29 | }; |
31 | 30 | ||
32 | #ifdef DEBUG_MNA | ||
33 | static char *dirstrings[] = { | ||
34 | "load", "store", "both", "fpload", "fpstore", "invalid" | ||
35 | }; | ||
36 | #endif | ||
37 | |||
38 | static inline enum direction decode_direction(unsigned int insn) | 31 | static inline enum direction decode_direction(unsigned int insn) |
39 | { | 32 | { |
40 | unsigned long tmp = (insn >> 21) & 1; | 33 | unsigned long tmp = (insn >> 21) & 1; |
@@ -255,10 +248,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
255 | unsigned long addr = compute_effective_address(regs, insn); | 248 | unsigned long addr = compute_effective_address(regs, insn); |
256 | int err; | 249 | int err; |
257 | 250 | ||
258 | #ifdef DEBUG_MNA | 251 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); |
259 | printk("KMNA: pc=%08lx [dir=%s addr=%08lx size=%d] retpc[%08lx]\n", | ||
260 | regs->pc, dirstrings[dir], addr, size, regs->u_regs[UREG_RETPC]); | ||
261 | #endif | ||
262 | switch (dir) { | 252 | switch (dir) { |
263 | case load: | 253 | case load: |
264 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), | 254 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), |
@@ -350,6 +340,7 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
350 | } | 340 | } |
351 | 341 | ||
352 | addr = compute_effective_address(regs, insn); | 342 | addr = compute_effective_address(regs, insn); |
343 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); | ||
353 | switch(dir) { | 344 | switch(dir) { |
354 | case load: | 345 | case load: |
355 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), | 346 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), |
diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c index 379209982a07..378ca82b9ccc 100644 --- a/arch/sparc/kernel/unaligned_64.c +++ b/arch/sparc/kernel/unaligned_64.c | |||
@@ -20,10 +20,9 @@ | |||
20 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
21 | #include <linux/smp.h> | 21 | #include <linux/smp.h> |
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/perf_event.h> | ||
23 | #include <asm/fpumacro.h> | 24 | #include <asm/fpumacro.h> |
24 | 25 | ||
25 | /* #define DEBUG_MNA */ | ||
26 | |||
27 | enum direction { | 26 | enum direction { |
28 | load, /* ld, ldd, ldh, ldsh */ | 27 | load, /* ld, ldd, ldh, ldsh */ |
29 | store, /* st, std, sth, stsh */ | 28 | store, /* st, std, sth, stsh */ |
@@ -33,12 +32,6 @@ enum direction { | |||
33 | invalid, | 32 | invalid, |
34 | }; | 33 | }; |
35 | 34 | ||
36 | #ifdef DEBUG_MNA | ||
37 | static char *dirstrings[] = { | ||
38 | "load", "store", "both", "fpload", "fpstore", "invalid" | ||
39 | }; | ||
40 | #endif | ||
41 | |||
42 | static inline enum direction decode_direction(unsigned int insn) | 35 | static inline enum direction decode_direction(unsigned int insn) |
43 | { | 36 | { |
44 | unsigned long tmp = (insn >> 21) & 1; | 37 | unsigned long tmp = (insn >> 21) & 1; |
@@ -327,12 +320,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
327 | 320 | ||
328 | addr = compute_effective_address(regs, insn, | 321 | addr = compute_effective_address(regs, insn, |
329 | ((insn >> 25) & 0x1f)); | 322 | ((insn >> 25) & 0x1f)); |
330 | #ifdef DEBUG_MNA | 323 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); |
331 | printk("KMNA: pc=%016lx [dir=%s addr=%016lx size=%d] " | ||
332 | "retpc[%016lx]\n", | ||
333 | regs->tpc, dirstrings[dir], addr, size, | ||
334 | regs->u_regs[UREG_RETPC]); | ||
335 | #endif | ||
336 | switch (asi) { | 324 | switch (asi) { |
337 | case ASI_NL: | 325 | case ASI_NL: |
338 | case ASI_AIUPL: | 326 | case ASI_AIUPL: |
@@ -399,6 +387,7 @@ int handle_popc(u32 insn, struct pt_regs *regs) | |||
399 | int ret, i, rd = ((insn >> 25) & 0x1f); | 387 | int ret, i, rd = ((insn >> 25) & 0x1f); |
400 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; | 388 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; |
401 | 389 | ||
390 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
402 | if (insn & 0x2000) { | 391 | if (insn & 0x2000) { |
403 | maybe_flush_windows(0, 0, rd, from_kernel); | 392 | maybe_flush_windows(0, 0, rd, from_kernel); |
404 | value = sign_extend_imm13(insn); | 393 | value = sign_extend_imm13(insn); |
@@ -445,6 +434,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs) | |||
445 | int asi = decode_asi(insn, regs); | 434 | int asi = decode_asi(insn, regs); |
446 | int flag = (freg < 32) ? FPRS_DL : FPRS_DU; | 435 | int flag = (freg < 32) ? FPRS_DL : FPRS_DU; |
447 | 436 | ||
437 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
438 | |||
448 | save_and_clear_fpu(); | 439 | save_and_clear_fpu(); |
449 | current_thread_info()->xfsr[0] &= ~0x1c000; | 440 | current_thread_info()->xfsr[0] &= ~0x1c000; |
450 | if (freg & 3) { | 441 | if (freg & 3) { |
@@ -566,6 +557,8 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs) | |||
566 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; | 557 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; |
567 | unsigned long *reg; | 558 | unsigned long *reg; |
568 | 559 | ||
560 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
561 | |||
569 | maybe_flush_windows(0, 0, rd, from_kernel); | 562 | maybe_flush_windows(0, 0, rd, from_kernel); |
570 | reg = fetch_reg_addr(rd, regs); | 563 | reg = fetch_reg_addr(rd, regs); |
571 | if (from_kernel || rd < 16) { | 564 | if (from_kernel || rd < 16) { |
@@ -596,6 +589,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr | |||
596 | 589 | ||
597 | if (tstate & TSTATE_PRIV) | 590 | if (tstate & TSTATE_PRIV) |
598 | die_if_kernel("lddfmna from kernel", regs); | 591 | die_if_kernel("lddfmna from kernel", regs); |
592 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); | ||
599 | if (test_thread_flag(TIF_32BIT)) | 593 | if (test_thread_flag(TIF_32BIT)) |
600 | pc = (u32)pc; | 594 | pc = (u32)pc; |
601 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { | 595 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { |
@@ -657,6 +651,7 @@ void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr | |||
657 | 651 | ||
658 | if (tstate & TSTATE_PRIV) | 652 | if (tstate & TSTATE_PRIV) |
659 | die_if_kernel("stdfmna from kernel", regs); | 653 | die_if_kernel("stdfmna from kernel", regs); |
654 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); | ||
660 | if (test_thread_flag(TIF_32BIT)) | 655 | if (test_thread_flag(TIF_32BIT)) |
661 | pc = (u32)pc; | 656 | pc = (u32)pc; |
662 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { | 657 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { |
diff --git a/arch/sparc/kernel/visemul.c b/arch/sparc/kernel/visemul.c index d231cbd5c526..9dfd2ebcb157 100644 --- a/arch/sparc/kernel/visemul.c +++ b/arch/sparc/kernel/visemul.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
7 | #include <linux/thread_info.h> | 7 | #include <linux/thread_info.h> |
8 | #include <linux/perf_event.h> | ||
8 | 9 | ||
9 | #include <asm/ptrace.h> | 10 | #include <asm/ptrace.h> |
10 | #include <asm/pstate.h> | 11 | #include <asm/pstate.h> |
@@ -801,6 +802,8 @@ int vis_emul(struct pt_regs *regs, unsigned int insn) | |||
801 | 802 | ||
802 | BUG_ON(regs->tstate & TSTATE_PRIV); | 803 | BUG_ON(regs->tstate & TSTATE_PRIV); |
803 | 804 | ||
805 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
806 | |||
804 | if (test_thread_flag(TIF_32BIT)) | 807 | if (test_thread_flag(TIF_32BIT)) |
805 | pc = (u32)pc; | 808 | pc = (u32)pc; |
806 | 809 | ||
diff --git a/arch/sparc/math-emu/math_32.c b/arch/sparc/math-emu/math_32.c index e13f65da17df..a3fccde894ec 100644 --- a/arch/sparc/math-emu/math_32.c +++ b/arch/sparc/math-emu/math_32.c | |||
@@ -67,6 +67,7 @@ | |||
67 | #include <linux/types.h> | 67 | #include <linux/types.h> |
68 | #include <linux/sched.h> | 68 | #include <linux/sched.h> |
69 | #include <linux/mm.h> | 69 | #include <linux/mm.h> |
70 | #include <linux/perf_event.h> | ||
70 | #include <asm/uaccess.h> | 71 | #include <asm/uaccess.h> |
71 | 72 | ||
72 | #include "sfp-util_32.h" | 73 | #include "sfp-util_32.h" |
@@ -163,6 +164,8 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt) | |||
163 | int retcode = 0; /* assume all succeed */ | 164 | int retcode = 0; /* assume all succeed */ |
164 | unsigned long insn; | 165 | unsigned long insn; |
165 | 166 | ||
167 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
168 | |||
166 | #ifdef DEBUG_MATHEMU | 169 | #ifdef DEBUG_MATHEMU |
167 | printk("In do_mathemu()... pc is %08lx\n", regs->pc); | 170 | printk("In do_mathemu()... pc is %08lx\n", regs->pc); |
168 | printk("fpqdepth is %ld\n", fpt->thread.fpqdepth); | 171 | printk("fpqdepth is %ld\n", fpt->thread.fpqdepth); |
diff --git a/arch/sparc/math-emu/math_64.c b/arch/sparc/math-emu/math_64.c index 6863c9bde25c..56d2c44747b8 100644 --- a/arch/sparc/math-emu/math_64.c +++ b/arch/sparc/math-emu/math_64.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/perf_event.h> | ||
14 | 15 | ||
15 | #include <asm/fpumacro.h> | 16 | #include <asm/fpumacro.h> |
16 | #include <asm/ptrace.h> | 17 | #include <asm/ptrace.h> |
@@ -183,6 +184,7 @@ int do_mathemu(struct pt_regs *regs, struct fpustate *f) | |||
183 | 184 | ||
184 | if (tstate & TSTATE_PRIV) | 185 | if (tstate & TSTATE_PRIV) |
185 | die_if_kernel("unfinished/unimplemented FPop from kernel", regs); | 186 | die_if_kernel("unfinished/unimplemented FPop from kernel", regs); |
187 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | ||
186 | if (test_thread_flag(TIF_32BIT)) | 188 | if (test_thread_flag(TIF_32BIT)) |
187 | pc = (u32)pc; | 189 | pc = (u32)pc; |
188 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { | 190 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { |