[PATCH 11/25] mm/microblaze: Use mm_fault_accounting()

From: Peter Xu
Date: Mon Jun 15 2020 - 18:17:06 EST


Use the new mm_fault_accounting() helper for page fault accounting.

Avoid doing page fault accounting multiple times if the page fault is retried.
Also, the perf events for page faults will be accounted too when the config has
CONFIG_PERF_EVENTS defined.

CC: Michal Simek <monstr@xxxxxxxxx>
Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
arch/microblaze/mm/fault.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/microblaze/mm/fault.c b/arch/microblaze/mm/fault.c
index 3248141f8ed5..db0f3b71c3fe 100644
--- a/arch/microblaze/mm/fault.c
+++ b/arch/microblaze/mm/fault.c
@@ -90,7 +90,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
struct mm_struct *mm = current->mm;
int code = SEGV_MAPERR;
int is_write = error_code & ESR_S;
- vm_fault_t fault;
+ vm_fault_t fault, major = 0;
unsigned int flags = FAULT_FLAG_DEFAULT;

regs->ear = address;
@@ -216,6 +216,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
* the fault.
*/
fault = handle_mm_fault(vma, address, flags);
+ major |= fault & VM_FAULT_MAJOR;

if (fault_signal_pending(fault, regs))
return;
@@ -231,10 +232,6 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
}

if (flags & FAULT_FLAG_ALLOW_RETRY) {
- if (unlikely(fault & VM_FAULT_MAJOR))
- current->maj_flt++;
- else
- current->min_flt++;
if (fault & VM_FAULT_RETRY) {
flags |= FAULT_FLAG_TRIED;

@@ -249,6 +246,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
}

up_read(&mm->mmap_sem);
+ mm_fault_accounting(current, regs, address, major);

/*
* keep track of tlb+htab misses that are good addrs but
--
2.26.2