simple_lmk: Reduce unnecessary wake ups

We can check if the waitqueue is actually active before calling wake_up()
in order to avoid an unnecessary wake_up() if the reclaim thread is already
running. Furthermore, the release barrier when zeroing needs_reclaim is
unnecessary, so remove it.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
fourteen
Sultan Alsawaf 2 years ago committed by Jenna
parent 6434ba1b52
commit 0787646d32
  1. 10
      drivers/android/simple_lmk.c

@ -290,7 +290,7 @@ static int simple_lmk_reclaim_thread(void *data)
while (1) {
wait_event_freezable(oom_waitq, atomic_read(&needs_reclaim));
scan_and_kill();
atomic_set_release(&needs_reclaim, 0);
atomic_set(&needs_reclaim, 0);
}
return 0;
@ -318,8 +318,12 @@ void simple_lmk_mm_freed(struct mm_struct *mm)
static int simple_lmk_vmpressure_cb(struct notifier_block *nb,
unsigned long pressure, void *data)
{
if (pressure == 100 && !atomic_cmpxchg_acquire(&needs_reclaim, 0, 1))
wake_up(&oom_waitq);
if (pressure == 100) {
atomic_set(&needs_reclaim, 1);
smp_mb__after_atomic();
if (waitqueue_active(&oom_waitq))
wake_up(&oom_waitq);
}
return NOTIFY_OK;
}

Loading…
Cancel
Save