When a device is thrashing the file cache, workingset refaults can
grow slowly because of variant reasons. Current thrashing detection
mechanism could reset the thrashing counter frequently as it relies
on presence of reclaim activity, however refaults can keep increasing
even when the device is not actively reclaiming. In addition, the
thrashing counter gets reset when conditions require a kill but lmkd
could not find an eligible process to be killed. This is problematic
because when this happens thrashing is being ignored.
Use a fixed 1 sec periods to aggregate the thrashing counter. Also we
need to keep monitoring thrashing counter while retrying as someone
could release the memory to mitigate the thrashing. If thrashing
counter is greater than the limit at the end of the 1 sec period this
means lmkd failed to find an eligible process to kill. In this case
we store accumulated thrashing in case a new eligible process appears
until accumulated thrashing is less that the limit or we miss an
entire 1 sec window.
Bug: 163134367
Test: heavy loading launch
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: Ie9f4121ea604179c0ad510cc8430e7a6aec6e6b2
Changes:
- We are already reading /proc/pid/status to resolve the tgid. While we
are at it, also parse RSS and swap values.
- Use the RSS and swap values for non memcg builds when creating the
statsd outputs
- Given we already read RSS, remove the separate read of /proc/pid/statm
that used to get tasksize.
Bug: 163116785
Test: manual, out/host/linux-x86/bin/statsd_testdrive 51
Change-Id: I9d98b9ffe8be0b014bb09174ec9532382cae1f38
Oftentimes while investigating bugreports it's unclear whether lmkd
was active between kills. To provide visibility into lmkd activity
adding the following fields into killinfo reports:
MsSinceEvent - number of msecs since the last PSI/vmpressure event
MsSincePrevWakeup - number of msecs since the previous wakeup
WakeupsSinceEvent - number of wakeups since the last PSI/vmpressure
event
SkippedWakeups - number of wakeups that were skipped due to an
incomplete kill
Bug: 162034541
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0356c27515132ff0dd309b59a8bf907acbd67cd8
When lmkd tries to kill a process in uninterruptible sleep state, it may
need to wait for a long time. To prevent this set the default kill timeout
to 100ms which should work for majority of the devices.
Bug: 160295034
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia280dc095df9ca8494278e0a75b976ed93fc04ae
Fix code logic to obey our intetion of not killing perceptible apps
due to low swap if above min wmark.
Bug: 155709603
Test: boot
Signed-off-by: Martin Liu <liumartin@google.com>
Merged-In: Ifc09c2a1fe7e21faa096988f471644f63951d81c
Change-Id: Ifc09c2a1fe7e21faa096988f471644f63951d81c
Fix code logic to obey our intetion of not killing perceptible apps
due to low swap if above min wmark.
Bug: 155709603
Test: boot
Signed-off-by: Martin Liu <liumartin@google.com>
Merged-In: Ifc09c2a1fe7e21faa096988f471644f63951d81c
Change-Id: Ifc09c2a1fe7e21faa096988f471644f63951d81c
am skip reason: Change-Id I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1 with SHA-1 48135c4cba is in history
Change-Id: Ia2bbfb9829b21d0214279edc7c245b5437d31593
am skip reason: Change-Id I443486763c034ed0603ea52b81c060c3969af9a5 with SHA-1 c2b228e498 is in history
Change-Id: I320b9b413fddfcc2ddd5dfbe2a3683dc5e5abae9
am skip reason: Change-Id If187654b8001ce843ec6085ccd2042d75a986dae with SHA-1 0e589f61ba is in history
Change-Id: I007c16b6a8bc5de7a906b8ab4424d42212f5b3ce
Prevent kills of perceptible apps due to swap shortages unless system
free memory is below the min watermark. This prevents kills of important
apps when the system is recovering from the memory pressure.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1
Change-Id: I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1
Prevent kills of perceptible apps due to swap shortages unless system
free memory is below the min watermark. This prevents kills of important
apps when the system is recovering from the memory pressure.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1
Lower the min swap threshold to 10% for all devices to limit kills while
swap still has enough space.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: I443486763c034ed0603ea52b81c060c3969af9a5
Change-Id: I443486763c034ed0603ea52b81c060c3969af9a5
In the cases when foreground processes should not be killed
min_score_adjust should be set above PERCEPTIBLE_APP_ADJ to prevent such
kills.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: If187654b8001ce843ec6085ccd2042d75a986dae
Change-Id: If187654b8001ce843ec6085ccd2042d75a986dae
am skip reason: Change-Id Ia802dbd7abb167d66b76390e269e4a4418ca5def with SHA-1 e538ba2df6 is in history
Change-Id: I71c445fc44e2da54b6e2016d21a77c6a1f34d964
am skip reason: Change-Id I7f0839d803a6bf6532f077208ce54aba761dc9fe with SHA-1 ed715a3424 is in history
Change-Id: I4d3ef9cfe36b68a2aa177c7660974a8f31c29bf0
am skip reason: Change-Id Ia3eed3448fd6928a5e634c2737044722048b3578 with SHA-1 03dccf35a1 is in history
Change-Id: I5fe0b9d7a442a0d729b0eec34719f004fcf0dfd1
am skip reason: Change-Id If0674eda954a25f0f6c9188501ff77db8ba0813b with SHA-1 9ca5334683 is in history
Change-Id: I65d3c8f3f36cec703fb60bf44e7f098369ce9bf3
Lower the min swap threshold to 10% for all devices to limit kills while
swap still has enough space.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I443486763c034ed0603ea52b81c060c3969af9a5
In the cases when foreground processes should not be killed
min_score_adjust should be set above PERCEPTIBLE_APP_ADJ to prevent such
kills.
Bug: 155709603
Test: memory stress test with multiple foreground apps
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If187654b8001ce843ec6085ccd2042d75a986dae
Allow lmkd to stop waiting for a kill notification if a kill takes longer
than ro.lmk.kill_timeout_ms.
Bug: 147315292
Test: lmkd_unit_test with ro.lmk.kill_timeout_ms set to 100
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: Ia3eed3448fd6928a5e634c2737044722048b3578
Change-Id: Ia3eed3448fd6928a5e634c2737044722048b3578
In memcg process stat path,
%u in format string (no.2) requires 'unsigned int'
but the argument type is 'signed int'.
Bug: NA
Test: check statslog with lmkd operation
Signed-off-by: Kyeongdon Kim <kyeongdon.kim@lge.com>
Change-Id: I3fcee57efbf26724878a81c8e1acd419aab8b95b
am skip reason: Change-Id Ic60331f3368f5a7fdfe09ad7d47c7ccf0a497685 with SHA-1 1d0ebeaa9c is in history
Change-Id: Ia0eb7d23137c74f72b251034902fd0ed9faf8a28
Add --reinit command-line option to allow updating lmkd properties. For
example to enable debug logging in the running lmkd process user should
issue:
setprop ro.lmk.debug true
lmkd --reinit
Bug: 155149944
Test: lmkd_unit_test after resetting lmkd properties
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: Ic60331f3368f5a7fdfe09ad7d47c7ccf0a497685
Change-Id: Ic60331f3368f5a7fdfe09ad7d47c7ccf0a497685