mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 16:30:53 +07:00
unicore32/mm/fault.c: Port OOM changes to do_pf
Commitd065bd810b
(mm: retry page fault when blocking on disk transfer) and commit37b23e0525
(x86,mm: make pagefault killable) The above commits introduced changes into the x86 pagefault handler for making the page fault handler retryable as well as killable. These changes reduce the mmap_sem hold time, which is crucial during OOM killer invocation. Port these changes to unicore32. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
This commit is contained in:
parent
0e4a43ed08
commit
f3f09d5a44
@ -168,7 +168,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
|
static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
|
||||||
struct task_struct *tsk)
|
unsigned int flags, struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
struct vm_area_struct *vma;
|
struct vm_area_struct *vma;
|
||||||
int fault;
|
int fault;
|
||||||
@ -194,14 +194,7 @@ static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
|
|||||||
* If for any reason at all we couldn't handle the fault, make
|
* If for any reason at all we couldn't handle the fault, make
|
||||||
* sure we exit gracefully rather than endlessly redo the fault.
|
* sure we exit gracefully rather than endlessly redo the fault.
|
||||||
*/
|
*/
|
||||||
fault = handle_mm_fault(mm, vma, addr & PAGE_MASK,
|
fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
|
||||||
(!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
|
|
||||||
if (unlikely(fault & VM_FAULT_ERROR))
|
|
||||||
return fault;
|
|
||||||
if (fault & VM_FAULT_MAJOR)
|
|
||||||
tsk->maj_flt++;
|
|
||||||
else
|
|
||||||
tsk->min_flt++;
|
|
||||||
return fault;
|
return fault;
|
||||||
|
|
||||||
check_stack:
|
check_stack:
|
||||||
@ -216,6 +209,8 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
|
|||||||
struct task_struct *tsk;
|
struct task_struct *tsk;
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
int fault, sig, code;
|
int fault, sig, code;
|
||||||
|
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
|
||||||
|
((!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
|
||||||
|
|
||||||
tsk = current;
|
tsk = current;
|
||||||
mm = tsk->mm;
|
mm = tsk->mm;
|
||||||
@ -236,6 +231,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
|
|||||||
if (!user_mode(regs)
|
if (!user_mode(regs)
|
||||||
&& !search_exception_tables(regs->UCreg_pc))
|
&& !search_exception_tables(regs->UCreg_pc))
|
||||||
goto no_context;
|
goto no_context;
|
||||||
|
retry:
|
||||||
down_read(&mm->mmap_sem);
|
down_read(&mm->mmap_sem);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -251,7 +247,28 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
fault = __do_pf(mm, addr, fsr, tsk);
|
fault = __do_pf(mm, addr, fsr, flags, tsk);
|
||||||
|
|
||||||
|
/* If we need to retry but a fatal signal is pending, handle the
|
||||||
|
* signal first. We do not need to release the mmap_sem because
|
||||||
|
* it would already be released in __lock_page_or_retry in
|
||||||
|
* mm/filemap.c. */
|
||||||
|
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) {
|
||||||
|
if (fault & VM_FAULT_MAJOR)
|
||||||
|
tsk->maj_flt++;
|
||||||
|
else
|
||||||
|
tsk->min_flt++;
|
||||||
|
if (fault & VM_FAULT_RETRY) {
|
||||||
|
/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
|
||||||
|
* of starvation. */
|
||||||
|
flags &= ~FAULT_FLAG_ALLOW_RETRY;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
up_read(&mm->mmap_sem);
|
up_read(&mm->mmap_sem);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user