mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf
@ 2012-03-20 13:25 Kautuk Consul
  2012-03-27  3:18 ` Guan Xuetao
  2012-03-30  4:31 ` Guan Xuetao
  0 siblings, 2 replies; 4+ messages in thread
From: Kautuk Consul @ 2012-03-20 13:25 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: linux-kernel, Kautuk Consul

Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
(mm: retry page fault when blocking on disk transfer) and
commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
(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>
---
 arch/unicore32/mm/fault.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index 283aa4b..db40765 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -169,7 +169,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,
-		struct task_struct *tsk)
+		unsigned int flags, struct task_struct *tsk)
 {
 	struct vm_area_struct *vma;
 	int fault;
@@ -195,14 +195,7 @@ good_area:
 	 * If for any reason at all we couldn't handle the fault, make
 	 * sure we exit gracefully rather than endlessly redo the fault.
 	 */
-	fault = handle_mm_fault(mm, vma, addr & PAGE_MASK,
-			    (!(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++;
+	fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
 	return fault;
 
 check_stack:
@@ -217,6 +210,8 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	struct task_struct *tsk;
 	struct mm_struct *mm;
 	int fault, sig, code;
+	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
+				 ((!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
 
 	tsk = current;
 	mm = tsk->mm;
@@ -237,6 +232,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 		if (!user_mode(regs)
 		    && !search_exception_tables(regs->UCreg_pc))
 			goto no_context;
+retry:
 		down_read(&mm->mmap_sem);
 	} else {
 		/*
@@ -252,7 +248,28 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 #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);
 
 	/*
-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf
  2012-03-20 13:25 [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf Kautuk Consul
@ 2012-03-27  3:18 ` Guan Xuetao
  2012-03-30  4:31 ` Guan Xuetao
  1 sibling, 0 replies; 4+ messages in thread
From: Guan Xuetao @ 2012-03-27  3:18 UTC (permalink / raw)
  To: Kautuk Consul; +Cc: linux-kernel

On 03/20/2012 09:25 PM, Kautuk Consul wrote:
> Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
> (mm: retry page fault when blocking on disk transfer) and
> commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
> (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>
> ---
>
Sorry for replying so late.

I've tested the patch for compilation and running, but not triggered 
VM_FAULT_RETRY.

Regards,

Guan Xuetao

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf
  2012-03-20 13:25 [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf Kautuk Consul
  2012-03-27  3:18 ` Guan Xuetao
@ 2012-03-30  4:31 ` Guan Xuetao
  2012-03-31 10:10   ` Kautuk Consul
  1 sibling, 1 reply; 4+ messages in thread
From: Guan Xuetao @ 2012-03-30  4:31 UTC (permalink / raw)
  To: Kautuk Consul; +Cc: linux-kernel

On 03/20/2012 09:25 PM, Kautuk Consul wrote:
> Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
> (mm: retry page fault when blocking on disk transfer) and
> commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
> (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>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf
  2012-03-30  4:31 ` Guan Xuetao
@ 2012-03-31 10:10   ` Kautuk Consul
  0 siblings, 0 replies; 4+ messages in thread
From: Kautuk Consul @ 2012-03-31 10:10 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: linux-kernel

>> Port these changes to unicore32.
>>
>> Signed-off-by: Kautuk Consul<consul.kautuk@gmail.com>
>> ---
>>
> Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
>
Thanks, Guan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-31 10:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-20 13:25 [PATCH 15/20] unicore32/mm/fault.c: Port OOM changes to do_pf Kautuk Consul
2012-03-27  3:18 ` Guan Xuetao
2012-03-30  4:31 ` Guan Xuetao
2012-03-31 10:10   ` Kautuk Consul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®