Skip to content

Commit 89c12fe

Browse files
clementlegerpalmer-dabbelt
authored andcommitted
riscv: report perf event for misaligned fault
Add missing calls to account for misaligned fault event using perf_sw_event(). Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-4-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 7c83232 commit 89c12fe

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

arch/riscv/kernel/traps_misaligned.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/init.h>
77
#include <linux/mm.h>
88
#include <linux/module.h>
9+
#include <linux/perf_event.h>
910
#include <linux/irq.h>
1011
#include <linux/stringify.h>
1112

@@ -294,6 +295,8 @@ int handle_misaligned_load(struct pt_regs *regs)
294295
unsigned long addr = regs->badaddr;
295296
int i, fp = 0, shift = 0, len = 0;
296297

298+
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
299+
297300
if (get_insn(regs, epc, &insn))
298301
return -1;
299302

@@ -382,6 +385,8 @@ int handle_misaligned_store(struct pt_regs *regs)
382385
unsigned long addr = regs->badaddr;
383386
int i, len = 0;
384387

388+
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
389+
385390
if (get_insn(regs, epc, &insn))
386391
return -1;
387392

0 commit comments

Comments
 (0)