Commit 121dd5f2 authored by David S. Miller's avatar David S. Miller

sparc: Add alignment and emulation fault perf events.

This mirrors commit 196f02bf
(powerpc: perf_event: Add alignment-faults and emulation-faults software events)
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c658ad1b
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/perf_event.h>
/* #define DEBUG_MNA */
enum direction { enum direction {
load, /* ld, ldd, ldh, ldsh */ load, /* ld, ldd, ldh, ldsh */
...@@ -29,12 +28,6 @@ enum direction { ...@@ -29,12 +28,6 @@ enum direction {
invalid, invalid,
}; };
#ifdef DEBUG_MNA
static char *dirstrings[] = {
"load", "store", "both", "fpload", "fpstore", "invalid"
};
#endif
static inline enum direction decode_direction(unsigned int insn) static inline enum direction decode_direction(unsigned int insn)
{ {
unsigned long tmp = (insn >> 21) & 1; unsigned long tmp = (insn >> 21) & 1;
...@@ -255,10 +248,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) ...@@ -255,10 +248,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
unsigned long addr = compute_effective_address(regs, insn); unsigned long addr = compute_effective_address(regs, insn);
int err; int err;
#ifdef DEBUG_MNA perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
printk("KMNA: pc=%08lx [dir=%s addr=%08lx size=%d] retpc[%08lx]\n",
regs->pc, dirstrings[dir], addr, size, regs->u_regs[UREG_RETPC]);
#endif
switch (dir) { switch (dir) {
case load: case load:
err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), 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,6 +340,7 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
} }
addr = compute_effective_address(regs, insn); addr = compute_effective_address(regs, insn);
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
switch(dir) { switch(dir) {
case load: case load:
err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
......
...@@ -20,10 +20,9 @@ ...@@ -20,10 +20,9 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/perf_event.h>
#include <asm/fpumacro.h> #include <asm/fpumacro.h>
/* #define DEBUG_MNA */
enum direction { enum direction {
load, /* ld, ldd, ldh, ldsh */ load, /* ld, ldd, ldh, ldsh */
store, /* st, std, sth, stsh */ store, /* st, std, sth, stsh */
...@@ -33,12 +32,6 @@ enum direction { ...@@ -33,12 +32,6 @@ enum direction {
invalid, invalid,
}; };
#ifdef DEBUG_MNA
static char *dirstrings[] = {
"load", "store", "both", "fpload", "fpstore", "invalid"
};
#endif
static inline enum direction decode_direction(unsigned int insn) static inline enum direction decode_direction(unsigned int insn)
{ {
unsigned long tmp = (insn >> 21) & 1; unsigned long tmp = (insn >> 21) & 1;
...@@ -327,12 +320,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) ...@@ -327,12 +320,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
addr = compute_effective_address(regs, insn, addr = compute_effective_address(regs, insn,
((insn >> 25) & 0x1f)); ((insn >> 25) & 0x1f));
#ifdef DEBUG_MNA perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
printk("KMNA: pc=%016lx [dir=%s addr=%016lx size=%d] "
"retpc[%016lx]\n",
regs->tpc, dirstrings[dir], addr, size,
regs->u_regs[UREG_RETPC]);
#endif
switch (asi) { switch (asi) {
case ASI_NL: case ASI_NL:
case ASI_AIUPL: case ASI_AIUPL:
...@@ -399,6 +387,7 @@ int handle_popc(u32 insn, struct pt_regs *regs) ...@@ -399,6 +387,7 @@ int handle_popc(u32 insn, struct pt_regs *regs)
int ret, i, rd = ((insn >> 25) & 0x1f); int ret, i, rd = ((insn >> 25) & 0x1f);
int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
if (insn & 0x2000) { if (insn & 0x2000) {
maybe_flush_windows(0, 0, rd, from_kernel); maybe_flush_windows(0, 0, rd, from_kernel);
value = sign_extend_imm13(insn); value = sign_extend_imm13(insn);
...@@ -445,6 +434,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs) ...@@ -445,6 +434,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs)
int asi = decode_asi(insn, regs); int asi = decode_asi(insn, regs);
int flag = (freg < 32) ? FPRS_DL : FPRS_DU; int flag = (freg < 32) ? FPRS_DL : FPRS_DU;
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
save_and_clear_fpu(); save_and_clear_fpu();
current_thread_info()->xfsr[0] &= ~0x1c000; current_thread_info()->xfsr[0] &= ~0x1c000;
if (freg & 3) { if (freg & 3) {
...@@ -566,6 +557,8 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs) ...@@ -566,6 +557,8 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs)
int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
unsigned long *reg; unsigned long *reg;
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
maybe_flush_windows(0, 0, rd, from_kernel); maybe_flush_windows(0, 0, rd, from_kernel);
reg = fetch_reg_addr(rd, regs); reg = fetch_reg_addr(rd, regs);
if (from_kernel || rd < 16) { if (from_kernel || rd < 16) {
...@@ -596,6 +589,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr ...@@ -596,6 +589,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr
if (tstate & TSTATE_PRIV) if (tstate & TSTATE_PRIV)
die_if_kernel("lddfmna from kernel", regs); die_if_kernel("lddfmna from kernel", regs);
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);
if (test_thread_flag(TIF_32BIT)) if (test_thread_flag(TIF_32BIT))
pc = (u32)pc; pc = (u32)pc;
if (get_user(insn, (u32 __user *) pc) != -EFAULT) { 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,6 +651,7 @@ void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr
if (tstate & TSTATE_PRIV) if (tstate & TSTATE_PRIV)
die_if_kernel("stdfmna from kernel", regs); die_if_kernel("stdfmna from kernel", regs);
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);
if (test_thread_flag(TIF_32BIT)) if (test_thread_flag(TIF_32BIT))
pc = (u32)pc; pc = (u32)pc;
if (get_user(insn, (u32 __user *) pc) != -EFAULT) { if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/thread_info.h> #include <linux/thread_info.h>
#include <linux/perf_event.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/pstate.h> #include <asm/pstate.h>
...@@ -801,6 +802,8 @@ int vis_emul(struct pt_regs *regs, unsigned int insn) ...@@ -801,6 +802,8 @@ int vis_emul(struct pt_regs *regs, unsigned int insn)
BUG_ON(regs->tstate & TSTATE_PRIV); BUG_ON(regs->tstate & TSTATE_PRIV);
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
if (test_thread_flag(TIF_32BIT)) if (test_thread_flag(TIF_32BIT))
pc = (u32)pc; pc = (u32)pc;
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/perf_event.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "sfp-util_32.h" #include "sfp-util_32.h"
...@@ -163,6 +164,8 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt) ...@@ -163,6 +164,8 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt)
int retcode = 0; /* assume all succeed */ int retcode = 0; /* assume all succeed */
unsigned long insn; unsigned long insn;
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
#ifdef DEBUG_MATHEMU #ifdef DEBUG_MATHEMU
printk("In do_mathemu()... pc is %08lx\n", regs->pc); printk("In do_mathemu()... pc is %08lx\n", regs->pc);
printk("fpqdepth is %ld\n", fpt->thread.fpqdepth); printk("fpqdepth is %ld\n", fpt->thread.fpqdepth);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/perf_event.h>
#include <asm/fpumacro.h> #include <asm/fpumacro.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
...@@ -183,6 +184,7 @@ int do_mathemu(struct pt_regs *regs, struct fpustate *f) ...@@ -183,6 +184,7 @@ int do_mathemu(struct pt_regs *regs, struct fpustate *f)
if (tstate & TSTATE_PRIV) if (tstate & TSTATE_PRIV)
die_if_kernel("unfinished/unimplemented FPop from kernel", regs); die_if_kernel("unfinished/unimplemented FPop from kernel", regs);
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
if (test_thread_flag(TIF_32BIT)) if (test_thread_flag(TIF_32BIT))
pc = (u32)pc; pc = (u32)pc;
if (get_user(insn, (u32 __user *) pc) != -EFAULT) { if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment