From 20de82dde24f5097d777b7a2681623b06a6f5206 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Mon, 1 Apr 2024 14:04:49 -0700 Subject: [PATCH] lmkd: update watermarks before the first kill Change-Id: Ie8080fd8995c54fc8c1f5b94e77dbf32e33783fe Signed-off-by: Suren Baghdasaryan --- lmkd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lmkd.cpp b/lmkd.cpp index f162f6c..8b0055e 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -2807,6 +2807,7 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_ max_thrashing = thrashing; } +update_watermarks: /* * Refresh watermarks once per min in case user updated one of the margins. * TODO: b/140521024 replace this periodic update with an API for AMS to notify LMKD @@ -2942,6 +2943,14 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_ .thrashing = (int)thrashing, .max_thrashing = max_thrashing, }; + static bool first_kill = true; + + /* Make sure watermarks are correct before the first kill */ + if (first_kill) { + first_kill = false; + watermarks.high_wmark = 0; // force recomputation + goto update_watermarks; + } /* Allow killing perceptible apps if the system is stalled */ if (critical_stall) {