Commit 02c88d14 authored by Vineet Gupta's avatar Vineet Gupta

ARC: mm: do_page_fault refactor #4: consolidate retry related logic

stats update code can now elide "retry" check and additional level of
indentation since all retry handling is done ahead of it already
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
parent 85c5e337
...@@ -65,8 +65,8 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) ...@@ -65,8 +65,8 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
struct mm_struct *mm = tsk->mm; struct mm_struct *mm = tsk->mm;
int si_code = SEGV_MAPERR; int si_code = SEGV_MAPERR;
unsigned int write = 0, exec = 0, mask; unsigned int write = 0, exec = 0, mask;
vm_fault_t fault; vm_fault_t fault; /* handle_mm_fault() output */
unsigned int flags; unsigned int flags; /* handle_mm_fault() input */
/* /*
* NOTE! We MUST NOT take any locks for this case. We may * NOTE! We MUST NOT take any locks for this case. We may
...@@ -125,49 +125,51 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) ...@@ -125,49 +125,51 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
goto bad_area; goto bad_area;
} }
/*
* If for any reason at all we couldn't handle the fault,
* make sure we exit gracefully rather than endlessly redo
* the fault.
*/
fault = handle_mm_fault(vma, address, flags); fault = handle_mm_fault(vma, address, flags);
if (fatal_signal_pending(current)) { /*
* Fault retry nuances
*/
if (unlikely(fault & VM_FAULT_RETRY)) {
/* /*
* if fault retry, mmap_sem already relinquished by core mm * If fault needs to be retried, handle any pending signals
* so OK to return to user mode (with signal handled first) * first (by returning to user mode).
* mmap_sem already relinquished by core mm for RETRY case
*/ */
if (fault & VM_FAULT_RETRY) { if (fatal_signal_pending(current)) {
if (!user_mode(regs)) if (!user_mode(regs))
goto no_context; goto no_context;
return; return;
} }
/*
* retry state machine
*/
if (flags & FAULT_FLAG_ALLOW_RETRY) {
flags &= ~FAULT_FLAG_ALLOW_RETRY;
flags |= FAULT_FLAG_TRIED;
goto retry;
}
} }
/*
* Major/minor page fault accounting
* (in case of retry we only land here once)
*/
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
if (likely(!(fault & VM_FAULT_ERROR))) { if (likely(!(fault & VM_FAULT_ERROR))) {
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) {
/* To avoid updating stats twice for retry case */ tsk->maj_flt++;
if (fault & VM_FAULT_MAJOR) { perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
tsk->maj_flt++; regs, address);
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, } else {
regs, address); tsk->min_flt++;
} else { perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
tsk->min_flt++; regs, address);
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
regs, address);
}
if (fault & VM_FAULT_RETRY) {
flags &= ~FAULT_FLAG_ALLOW_RETRY;
flags |= FAULT_FLAG_TRIED;
goto retry;
}
} }
/* Fault Handled Gracefully */ /* Normal return path: fault Handled Gracefully */
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
return; return;
} }
......
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