diff options
author | David Rientjes <rientjes@google.com> | 2012-12-12 16:52:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 20:38:34 -0500 |
commit | efacd02e4f57d94e934ba5c84f10f8ce91158770 (patch) | |
tree | b6ee63cc384d68a3904d5e5531ae69f8d4659546 /mm/oom_kill.c | |
parent | 09285af75d1682d8642607941ca6034ea1b159eb (diff) |
mm, oom: cleanup pagefault oom handler
To lock the entire system from parallel oom killing, it's possible to pass
in a zonelist with all zones rather than using for_each_populated_zone()
for the iteration. This obsoletes try_set_system_oom() and
clear_system_oom() so that they can be removed.
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r-- | mm/oom_kill.c | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index fe36205a7f8a..0e30ff7b21c5 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -591,43 +591,6 @@ void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask) | |||
591 | spin_unlock(&zone_scan_lock); | 591 | spin_unlock(&zone_scan_lock); |
592 | } | 592 | } |
593 | 593 | ||
594 | /* | ||
595 | * Try to acquire the oom killer lock for all system zones. Returns zero if a | ||
596 | * parallel oom killing is taking place, otherwise locks all zones and returns | ||
597 | * non-zero. | ||
598 | */ | ||
599 | static int try_set_system_oom(void) | ||
600 | { | ||
601 | struct zone *zone; | ||
602 | int ret = 1; | ||
603 | |||
604 | spin_lock(&zone_scan_lock); | ||
605 | for_each_populated_zone(zone) | ||
606 | if (zone_is_oom_locked(zone)) { | ||
607 | ret = 0; | ||
608 | goto out; | ||
609 | } | ||
610 | for_each_populated_zone(zone) | ||
611 | zone_set_flag(zone, ZONE_OOM_LOCKED); | ||
612 | out: | ||
613 | spin_unlock(&zone_scan_lock); | ||
614 | return ret; | ||
615 | } | ||
616 | |||
617 | /* | ||
618 | * Clears ZONE_OOM_LOCKED for all system zones so that failed allocation | ||
619 | * attempts or page faults may now recall the oom killer, if necessary. | ||
620 | */ | ||
621 | static void clear_system_oom(void) | ||
622 | { | ||
623 | struct zone *zone; | ||
624 | |||
625 | spin_lock(&zone_scan_lock); | ||
626 | for_each_populated_zone(zone) | ||
627 | zone_clear_flag(zone, ZONE_OOM_LOCKED); | ||
628 | spin_unlock(&zone_scan_lock); | ||
629 | } | ||
630 | |||
631 | /** | 594 | /** |
632 | * out_of_memory - kill the "best" process when we run out of memory | 595 | * out_of_memory - kill the "best" process when we run out of memory |
633 | * @zonelist: zonelist pointer | 596 | * @zonelist: zonelist pointer |
@@ -708,15 +671,17 @@ out: | |||
708 | 671 | ||
709 | /* | 672 | /* |
710 | * The pagefault handler calls here because it is out of memory, so kill a | 673 | * The pagefault handler calls here because it is out of memory, so kill a |
711 | * memory-hogging task. If a populated zone has ZONE_OOM_LOCKED set, a parallel | 674 | * memory-hogging task. If any populated zone has ZONE_OOM_LOCKED set, a |
712 | * oom killing is already in progress so do nothing. If a task is found with | 675 | * parallel oom killing is already in progress so do nothing. |
713 | * TIF_MEMDIE set, it has been killed so do nothing and allow it to exit. | ||
714 | */ | 676 | */ |
715 | void pagefault_out_of_memory(void) | 677 | void pagefault_out_of_memory(void) |
716 | { | 678 | { |
717 | if (try_set_system_oom()) { | 679 | struct zonelist *zonelist = node_zonelist(first_online_node, |
680 | GFP_KERNEL); | ||
681 | |||
682 | if (try_set_zonelist_oom(zonelist, GFP_KERNEL)) { | ||
718 | out_of_memory(NULL, 0, 0, NULL, false); | 683 | out_of_memory(NULL, 0, 0, NULL, false); |
719 | clear_system_oom(); | 684 | clear_zonelist_oom(zonelist, GFP_KERNEL); |
720 | } | 685 | } |
721 | schedule_timeout_killable(1); | 686 | schedule_timeout_killable(1); |
722 | } | 687 | } |