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: Prakash Gupta <guptap@codeaurora.org>
Loading
Please register or sign in to comment