Commit 52e3f8d0 authored by Peter Xu's avatar Peter Xu Committed by Linus Torvalds

mm/arc: use general page fault accounting

Use the general page fault accounting by passing regs into
handle_mm_fault().  It naturally solve the issue of multiple page fault
accounting when page fault retry happened.

Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries,
by moving it before taking mmap_sem.
Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Vineet Gupta <vgupta@synopsys.com>
Link: http://lkml.kernel.org/r/20200707225021.200906-4-peterx@redhat.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c0f6eda4
...@@ -105,6 +105,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) ...@@ -105,6 +105,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
if (write) if (write)
flags |= FAULT_FLAG_WRITE; flags |= FAULT_FLAG_WRITE;
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
retry: retry:
mmap_read_lock(mm); mmap_read_lock(mm);
...@@ -130,7 +131,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) ...@@ -130,7 +131,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
goto bad_area; goto bad_area;
} }
fault = handle_mm_fault(vma, address, flags, NULL); fault = handle_mm_fault(vma, address, flags, regs);
/* Quick path to respond to signals */ /* Quick path to respond to signals */
if (fault_signal_pending(fault, regs)) { if (fault_signal_pending(fault, regs)) {
...@@ -155,22 +156,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) ...@@ -155,22 +156,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
* Major/minor page fault accounting * Major/minor page fault accounting
* (in case of retry we only land here once) * (in case of retry we only land here once)
*/ */
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); if (likely(!(fault & VM_FAULT_ERROR)))
if (likely(!(fault & VM_FAULT_ERROR))) {
if (fault & VM_FAULT_MAJOR) {
tsk->maj_flt++;
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
regs, address);
} else {
tsk->min_flt++;
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
regs, address);
}
/* Normal return path: fault Handled Gracefully */ /* Normal return path: fault Handled Gracefully */
return; return;
}
if (!user_mode(regs)) if (!user_mode(regs))
goto no_context; goto no_context;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment