aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2011-05-24 20:11:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 11:39:08 -0400
commit37b23e0525d393d48a7d59f870b3bc061a30ccdb (patch)
tree467e6fcd785108a21d836e1aad8fc1a68aa72e17 /mm/filemap.c
parentf62e00cc3a00bfbd394a79fc22b334c31f91bd5f (diff)
x86,mm: make pagefault killable
When an oom killing occurs, almost all processes are getting stuck at the following two points. 1) __alloc_pages_nodemask 2) __lock_page_or_retry 1) is not very problematic because TIF_MEMDIE leads to an allocation failure and getting out from page allocator. 2) is more problematic. In an OOM situation, zones typically don't have page cache at all and memory starvation might lead to greatly reduced IO performance. When a fork bomb occurs, TIF_MEMDIE tasks don't die quickly, meaning that a fork bomb may create new process quickly rather than the oom-killer killing it. Then, the system may become livelocked. This patch makes the pagefault interruptible by SIGKILL. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: Matthew Wilcox <willy@linux.intel.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index dea8a38bb2bb..8144f87dcbb4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -654,15 +654,32 @@ EXPORT_SYMBOL_GPL(__lock_page_killable);
654int __lock_page_or_retry(struct page *page, struct mm_struct *mm, 654int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
655 unsigned int flags) 655 unsigned int flags)
656{ 656{
657 if (!(flags & FAULT_FLAG_ALLOW_RETRY)) { 657 if (flags & FAULT_FLAG_ALLOW_RETRY) {
658 __lock_page(page); 658 /*
659 return 1; 659 * CAUTION! In this case, mmap_sem is not released
660 } else { 660 * even though return 0.
661 if (!(flags & FAULT_FLAG_RETRY_NOWAIT)) { 661 */
662 up_read(&mm->mmap_sem); 662 if (flags & FAULT_FLAG_RETRY_NOWAIT)
663 return 0;
664
665 up_read(&mm->mmap_sem);
666 if (flags & FAULT_FLAG_KILLABLE)
667 wait_on_page_locked_killable(page);
668 else
663 wait_on_page_locked(page); 669 wait_on_page_locked(page);
664 }
665 return 0; 670 return 0;
671 } else {
672 if (flags & FAULT_FLAG_KILLABLE) {
673 int ret;
674
675 ret = __lock_page_killable(page);
676 if (ret) {
677 up_read(&mm->mmap_sem);
678 return 0;
679 }
680 } else
681 __lock_page(page);
682 return 1;
666 } 683 }
667} 684}
668 685