Skip to contentSkip to conversation

riscv: mm: refactor by introducing trace_page_fault_entries()

PATCH New Austin Kim 1 participant 1 message Mar 30 RISC-V

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 riscv: mm: refactor by introducing trace_page_fault_entries()

From: Austin Kim <[email protected]>

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.

---
 arch/riscv/mm/fault.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
arch/riscv/mm/fault.c +11 -4
index 04ed6f8ac..54c9a388c 100644
@@ -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.
Signature · 1 line
2.34.1