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

The perf event accounting will be included too if possible.  Also, do the
accounting after releasing the mmap_sem.

CC: Brian Cain <bc...@codeaurora.org>
CC: linux-hexa...@vger.kernel.org
Signed-off-by: Peter Xu <pet...@redhat.com>
---
 arch/hexagon/mm/vm_fault.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/hexagon/mm/vm_fault.c b/arch/hexagon/mm/vm_fault.c
index 72334b26317a..5fbccfce6083 100644
--- a/arch/hexagon/mm/vm_fault.c
+++ b/arch/hexagon/mm/vm_fault.c
@@ -39,7 +39,7 @@ void do_page_fault(unsigned long address, long cause, struct 
pt_regs *regs)
        struct mm_struct *mm = current->mm;
        int si_signo;
        int si_code = SEGV_MAPERR;
-       vm_fault_t fault;
+       vm_fault_t fault, major = 0;
        const struct exception_table_entry *fixup;
        unsigned int flags = FAULT_FLAG_DEFAULT;
 
@@ -90,6 +90,7 @@ void do_page_fault(unsigned long address, long cause, struct 
pt_regs *regs)
        }
 
        fault = handle_mm_fault(vma, address, flags);
+       major |= fault & VM_FAULT_MAJOR;
 
        if (fault_signal_pending(fault, regs))
                return;
@@ -97,17 +98,13 @@ void do_page_fault(unsigned long address, long cause, 
struct pt_regs *regs)
        /* The most common case -- we are done. */
        if (likely(!(fault & VM_FAULT_ERROR))) {
                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;
                                goto retry;
                        }
                }
-
                up_read(&mm->mmap_sem);
+               mm_fault_accounting(current, regs, address, major);
                return;
        }
 
-- 
2.26.2

Reply via email to