Skip to content
Commit 364bedd3 authored by Prakash Gupta's avatar Prakash Gupta
Browse files

lowmemorykiller: fix scan_mutex contention



A livelock can be created in the system by lowmemorykiller trying to kill
the same task again and again.  Below is the livelock condition.

P0 -> binder_main_lock(W)
P1 -> binder_main_lock(T)-> mmap_sem(W)
P2 -> mmap_sem(T) -> lowmem_scan::scan_mutex(W)
P3 -> lowmem_scan::scan_mutex(T) -> send SIGKILL P0

Here multiple tasks are contending on scan_mutex, and binder_main_lock.
Change lowmem_scan mutex_lock with mutex_trylock, so in case of lowmem_scan
lock contention, task will be allowed to reclaim from other shrinkers. This
will also maintain the serialization of lowmemorykiller trigger.

If a task is pending MEMDIE'ing, remove sleep before falling back on other
shrinkers.

If the task selected to be killed is MEMDIE'ing and in un-interruptible
sleep state, do not repeat kill but fallback on other shrinkers without any
delay.

Change-Id: I12131622f7fa7b422c6d5d09f782af848300e412
[guptap: update TIF_MEMDIE check with test lmk_waiting]
Signed-off-by: default avatarPrakash Gupta <guptap@codeaurora.org>
parent e06ba2c4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment