Commit efacd02e authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

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: default avatarDavid Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: default avatarMichal Hocko <mhocko@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 09285af7
...@@ -591,43 +591,6 @@ void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask) ...@@ -591,43 +591,6 @@ void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask)
spin_unlock(&zone_scan_lock); spin_unlock(&zone_scan_lock);
} }
/*
* Try to acquire the oom killer lock for all system zones. Returns zero if a
* parallel oom killing is taking place, otherwise locks all zones and returns
* non-zero.
*/
static int try_set_system_oom(void)
{
struct zone *zone;
int ret = 1;
spin_lock(&zone_scan_lock);
for_each_populated_zone(zone)
if (zone_is_oom_locked(zone)) {
ret = 0;
goto out;
}
for_each_populated_zone(zone)
zone_set_flag(zone, ZONE_OOM_LOCKED);
out:
spin_unlock(&zone_scan_lock);
return ret;
}
/*
* Clears ZONE_OOM_LOCKED for all system zones so that failed allocation
* attempts or page faults may now recall the oom killer, if necessary.
*/
static void clear_system_oom(void)
{
struct zone *zone;
spin_lock(&zone_scan_lock);
for_each_populated_zone(zone)
zone_clear_flag(zone, ZONE_OOM_LOCKED);
spin_unlock(&zone_scan_lock);
}
/** /**
* out_of_memory - kill the "best" process when we run out of memory * out_of_memory - kill the "best" process when we run out of memory
* @zonelist: zonelist pointer * @zonelist: zonelist pointer
...@@ -708,15 +671,17 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, ...@@ -708,15 +671,17 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
/* /*
* The pagefault handler calls here because it is out of memory, so kill a * The pagefault handler calls here because it is out of memory, so kill a
* memory-hogging task. If a populated zone has ZONE_OOM_LOCKED set, a parallel * memory-hogging task. If any populated zone has ZONE_OOM_LOCKED set, a
* oom killing is already in progress so do nothing. If a task is found with * parallel oom killing is already in progress so do nothing.
* TIF_MEMDIE set, it has been killed so do nothing and allow it to exit.
*/ */
void pagefault_out_of_memory(void) void pagefault_out_of_memory(void)
{ {
if (try_set_system_oom()) { struct zonelist *zonelist = node_zonelist(first_online_node,
GFP_KERNEL);
if (try_set_zonelist_oom(zonelist, GFP_KERNEL)) {
out_of_memory(NULL, 0, 0, NULL, false); out_of_memory(NULL, 0, 0, NULL, false);
clear_system_oom(); clear_zonelist_oom(zonelist, GFP_KERNEL);
} }
schedule_timeout_killable(1); schedule_timeout_killable(1);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment