[PATCH] riscv: mm: refactor by introducing trace_page_fault_entries()

Austin Kim austindh.kim at gmail.com
Sun Mar 29 22:31:37 PDT 2026


From: Austin Kim <austin.kim at lge.com>

Introduce trace_page_fault_entries() as an inline helper to wrap page 
faults tracepoints. This simplifies handle_page_fault() and makes the code 
cleaner and more readable. No functional change is made.

Signed-off-by: Austin Kim <austin.kim at lge.com>
---
 arch/riscv/mm/fault.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 04ed6f8ac..54c9a388c 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -271,6 +271,16 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma)
 	return false;
 }
 
+static __always_inline void
+trace_page_fault_entries(unsigned long address, struct pt_regs *regs,
+			 unsigned long cause_code)
+{
+	if (user_mode(regs))
+		trace_page_fault_user(address, regs, cause_code);
+	else
+		trace_page_fault_kernel(address, regs, cause_code);
+}
+
 /*
  * This routine handles page faults.  It determines the address and the
  * problem, and then passes it off to one of the appropriate routines.
@@ -294,10 +304,7 @@ 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);
+	trace_page_fault_entries(addr, regs, cause);
 
 	/*
 	 * Fault-in kernel-space virtual memory on-demand.
-- 
2.34.1




More information about the linux-riscv mailing list