Commit Graph

612 Commits

Author SHA1 Message Date
Kalesh Singh 5015275acf lmkd: Add clang format symlink
Bug: 174144799
Test: clang-format -i <file>
Change-Id: I56afa2b58891fbc1786669afa7d442343dbc6f19
2020-11-24 13:09:01 -05:00
Xin Li e6ad9cc974 Skip ab/6749736 in stage.
Merged-In: I21557b59bcb67736b552b7f5fa3b37045851a4dd
Change-Id: I4ba2e0df4785cafd998a73ac73520c5ac06cc700
2020-10-08 17:24:04 -07:00
Sudarshan Rajagopalan 54c3db5d70 libpsi: Export library to vendor am: c467601098
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1437955

Change-Id: I71df63d382caf5f06131b1f7950dab1955bb6c4d
2020-09-29 01:21:07 +00:00
Sudarshan Rajagopalan 41dc0274a3 libpsi: Add explicit header files am: 8771e054e8
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1437956

Change-Id: I7c68520392ec9aca5921dac5b372cbf011849800
2020-09-29 00:10:01 +00:00
Sudarshan Rajagopalan c467601098 libpsi: Export library to vendor
Make vendor_available = true so that other modules in vendor image
can leverage this library to init, register and unregister to psi.

Bug: 169346507
Change-Id: I47f7d25984e09d61703e7b2bd6fcb8db9d3814f5
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
2020-09-28 14:51:09 -07:00
Sudarshan Rajagopalan 8771e054e8 libpsi: Add explicit header files
The libpsi source code is missing cutils and stdio header files.
Add cutils and stdio header files, and add libcutils_headers to
the header library in Android.bp.

Bug: 169346507
Change-Id: I2d613d5724d3c5f52dd52dcae7024439f2e8d5bb
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
2020-09-28 14:50:15 -07:00
Suren Baghdasaryan 595d1c19c7 lmkd: report kill reason, and meminfo details to statsd for each kill am: 3cc1f13044
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1424049

Change-Id: Ic70e756c0ac793414c68967a7fe13599da7b0d7d
2020-09-14 17:32:25 +00:00
Suren Baghdasaryan 3cc1f13044 lmkd: report kill reason, and meminfo details to statsd for each kill
Information like free memory and swap as well as kill reason would be
useful for understanding regressions in the number of lmk kills in the
field.

Bug: 168117803
Change-Id: Ic46aed3c85b880b32ac5ad61b55f90e0d33517c7
Test: statsd_testdrive 51, load with lmk_unit_test
2020-09-11 14:24:23 +01:00
Martin Liu d65f63c7d4 lmkd: fix possible long stall state am: 589b5752ee
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418830

Change-Id: I2386b050dd2d3b51b8db7ab8040c7e54d1aed74d
2020-09-03 16:41:00 +00:00
Martin Liu b1294d486f lmkd: avoid division by zero because of file_base_lru am: c3108416e7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418831

Change-Id: I828d0765ce5c1bbb15451c37a49bc0b9fc26795e
2020-09-03 16:40:55 +00:00
Martin Liu 589b5752ee lmkd: fix possible long stall state
If the first PSI event triggers a kill, lmkd won't resume polling
immediately after the process has died. Instead, it will wait until the
next PSI event to resume the polling which is too late when the device
is under memory pressure. This happens if data communication with AMS
happens after previous polling window expired, in which case paused
handler gets reset and polling does not resume after the kill.
Fix this by changing pause handler reset logic.

Bug: 167562248
Test: memory pressure test
Signed-off-by: Martin Liu <liumartin@google.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I10c65c85b718a656e3d8991bf09948b96da895cb
2020-09-04 00:04:57 +08:00
Martin Liu c3108416e7 lmkd: avoid division by zero because of file_base_lru
It seems we have chance that file_base_lru is zero.
Avoid it by adding 1.

Bug: 167660459
Test: boot
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7
2020-09-04 00:03:49 +08:00
Martin Liu 58f6be8f3c lmkd: adjust thrashing dection strategy am: 1f72f5fa4b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1414468

Change-Id: If2c66c905e2c5e73a946d9d19fa98a2c07a6fdf4
2020-09-02 20:03:10 +00:00
Martin Liu 1f72f5fa4b lmkd: adjust thrashing dection strategy
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
2020-08-28 13:04:42 +08:00
Xin Li 3bf11e828b Mark Android R (rvc-dev-plus-aosp-without-vendor@6692709) as merged
Bug: 166295507
Merged-In: I06968623ad7ea99ee61c001e367d3892249ed3a6
Change-Id: I536b69290d787bf3fa7d060427bbea66d6570699
2020-08-27 09:44:21 -07:00
Ioannis Ilkos 30240af1f0 Emit swap size in the killed process' statsd atoms am: 279268a07f
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1398492

Change-Id: I1a3e6a035e60cd15ff6723ffcdcdc6e01262ccc0
2020-08-13 07:51:07 +00:00
Ioannis Ilkos 279268a07f Emit swap size in the killed process' statsd atoms
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
2020-08-12 20:24:56 +01:00
Suren Baghdasaryan 5ac19eb471 [automerger skipped] lmkd: Add lmkd wakeup information into killinfo logs am: fa667edb56 -s ours
am skip reason: Change-Id I0356c27515132ff0dd309b59a8bf907acbd67cd8 with SHA-1 d7b4fcb8a5 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/12245884

Change-Id: I21557b59bcb67736b552b7f5fa3b37045851a4dd
2020-07-30 01:41:43 +00:00
Suren Baghdasaryan 4a04afd997 [automerger skipped] lmkd: Set default kill timeout to limit waits for uninterruptible processes am: dd8c2c181b -s ours
am skip reason: Change-Id Ia280dc095df9ca8494278e0a75b976ed93fc04ae with SHA-1 7d1f4f0047 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/12245883

Change-Id: I72a2b3e18a4f8e29095150f9eeb7dd64c622281f
2020-07-30 01:41:40 +00:00
Suren Baghdasaryan fa667edb56 lmkd: Add lmkd wakeup information into killinfo logs
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
Bug: 161955028
Bug: 162297751
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0356c27515132ff0dd309b59a8bf907acbd67cd8
(cherry picked from commit d7b4fcb8a5)
Signed-off-by: Martin Liu <liumartin@google.com>
Merged-In: I0356c27515132ff0dd309b59a8bf907acbd67cd8
2020-07-30 01:33:27 +00:00
Suren Baghdasaryan dd8c2c181b lmkd: Set default kill timeout to limit waits for uninterruptible processes
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
Bug: 161955028
Bug: 162297751
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia280dc095df9ca8494278e0a75b976ed93fc04ae
(cherry picked from commit 7d1f4f0047)
Signed-off-by: Martin Liu <liumartin@google.com>
Merged-In: Ia280dc095df9ca8494278e0a75b976ed93fc04ae
2020-07-28 09:13:44 +00:00
Suren Baghdasaryan c7c600c768 lmkd: Add lmkd wakeup information into killinfo logs am: d7b4fcb8a5 am: 403c7fd536 am: 48f7d0e49f
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1371804

Change-Id: Ied2bb909d79ae865982795db181824a85bcf887c
2020-07-26 18:06:59 +00:00
Suren Baghdasaryan 48f7d0e49f lmkd: Add lmkd wakeup information into killinfo logs am: d7b4fcb8a5 am: 403c7fd536
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1371804

Change-Id: Ifcca19bbbb6c5d69f44edf20d34af824e9879060
2020-07-26 17:47:07 +00:00
Suren Baghdasaryan 403c7fd536 lmkd: Add lmkd wakeup information into killinfo logs am: d7b4fcb8a5
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1371804

Change-Id: I99560d361860d3c4d1e83f7b8ac219d57824f817
2020-07-26 17:32:08 +00:00
Suren Baghdasaryan d7b4fcb8a5 lmkd: Add lmkd wakeup information into killinfo logs
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
2020-07-24 19:31:03 +00:00
Suren Baghdasaryan ec0f9218de lmkd: Set default kill timeout to limit waits for uninterruptible processes am: 7d1f4f0047 am: 93060362b5 am: 0b8b47057e
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1358623

Change-Id: Ic644942e90748588e194ff05adf2d3f75397444e
2020-07-11 03:30:30 +00:00
Suren Baghdasaryan 0b8b47057e lmkd: Set default kill timeout to limit waits for uninterruptible processes am: 7d1f4f0047 am: 93060362b5
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1358623

Change-Id: I06968623ad7ea99ee61c001e367d3892249ed3a6
2020-07-11 03:18:24 +00:00
Suren Baghdasaryan 93060362b5 lmkd: Set default kill timeout to limit waits for uninterruptible processes am: 7d1f4f0047
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1358623

Change-Id: Iffcb4cbd88d44df216fce44c37ecace082df7d69
2020-07-11 03:07:04 +00:00
Suren Baghdasaryan 7d1f4f0047 lmkd: Set default kill timeout to limit waits for uninterruptible processes
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
2020-07-08 11:41:14 -07:00
Martin Liu a8465ae999 [automerger skipped] lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: dfc73bc2fe -s ours am: 08d786c5bd -s ours
am skip reason: Change-Id Ifc09c2a1fe7e21faa096988f471644f63951d81c with SHA-1 dfc73bc2fe is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11699841

Change-Id: I01c65d9d30e12efd461b7dba263dc4194924c611
2020-06-02 21:12:09 +00:00
Martin Liu f9db70b71b [automerger skipped] lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: dfc73bc2fe am: 62f4f4262e -s ours
am skip reason: Change-Id Ifc09c2a1fe7e21faa096988f471644f63951d81c with SHA-1 3185c2d096 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11699841

Change-Id: Ib5b7c1a7267883095bba6f2f5dae064037b4f962
2020-06-02 21:11:19 +00:00
Martin Liu 08d786c5bd [automerger skipped] lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: dfc73bc2fe -s ours
am skip reason: Change-Id Ifc09c2a1fe7e21faa096988f471644f63951d81c with SHA-1 3185c2d096 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11699841

Change-Id: Ied978dbd309a8876ed7a090120927b6818a70b80
2020-06-02 20:55:41 +00:00
Martin Liu 62f4f4262e lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: dfc73bc2fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11699841

Change-Id: Iee2254c3047d939a82bbaf7de9e350ea1df4ea20
2020-06-02 20:55:29 +00:00
Martin Liu 6f4f82ffef lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: 3185c2d096 am: ff6ad5cd06 am: 3a2aeaba0e
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1321895

Change-Id: I7349628a326f0f8e6672462e604c0bf3e81c496c
2020-06-02 17:52:48 +00:00
Martin Liu 3a2aeaba0e lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: 3185c2d096 am: ff6ad5cd06
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1321895

Change-Id: I1533fc059bb1683e5bf9441a7b30e5e24e6f1f83
2020-06-02 17:27:00 +00:00
Martin Liu ff6ad5cd06 lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: 3185c2d096
Original change: undetermined

Change-Id: I1cb82bf5ff5da1dd29876354a54b2dd963088b37
2020-06-02 17:09:23 +00:00
Martin Liu dfc73bc2fe lmkd: Fix do not kill perceptible apps due to low swap if above min wmark
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
2020-06-02 23:47:01 +08:00
Martin Liu 3185c2d096 lmkd: Fix do not kill perceptible apps due to low swap if above min wmark
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
2020-06-02 23:43:49 +08:00
Automerger Merge Worker 3e6ee0722c Merge "[automerger skipped] lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978 -s ours am: 5b4b3716e4 -s ours" into rvc-d1-dev-plus-aosp 2020-05-21 00:36:14 +00:00
Suren Baghdasaryan c08f3f09b7 [automerger skipped] lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978 -s ours am: 5b4b3716e4 -s ours
am skip reason: Change-Id I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1 with SHA-1 48135c4cba is in history

Change-Id: I991c035d1cf12e59b5975450b399a85d0af239ab
2020-05-21 00:36:10 +00:00
Suren Baghdasaryan 4afbef0f6c [automerger skipped] lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978 am: 747c846a5a -s ours
am skip reason: Change-Id I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1 with SHA-1 48135c4cba is in history

Change-Id: I742875df19599c98274531e9d986f3a827529da5
2020-05-21 00:36:08 +00:00
Suren Baghdasaryan 747c846a5a lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978
Change-Id: Ib75f23cdd2fc21a32c8e2f6c303ad59ca531b026
2020-05-21 00:09:51 +00:00
Suren Baghdasaryan 5b4b3716e4 [automerger skipped] lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978 -s ours
am skip reason: Change-Id I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1 with SHA-1 48135c4cba is in history

Change-Id: Ia2bbfb9829b21d0214279edc7c245b5437d31593
2020-05-21 00:09:43 +00:00
Suren Baghdasaryan 5d843e85e4 lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 48135c4cba am: d6d8a3dc55 am: c9e47704a9
Change-Id: Ie06f0ad716299660380a13fedfc878194afcc32f
2020-05-20 21:38:13 +00:00
Suren Baghdasaryan 7263dd1a1c [automerger skipped] lmkd: Set the default free swap threshold to 10% for all devices am: fb1f592602 am: 5132481e15 -s ours am: 16657a940d -s ours
am skip reason: Change-Id I443486763c034ed0603ea52b81c060c3969af9a5 with SHA-1 c2b228e498 is in history

Change-Id: I16423e56f3e6fb693b5fa285b03a94763fe90990
2020-05-20 21:38:13 +00:00
Suren Baghdasaryan 6e7368e80c [automerger skipped] lmkd: Fix min_score_adj to exclude killing foreground processes am: 5c039b53d8 am: d9ba0c99ae -s ours am: e58fd35c27 -s ours
am skip reason: Change-Id If187654b8001ce843ec6085ccd2042d75a986dae with SHA-1 0e589f61ba is in history

Change-Id: I465380f7a63d085ab082582d6a0cf2a3a2527e77
2020-05-20 21:38:12 +00:00
Suren Baghdasaryan c9e47704a9 lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 48135c4cba am: d6d8a3dc55
Change-Id: I8d6a9376c361279c9833b19afdaac5a83d8a9f2a
2020-05-20 21:25:29 +00:00
Suren Baghdasaryan 16657a940d [automerger skipped] lmkd: Set the default free swap threshold to 10% for all devices am: fb1f592602 am: 5132481e15 -s ours
am skip reason: Change-Id I443486763c034ed0603ea52b81c060c3969af9a5 with SHA-1 c2b228e498 is in history

Change-Id: I320b9b413fddfcc2ddd5dfbe2a3683dc5e5abae9
2020-05-20 21:25:27 +00:00
Suren Baghdasaryan e58fd35c27 [automerger skipped] lmkd: Fix min_score_adj to exclude killing foreground processes am: 5c039b53d8 am: d9ba0c99ae -s ours
am skip reason: Change-Id If187654b8001ce843ec6085ccd2042d75a986dae with SHA-1 0e589f61ba is in history

Change-Id: I007c16b6a8bc5de7a906b8ab4424d42212f5b3ce
2020-05-20 21:25:25 +00:00
Suren Baghdasaryan d6d8a3dc55 lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 48135c4cba
Change-Id: I3ba7b9a0cab86a185cfc3c6d9f23d5ad677a0251
2020-05-20 20:59:14 +00:00