Skip to content

Commit 4d5914d

Browse files
Kautuk ConsulJesper Nilsson
authored andcommitted
cris/mm/fault.c: Port OOM changes to do_page_fault
Commit d065bd8 (mm: retry page fault when blocking on disk transfer) and commit 37b23e0 (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 CRIS. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
1 parent dfb73a0 commit 4d5914d

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

‎arch/cris/mm/fault.c‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
5858
struct vm_area_struct * vma;
5959
siginfo_t info;
6060
int fault;
61+
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
62+
((writeaccess & 1) ? FAULT_FLAG_WRITE : 0);
6163

6264
D(printk(KERN_DEBUG
6365
"Page fault for %lX on %X at %lX, prot %d write %d\n",
@@ -115,6 +117,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
115117
if (in_atomic() || !mm)
116118
goto no_context;
117119

120+
retry:
118121
down_read(&mm->mmap_sem);
119122
vma = find_vma(mm, address);
120123
if (!vma)
@@ -163,18 +166,36 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
163166
* the fault.
164167
*/
165168

166-
fault = handle_mm_fault(mm, vma, address, (writeaccess & 1) ? FAULT_FLAG_WRITE : 0);
169+
fault = handle_mm_fault(mm, vma, address, flags);
170+
171+
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
172+
return;
173+
167174
if (unlikely(fault & VM_FAULT_ERROR)) {
168175
if (fault & VM_FAULT_OOM)
169176
goto out_of_memory;
170177
else if (fault & VM_FAULT_SIGBUS)
171178
goto do_sigbus;
172179
BUG();
173180
}
174-
if (fault & VM_FAULT_MAJOR)
175-
tsk->maj_flt++;
176-
else
177-
tsk->min_flt++;
181+
182+
if (flags & FAULT_FLAG_ALLOW_RETRY) {
183+
if (fault & VM_FAULT_MAJOR)
184+
tsk->maj_flt++;
185+
else
186+
tsk->min_flt++;
187+
if (fault & VM_FAULT_RETRY) {
188+
flags &= ~FAULT_FLAG_ALLOW_RETRY;
189+
190+
/*
191+
* No need to up_read(&mm->mmap_sem) as we would
192+
* have already released it in __lock_page_or_retry
193+
* in mm/filemap.c.
194+
*/
195+
196+
goto retry;
197+
}
198+
}
178199

179200
up_read(&mm->mmap_sem);
180201
return;

0 commit comments

Comments
 (0)