[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210921165758.6154-1-sultan@kerneltoast.com>
Date: Tue, 21 Sep 2021 09:57:58 -0700
From: Sultan Alsawaf <sultan@...neltoast.com>
To: sultan@...neltoast.com
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, mgorman@...e.de, mhocko@...e.com,
rientjes@...gle.com
Subject: [PATCH v2] mm: Mark the OOM reaper thread as freezable
From: Sultan Alsawaf <sultan@...neltoast.com>
The OOM reaper alters user address space which might theoretically alter
the snapshot if reaping is allowed to happen after the freezer quiescent
state. To this end, the reaper kthread uses wait_event_freezable() while
waiting for any work so that it cannot run while the system freezes.
However, the current implementation doesn't respect the freezer because
all kernel threads are created with the PF_NOFREEZE flag, so they are
automatically excluded from freezing operations. This means that the OOM
reaper can race with system snapshotting if it has work to do while the
system is being frozen.
Fix this by adding a set_freezable() call which will clear the
PF_NOFREEZE flag and thus make the OOM reaper visible to the freezer.
Please note that the OOM reaper altering the snapshot this way is mostly
a theoretical concern and has not been observed in practice.
Fixes: aac453635549 ("mm, oom: introduce oom reaper")
Signed-off-by: Sultan Alsawaf <sultan@...neltoast.com>
Acked-by: Michal Hocko <mhocko@...e.com>
---
mm/oom_kill.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 831340e7ad8b..46a742b57735 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -641,6 +641,8 @@ static void oom_reap_task(struct task_struct *tsk)
static int oom_reaper(void *unused)
{
+ set_freezable();
+
while (true) {
struct task_struct *tsk = NULL;
--
2.33.0
Powered by blists - more mailing lists