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

Avoid doing page fault accounting multiple times if the page fault is retried.

CC: Chris Zankel <ch...@zankel.net>
CC: Max Filippov <jcmvb...@gmail.com>
CC: linux-xte...@linux-xtensa.org
Signed-off-by: Peter Xu <pet...@redhat.com>
---
 arch/xtensa/mm/fault.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c
index e7172bd53ced..511a2c5f9857 100644
--- a/arch/xtensa/mm/fault.c
+++ b/arch/xtensa/mm/fault.c
@@ -42,7 +42,7 @@ void do_page_fault(struct pt_regs *regs)
        int code;
 
        int is_write, is_exec;
-       vm_fault_t fault;
+       vm_fault_t fault, major = 0;
        unsigned int flags = FAULT_FLAG_DEFAULT;
 
        code = SEGV_MAPERR;
@@ -109,6 +109,7 @@ void do_page_fault(struct pt_regs *regs)
         * the fault.
         */
        fault = handle_mm_fault(vma, address, flags);
+       major |= fault & VM_FAULT_MAJOR;
 
        if (fault_signal_pending(fault, regs))
                return;
@@ -123,10 +124,6 @@ void do_page_fault(struct pt_regs *regs)
                BUG();
        }
        if (flags & FAULT_FLAG_ALLOW_RETRY) {
-               if (fault & VM_FAULT_MAJOR)
-                       current->maj_flt++;
-               else
-                       current->min_flt++;
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
@@ -140,12 +137,7 @@ void do_page_fault(struct pt_regs *regs)
        }
 
        up_read(&mm->mmap_sem);
-       perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-       if (flags & VM_FAULT_MAJOR)
-               perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
-       else
-               perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
-
+       mm_fault_accounting(current, regs, address, major);
        return;
 
        /* Something tried to access memory that isn't in our memory map..
-- 
2.26.2

Reply via email to