aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2010-08-09 20:18:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-09 23:44:57 -0400
commit0aad4b3124850e85fe54e610802f0917ce46a1ae (patch)
treeebba56659dab4e285b87341d7639fda7a2db81e9 /mm
parentf44200320b10c76003101dee21c5f961e80faf0b (diff)
oom: fold __out_of_memory into out_of_memory
__out_of_memory() only has a single caller, so fold it into out_of_memory() and add a comment about locking for its call to oom_kill_process(). Signed-off-by: David Rientjes <rientjes@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/oom_kill.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index cba18c06e50..26ae6975fa3 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -628,41 +628,6 @@ static void clear_system_oom(void)
628 spin_unlock(&zone_scan_lock); 628 spin_unlock(&zone_scan_lock);
629} 629}
630 630
631
632/*
633 * Must be called with tasklist_lock held for read.
634 */
635static void __out_of_memory(gfp_t gfp_mask, int order, const nodemask_t *mask)
636{
637 struct task_struct *p;
638 unsigned long points;
639
640 if (sysctl_oom_kill_allocating_task)
641 if (!oom_kill_process(current, gfp_mask, order, 0, NULL,
642 "Out of memory (oom_kill_allocating_task)"))
643 return;
644retry:
645 /*
646 * Rambo mode: Shoot down a process and hope it solves whatever
647 * issues we may have.
648 */
649 p = select_bad_process(&points, NULL, mask);
650
651 if (PTR_ERR(p) == -1UL)
652 return;
653
654 /* Found nothing?!?! Either we hang forever, or we panic. */
655 if (!p) {
656 dump_header(NULL, gfp_mask, order, NULL);
657 read_unlock(&tasklist_lock);
658 panic("Out of memory and no killable processes...\n");
659 }
660
661 if (oom_kill_process(p, gfp_mask, order, points, NULL,
662 "Out of memory"))
663 goto retry;
664}
665
666/** 631/**
667 * out_of_memory - kill the "best" process when we run out of memory 632 * out_of_memory - kill the "best" process when we run out of memory
668 * @zonelist: zonelist pointer 633 * @zonelist: zonelist pointer
@@ -678,7 +643,9 @@ retry:
678void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, 643void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
679 int order, nodemask_t *nodemask) 644 int order, nodemask_t *nodemask)
680{ 645{
646 struct task_struct *p;
681 unsigned long freed = 0; 647 unsigned long freed = 0;
648 unsigned long points;
682 enum oom_constraint constraint = CONSTRAINT_NONE; 649 enum oom_constraint constraint = CONSTRAINT_NONE;
683 650
684 blocking_notifier_call_chain(&oom_notify_list, 0, &freed); 651 blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
@@ -703,10 +670,36 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
703 if (zonelist) 670 if (zonelist)
704 constraint = constrained_alloc(zonelist, gfp_mask, nodemask); 671 constraint = constrained_alloc(zonelist, gfp_mask, nodemask);
705 check_panic_on_oom(constraint, gfp_mask, order); 672 check_panic_on_oom(constraint, gfp_mask, order);
673
706 read_lock(&tasklist_lock); 674 read_lock(&tasklist_lock);
707 __out_of_memory(gfp_mask, order, 675 if (sysctl_oom_kill_allocating_task) {
676 /*
677 * oom_kill_process() needs tasklist_lock held. If it returns
678 * non-zero, current could not be killed so we must fallback to
679 * the tasklist scan.
680 */
681 if (!oom_kill_process(current, gfp_mask, order, 0, NULL,
682 "Out of memory (oom_kill_allocating_task)"))
683 return;
684 }
685
686retry:
687 p = select_bad_process(&points, NULL,
708 constraint == CONSTRAINT_MEMORY_POLICY ? nodemask : 688 constraint == CONSTRAINT_MEMORY_POLICY ? nodemask :
709 NULL); 689 NULL);
690 if (PTR_ERR(p) == -1UL)
691 return;
692
693 /* Found nothing?!?! Either we hang forever, or we panic. */
694 if (!p) {
695 dump_header(NULL, gfp_mask, order, NULL);
696 read_unlock(&tasklist_lock);
697 panic("Out of memory and no killable processes...\n");
698 }
699
700 if (oom_kill_process(p, gfp_mask, order, points, NULL,
701 "Out of memory"))
702 goto retry;
710 read_unlock(&tasklist_lock); 703 read_unlock(&tasklist_lock);
711 704
712 /* 705 /*