2023-10-04 15:14:41

by Clément Léger

[permalink] [raw]
Subject: [PATCH v2 3/8] 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 <[email protected]>
---
arch/riscv/kernel/traps_misaligned.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
index 9daed7d756ae..804f6c5e0e44 100644
--- a/arch/riscv/kernel/traps_misaligned.c
+++ b/arch/riscv/kernel/traps_misaligned.c
@@ -6,6 +6,7 @@
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/module.h>
+#include <linux/perf_event.h>
#include <linux/irq.h>
#include <linux/stringify.h>

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

+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
+
if (get_insn(regs, epc, &insn))
return -1;

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

+ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
+
if (get_insn(regs, epc, &insn))
return -1;

--
2.42.0


2023-10-04 17:02:33

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH v2 3/8] riscv: report perf event for misaligned fault

Clément Léger <[email protected]> writes:

> Add missing calls to account for misaligned fault event using
> perf_sw_event().
>
> Signed-off-by: Clément Léger <[email protected]>

Reviewed-by: Björn Töpel <[email protected]>