Skip to content

Commit 393a86a

Browse files
Kautuk ConsulRichard Kuo
authored andcommitted
hexagon/mm/vm_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 hexagon. Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com> Signed-off-by: Richard Kuo <rkuo@codeaurora.org>
1 parent 222c547 commit 393a86a

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎arch/hexagon/mm/vm_fault.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
5353
int si_code = SEGV_MAPERR;
5454
int fault;
5555
const struct exception_table_entry *fixup;
56+
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
57+
(cause > 0 ? FAULT_FLAG_WRITE : 0);
5658

5759
/*
5860
* If we're in an interrupt or have no user context,
@@ -63,6 +65,7 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
6365

6466
local_irq_enable();
6567

68+
retry:
6669
down_read(&mm->mmap_sem);
6770
vma = find_vma(mm, address);
6871
if (!vma)
@@ -96,14 +99,23 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
9699
break;
97100
}
98101

99-
fault = handle_mm_fault(mm, vma, address, (cause > 0));
102+
fault = handle_mm_fault(mm, vma, address, flags);
103+
104+
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
105+
return;
100106

101107
/* The most common case -- we are done. */
102108
if (likely(!(fault & VM_FAULT_ERROR))) {
103-
if (fault & VM_FAULT_MAJOR)
104-
current->maj_flt++;
105-
else
106-
current->min_flt++;
109+
if (flags & FAULT_FLAG_ALLOW_RETRY) {
110+
if (fault & VM_FAULT_MAJOR)
111+
current->maj_flt++;
112+
else
113+
current->min_flt++;
114+
if (fault & VM_FAULT_RETRY) {
115+
flags &= ~FAULT_FLAG_ALLOW_RETRY;
116+
goto retry;
117+
}
118+
}
107119

108120
up_read(&mm->mmap_sem);
109121
return;

0 commit comments

Comments
 (0)