From 9a2809ba47fc71969090cc55923119de61fdbd28 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Fri, 10 Jul 2020 17:48:15 -0700 Subject: [PATCH] mm/oom_kill: Online memory before running oom-killer Attempt to online memory before invoking the oom-killer to alleviate the memory pressure in the system as quickly as possible, without sacrificing performance/user-experience by invoking the oom-killer. Change-Id: I0cf3c50fcd022cd282731bccb54bfbad45878bb1 Signed-off-by: Isaac J. Manjarres --- mm/oom_kill.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 87541dbe8d8b..a1aca76678ca 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1090,6 +1090,13 @@ bool out_of_memory(struct oom_control *oc) if (oom_killer_disabled) return false; + + if (try_online_one_block(numa_node_id())) { + /* Got some memory back */ + WARN(1, "OOM killer had to online a memory block\n"); + return true; + } + #ifdef CONFIG_PRIORITIZE_OOM_TASKS oc->min_kill_adj = OOM_SCORE_ADJ_MIN; #endif @@ -1157,11 +1164,6 @@ bool out_of_memory(struct oom_control *oc) #endif if (!oc->chosen) { - if (try_online_one_block(numa_node_id())) { - /* Got some memory back */ - WARN(1, "OOM killer had to online a memory block\n"); - return true; - } check_panic_on_oom(oc); select_bad_process(oc); }