[PATCH 08/10] riscv: mm: Add page fault trace points

Alexandre Ghiti alex at ghiti.fr
Wed Apr 2 00:35:12 PDT 2025


Hi Nam,

On 11/03/2025 18:05, Nam Cao wrote:
> Add page fault trace points, which are useful to implement RV monitor that
> watches page faults.
>
> Signed-off-by: Nam Cao <namcao at linutronix.de>
> ---
> Cc: Paul Walmsley <paul.walmsley at sifive.com>
> Cc: Palmer Dabbelt <palmer at dabbelt.com>
> Cc: Albert Ou <aou at eecs.berkeley.edu>
> Cc: Alexandre Ghiti <alex at ghiti.fr>
> Cc: linux-riscv at lists.infradead.org
> ---
>   arch/riscv/mm/fault.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 0194324a0c50..04ed6f8acae4 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -20,6 +20,9 @@
>   #include <asm/ptrace.h>
>   #include <asm/tlbflush.h>
>   
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/exceptions.h>
> +
>   #include "../kernel/head.h"
>   
>   static void show_pte(unsigned long addr)
> @@ -291,6 +294,11 @@ void handle_page_fault(struct pt_regs *regs)
>   	if (kprobe_page_fault(regs, cause))
>   		return;
>   
> +	if (user_mode(regs))
> +		trace_page_fault_user(addr, regs, cause);
> +	else
> +		trace_page_fault_kernel(addr, regs, cause);
> +
>   	/*
>   	 * Fault-in kernel-space virtual memory on-demand.
>   	 * The 'reference' page table is init_mm.pgd.


For this riscv part, you can add:

Acked-by: Alexandre Ghiti <alexghiti at rivosinc.com>

Thanks,

Alex




More information about the linux-riscv mailing list