lmkd: fix log message reporting the breached watermark
Wrong condition causes reporting low watermark breach when min watermark
is breached and visa versa. Fix the condition to make reporting correct.
Bug: 181778155
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I684141c38f961fce99d17cfb3a83706fcd84ea10
diff --git a/lmkd.cpp b/lmkd.cpp
index 68f96f6..034b44f 100644
--- a/lmkd.cpp
+++ b/lmkd.cpp
@@ -2508,7 +2508,7 @@
/* Both free memory and swap are low */
kill_reason = LOW_MEM_AND_SWAP;
snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and swap is low (%"
- PRId64 "kB < %" PRId64 "kB)", wmark > WMARK_LOW ? "min" : "low",
+ PRId64 "kB < %" PRId64 "kB)", wmark < WMARK_LOW ? "min" : "low",
mi.field.free_swap * page_k, swap_low_threshold * page_k);
/* Do not kill perceptible apps unless below min watermark */
if (wmark > WMARK_MIN) {
@@ -2522,13 +2522,13 @@
*/
kill_reason = LOW_MEM_AND_SWAP_UTIL;
snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and swap utilization"
- " is high (%d%% > %d%%)", wmark > WMARK_LOW ? "min" : "low",
+ " is high (%d%% > %d%%)", wmark < WMARK_LOW ? "min" : "low",
swap_util, swap_util_max);
} else if (wmark < WMARK_HIGH && thrashing > thrashing_limit) {
/* Page cache is thrashing while memory is low */
kill_reason = LOW_MEM_AND_THRASHING;
snprintf(kill_desc, sizeof(kill_desc), "%s watermark is breached and thrashing (%"
- PRId64 "%%)", wmark > WMARK_LOW ? "min" : "low", thrashing);
+ PRId64 "%%)", wmark < WMARK_LOW ? "min" : "low", thrashing);
cut_thrashing_limit = true;
/* Do not kill perceptible apps because of thrashing */
min_score_adj = PERCEPTIBLE_APP_ADJ + 1;