diff mbox series

[v2] mm, oom: OOM sysrq should always kill a process

Message ID 20220106102027.634842-1-jannh@google.com (mailing list archive)
State New
Headers show
Series [v2] mm, oom: OOM sysrq should always kill a process | expand

Commit Message

Jann Horn Jan. 6, 2022, 10:20 a.m. UTC
The OOM kill sysrq (alt+sysrq+F) should allow the user to kill the
process with the highest OOM badness with a single execution.

However, at the moment, the OOM kill can bail out if an OOM notifier
(e.g. the i915 one) says that it reclaimed a tiny amount of memory
from somewhere. That's probably not what the user wants.

As documented in struct oom_control, order == -1 means the oom kill is
required by sysrq. So check for that, and if it's true, don't bail out
no matter what the OOM notifiers say.

Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Jann Horn <jannh@google.com>
---
 mm/oom_kill.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: c9e6606c7fe92b50a02ce51dda82586ebdf99b48

Comments

Jann Horn Jan. 6, 2022, 10:22 a.m. UTC | #1
On Thu, Jan 6, 2022 at 11:21 AM Jann Horn <jannh@google.com> wrote:
> The OOM kill sysrq (alt+sysrq+F) should allow the user to kill the
> process with the highest OOM badness with a single execution.
>
> However, at the moment, the OOM kill can bail out if an OOM notifier
> (e.g. the i915 one) says that it reclaimed a tiny amount of memory
> from somewhere. That's probably not what the user wants.
>
> As documented in struct oom_control, order == -1 means the oom kill is
> required by sysrq. So check for that, and if it's true, don't bail out
> no matter what the OOM notifiers say.

Er, sorry, I just noticed after sending this that the commit message
doesn't make sense anymore... I'll send a new version in a sec.
diff mbox series

Patch

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1ddabefcfb5a..3c480b24a93c 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1057,7 +1057,7 @@  bool out_of_memory(struct oom_control *oc)
 
 	if (!is_memcg_oom(oc)) {
 		blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
-		if (freed > 0)
+		if (freed > 0 && !is_sysrq_oom(oc))
 			/* Got some memory back in the last second. */
 			return true;
 	}