From 2e24da16e2acd054d0c9218b0545108c237f38f0 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 18 Sep 2021 21:43:38 -0700 Subject: [PATCH] simple_lmk: Thaw victims upon killing them With freezable cgroups and their recent utilization in Android, it's possible for some of Simple LMK's victims to be frozen at the time that they're selected for killing. The forced SIGKILL used for killing victims can only wake up processes containing TASK_WAKEKILL and/or TASK_INTERRUPTIBLE, not TASK_UNINTERRUPTIBLE, which is the state used on frozen tasks. In order to wake frozen tasks from their uninterruptible slumber so that they can die, we must thaw them. Leaving victims frozen can otherwise make them take an indefinite amount of time to process our SIGKILL and thus free memory. Signed-off-by: Sultan Alsawaf --- drivers/android/simple_lmk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/android/simple_lmk.c b/drivers/android/simple_lmk.c index 0ed723bc0043..7afd721845bf 100644 --- a/drivers/android/simple_lmk.c +++ b/drivers/android/simple_lmk.c @@ -248,6 +248,9 @@ static void scan_and_kill(void) /* Allow the victim to run on any CPU. This won't schedule. */ set_cpus_allowed_ptr(vtsk, cpu_all_mask); + /* Signals can't wake frozen tasks; only a thaw operation can */ + __thaw_task(vtsk); + /* Finally release the victim's task lock acquired earlier */ task_unlock(vtsk); }