Skip to content

Commit 4971f2b

Browse files
Kautuk ConsulJonas Bonn
authored andcommitted
openrisc/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 openrisc. Signed-off-by: Mohd. Faris <mohdfarisq2010@gmail.com> Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Signed-off-by: Jonas Bonn <jonas@southpole.se>
1 parent ad188f9 commit 4971f2b

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

‎arch/openrisc/mm/fault.c‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
5454
struct vm_area_struct *vma;
5555
siginfo_t info;
5656
int fault;
57+
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
5758

5859
tsk = current;
5960

@@ -105,6 +106,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
105106
if (in_interrupt() || !mm)
106107
goto no_context;
107108

109+
retry:
108110
down_read(&mm->mmap_sem);
109111
vma = find_vma(mm, address);
110112

@@ -143,6 +145,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
143145
if (write_acc) {
144146
if (!(vma->vm_flags & VM_WRITE))
145147
goto bad_area;
148+
flags |= FAULT_FLAG_WRITE;
146149
} else {
147150
/* not present */
148151
if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
@@ -159,19 +162,36 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
159162
* the fault.
160163
*/
161164

162-
fault = handle_mm_fault(mm, vma, address, write_acc);
165+
fault = handle_mm_fault(mm, vma, address, flags);
166+
167+
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
168+
return;
169+
163170
if (unlikely(fault & VM_FAULT_ERROR)) {
164171
if (fault & VM_FAULT_OOM)
165172
goto out_of_memory;
166173
else if (fault & VM_FAULT_SIGBUS)
167174
goto do_sigbus;
168175
BUG();
169176
}
170-
/*RGD modeled on Cris */
171-
if (fault & VM_FAULT_MAJOR)
172-
tsk->maj_flt++;
173-
else
174-
tsk->min_flt++;
177+
178+
if (flags & FAULT_FLAG_ALLOW_RETRY) {
179+
/*RGD modeled on Cris */
180+
if (fault & VM_FAULT_MAJOR)
181+
tsk->maj_flt++;
182+
else
183+
tsk->min_flt++;
184+
if (fault & VM_FAULT_RETRY) {
185+
flags &= ~FAULT_FLAG_ALLOW_RETRY;
186+
187+
/* No need to up_read(&mm->mmap_sem) as we would
188+
* have already released it in __lock_page_or_retry
189+
* in mm/filemap.c.
190+
*/
191+
192+
goto retry;
193+
}
194+
}
175195

176196
up_read(&mm->mmap_sem);
177197
return;

0 commit comments

Comments
 (0)