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 <sultan@kerneltoast.com>
fourteen
Sultan Alsawaf 3 years ago committed by Jenna
parent 3e49dbc48e
commit 88133c3016
  1. 4
      drivers/android/simple_lmk.c

@ -5,6 +5,7 @@
#define pr_fmt(fmt) "simple_lmk: " fmt
#include <linux/freezer.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/moduleparam.h>
@ -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);
}

Loading…
Cancel
Save