From 5263aa78001891243013dd4d597f2e949711c68e Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Thu, 29 Apr 2021 15:28:57 -0700 Subject: [PATCH] lmkd: Do not treat RSS=0 as a sign of a process being dead With kernel SPLIT_RSS_COUNTING feature it is possible for a valid process to report RSS of 0 size when reading /proc/pid/statm. This happens because split RSS accounting aggregates per-thread counters asynchronously and depending on the timing of the read, reported value can be inaccurate and occasionally be 0. lmkd currently treats processes reporting RSS of 0 as dead and removes them from the list of processes being tracked. This might lead to a valid process becoming unkillable. Change lmkd to stop treating RSS of 0 as a sign of a dead process. Bug: 160199622 Test: set ro.lmk.kill_heaviest_task=true and hack kernel to report RSS=0 Signed-off-by: Suren Baghdasaryan Change-Id: Ia311d2f98649c92d1a487657f94ea51f57813b73 --- lmkd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmkd.cpp b/lmkd.cpp index 7ea7c2c..e1c5276 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -1898,7 +1898,7 @@ static struct proc *proc_get_heaviest(int oomadj) { while (curr != head) { int pid = ((struct proc *)curr)->pid; int tasksize = proc_get_size(pid); - if (tasksize <= 0) { + if (tasksize < 0) { struct adjslot_list *next = curr->next; pid_remove(pid); curr = next;