From 88133c3016490208c08b96fa1fb509895ed7979f Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 18 Sep 2021 21:19:22 -0700 Subject: [PATCH] simple_lmk: Make the reclaim thread freezable There are two problems with the current uninterruptible wait used in the reclaim thread: the hung task detector is upset about an uninterruptible thread being asleep for so long, and killing processes can generate I/O. Since killing a process can generate I/O, the reclaim thread should participate in system-wide suspend operations. This neatly solves the hung task detector issue since wait_event_freezable() puts the current process into an interruptible sleep. Signed-off-by: Sultan Alsawaf --- drivers/android/simple_lmk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/android/simple_lmk.c b/drivers/android/simple_lmk.c index 3ed9182c1d42..0ed723bc0043 100644 --- a/drivers/android/simple_lmk.c +++ b/drivers/android/simple_lmk.c @@ -5,6 +5,7 @@ #define pr_fmt(fmt) "simple_lmk: " fmt +#include #include #include #include @@ -270,9 +271,10 @@ static int simple_lmk_reclaim_thread(void *data) }; sched_setscheduler_nocheck(current, SCHED_FIFO, &sched_max_rt_prio); + set_freezable(); while (1) { - wait_event(oom_waitq, atomic_read(&needs_reclaim)); + wait_event_freezable(oom_waitq, atomic_read(&needs_reclaim)); scan_and_kill(); atomic_set_release(&needs_reclaim, 0); }