mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-08 07:38:10 +00:00
sparc/mm/fault_32.c: Port OOM changes to do_sparc_fault
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 32-bit sparc. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7358e51082
commit
c29554f53e
1 changed files with 30 additions and 7 deletions
|
@ -225,6 +225,8 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
|
||||||
unsigned long g2;
|
unsigned long g2;
|
||||||
int from_user = !(regs->psr & PSR_PS);
|
int from_user = !(regs->psr & PSR_PS);
|
||||||
int fault, code;
|
int fault, code;
|
||||||
|
unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
|
||||||
|
(write ? FAULT_FLAG_WRITE : 0));
|
||||||
|
|
||||||
if(text_fault)
|
if(text_fault)
|
||||||
address = regs->pc;
|
address = regs->pc;
|
||||||
|
@ -251,6 +253,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
|
||||||
|
|
||||||
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
|
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
|
||||||
|
|
||||||
|
retry:
|
||||||
down_read(&mm->mmap_sem);
|
down_read(&mm->mmap_sem);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -289,7 +292,11 @@ good_area:
|
||||||
* make sure we exit gracefully rather than endlessly redo
|
* make sure we exit gracefully rather than endlessly redo
|
||||||
* the fault.
|
* the fault.
|
||||||
*/
|
*/
|
||||||
fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0);
|
fault = handle_mm_fault(mm, vma, address, flags);
|
||||||
|
|
||||||
|
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
|
||||||
|
return;
|
||||||
|
|
||||||
if (unlikely(fault & VM_FAULT_ERROR)) {
|
if (unlikely(fault & VM_FAULT_ERROR)) {
|
||||||
if (fault & VM_FAULT_OOM)
|
if (fault & VM_FAULT_OOM)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
@ -297,13 +304,29 @@ good_area:
|
||||||
goto do_sigbus;
|
goto do_sigbus;
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & FAULT_FLAG_ALLOW_RETRY) {
|
||||||
if (fault & VM_FAULT_MAJOR) {
|
if (fault & VM_FAULT_MAJOR) {
|
||||||
current->maj_flt++;
|
current->maj_flt++;
|
||||||
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
|
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
|
||||||
|
1, regs, address);
|
||||||
} else {
|
} else {
|
||||||
current->min_flt++;
|
current->min_flt++;
|
||||||
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
|
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
|
||||||
|
1, regs, address);
|
||||||
}
|
}
|
||||||
|
if (fault & VM_FAULT_RETRY) {
|
||||||
|
flags &= ~FAULT_FLAG_ALLOW_RETRY;
|
||||||
|
|
||||||
|
/* No need to up_read(&mm->mmap_sem) as we would
|
||||||
|
* have already released it in __lock_page_or_retry
|
||||||
|
* in mm/filemap.c.
|
||||||
|
*/
|
||||||
|
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
up_read(&mm->mmap_sem);
|
up_read(&mm->mmap_sem);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue