lmkd: Do not re-initialize lmkd when persistent properties are loaded

When a device boots, lmkd starts before persistent properties are loaded,
therefore if experiments set any flags, the corresponding persistent
properties will trigger change notifications when they are first loaded
during boot.
In order to prevent lmkd from re-initializing on every property load,
mark persistent property change by setting lmkd.reinit to 0 and delay
lmkd re-initialization until sys.boot_completed=1 when all properties
are set and only one re-initialization will capture them all. On devices
with no experiment flags being set lmkd.reinit will be undefined at the
boot completion time and re-initialization will not be triggered at all.

Bug: 194316048
Test: adb shell device_config put lmkd_native thrashing_limit_critical 350
Test: adb shell device_config put lmkd_native thrashing_limit 100
Test: adb reboot; adb -b all logcat | grep lmkd
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iba34fc719a18d58b890549c7415bec869d471901
This commit is contained in:
Suren Baghdasaryan 2021-09-01 00:49:51 -07:00
parent d0a800402c
commit 0e64eadc21
2 changed files with 19 additions and 13 deletions

View File

@ -3482,7 +3482,7 @@ static void update_props() {
int main(int argc, char **argv) { int main(int argc, char **argv) {
if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) { if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
if (property_set(LMKD_REINIT_PROP, "0")) { if (property_set(LMKD_REINIT_PROP, "")) {
ALOGE("Failed to reset " LMKD_REINIT_PROP " property"); ALOGE("Failed to reset " LMKD_REINIT_PROP " property");
} }
return issue_reinit(); return issue_reinit();

30
lmkd.rc
View File

@ -10,36 +10,42 @@ service lmkd /system/bin/lmkd
on property:lmkd.reinit=1 on property:lmkd.reinit=1
exec_background /system/bin/lmkd --reinit exec_background /system/bin/lmkd --reinit
# properties most likely to be used in experiments # reinitialize lmkd after device finished booting if experiments set any flags during boot
on property:persist.device_config.lmkd_native.debug=* on property:sys.boot_completed=1 && property:lmkd.reinit=0
setprop lmkd.reinit 1 setprop lmkd.reinit 1
# properties most likely to be used in experiments
# setting persist.device_config.* property either triggers immediate lmkd re-initialization
# if the device finished booting or sets lmkd.reinit=0 to re-initialize lmkd after boot completes
on property:persist.device_config.lmkd_native.debug=*
setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.kill_heaviest_task=* on property:persist.device_config.lmkd_native.kill_heaviest_task=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.kill_timeout_ms=* on property:persist.device_config.lmkd_native.kill_timeout_ms=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.swap_free_low_percentage=* on property:persist.device_config.lmkd_native.swap_free_low_percentage=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.psi_partial_stall_ms=* on property:persist.device_config.lmkd_native.psi_partial_stall_ms=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.psi_complete_stall_ms=* on property:persist.device_config.lmkd_native.psi_complete_stall_ms=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.thrashing_limit=* on property:persist.device_config.lmkd_native.thrashing_limit=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.thrashing_limit_decay=* on property:persist.device_config.lmkd_native.thrashing_limit_decay=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.thrashing_limit_critical=* on property:persist.device_config.lmkd_native.thrashing_limit_critical=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.swap_util_max=* on property:persist.device_config.lmkd_native.swap_util_max=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}
on property:persist.device_config.lmkd_native.filecache_min_kb=* on property:persist.device_config.lmkd_native.filecache_min_kb=*
setprop lmkd.reinit 1 setprop lmkd.reinit ${sys.boot_completed:-0}