Skip to content

Commit 3723929

Browse files
kerneltoasttorvalds
authored andcommitted
mm: mark the OOM reaper thread as freezable
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. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: aac4536 ("mm, oom: introduce oom reaper") Signed-off-by: Sultan Alsawaf <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: David Rientjes <[email protected]> Cc: Mel Gorman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4421cca commit 3723929

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/oom_kill.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ static void oom_reap_task(struct task_struct *tsk)
641641

642642
static int oom_reaper(void *unused)
643643
{
644+
set_freezable();
645+
644646
while (true) {
645647
struct task_struct *tsk = NULL;
646648

0 commit comments

Comments
 (0)