Commit Graph

981 Commits

Author SHA1 Message Date
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 b97c3ccdfb [automerger skipped] lmkd: report kill reason, and meminfo details to statsd for each kill am: 140385d3a0 -s ours am: fb80cee5c6 -s ours
am skip reason: Change-Id Ic46aed3c85b880b32ac5ad61b55f90e0d33517c7 with SHA-1 3cc1f13044 is in history

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

Change-Id: I377006cd5c900e46e2a7306acd9bbfa264df9300
2020-09-16 18:53:18 +00:00
Suren Baghdasaryan fb80cee5c6 [automerger skipped] lmkd: report kill reason, and meminfo details to statsd for each kill am: 140385d3a0 -s ours
am skip reason: Change-Id Ic46aed3c85b880b32ac5ad61b55f90e0d33517c7 with SHA-1 3cc1f13044 is in history

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

Change-Id: Ifde6aafa26f0af2d605a42cbf046d5a598818341
2020-09-16 16:52:06 +00:00
Suren Baghdasaryan 4a46fc210d lmkd: report kill reason, and meminfo details to statsd for each kill am: 3cc1f13044 am: 595d1c19c7 am: f527dfc9df am: f50a9ebb36 am: 272c650dd3
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1424049

Change-Id: I779ed5e1ff805672df5de392548ba9c67e8b6b5f
2020-09-15 20:37:48 +00:00
Suren Baghdasaryan 140385d3a0 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
Test: statsd_testdrive 51, load with lmk_unit_test
Merged-In: Ic46aed3c85b880b32ac5ad61b55f90e0d33517c7
Change-Id: Ic46aed3c85b880b32ac5ad61b55f90e0d33517c7
2020-09-15 11:34:27 -07:00
Martin Liu e271b2e0d0 [automerger skipped] lmkd: Fix do not kill perceptible apps due to low swap if above min wmark am: dfc73bc2fe am: f6dc513ad7 -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: Ic497f790472f9d3f38299957c1801371dcdcb738
2020-09-15 01:42:04 +00:00
Suren Baghdasaryan cec9b28d69 [automerger skipped] lmkd: Do not kill perceptible apps due to low swap if above min wmark am: 7afa463978 am: b286ce5376 -s ours
am skip reason: Change-Id I6beb4b55f8b4f7bc22818b5a7bdfa3adc6cd31c1 with SHA-1 7afa463978 is in history

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

Change-Id: I78567993487c791521c10a24979ea0119b9be276
2020-09-15 01:31:46 +00:00
Suren Baghdasaryan f5eb70d918 lmkd: Set the default free swap threshold to 10% for all devices am: c2b228e498 am: f1fe0cd12c
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11530605

Change-Id: Ice078ca05303839f5b11e6322aa966ee94786b13
2020-09-15 00:50:04 +00:00
Suren Baghdasaryan 18790ab57b lmkd: Fix min_score_adj to exclude killing foreground processes am: 0e589f61ba am: 1731180fcf
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/11530604

Change-Id: I6f86c840d6ac5dad97762b6857284e91a1e62254
2020-09-15 00:34:43 +00:00
Suren Baghdasaryan cb3ed61307 [automerger skipped] lmkd: Enable stricter compiler checks am: 5096d16091 am: eb6080bbdb -s ours
am skip reason: Change-Id Ia802dbd7abb167d66b76390e269e4a4418ca5def with SHA-1 5096d16091 is in history

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

Change-Id: I98aad15d67c5a2e93a500121516cee57f381dfbf
2020-09-15 00:00:03 +00:00
Suren Baghdasaryan 470d39b81e [automerger skipped] lmkd: Remove unused variables and fix type mismatches am: dd7ec447ab am: 9926488b3f -s ours
am skip reason: Change-Id I7f0839d803a6bf6532f077208ce54aba761dc9fe with SHA-1 dd7ec447ab is in history

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

Change-Id: Ie60c41a97035186bb9f691df473b9e0c541f1ebb
2020-09-15 00:00:01 +00:00
Suren Baghdasaryan 7a3fcae9f8 [automerger skipped] lmkd: enable ro.lmk.kill_timeout_ms to be used with kill notifications am: c7e51b7b2a am: 6a1b9fda36 -s ours
am skip reason: Change-Id Ia3eed3448fd6928a5e634c2737044722048b3578 with SHA-1 c7e51b7b2a is in history

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

Change-Id: I8fc2e4d70e5a33db8d367bba7f6948404b0b1c48
2020-09-14 23:59:59 +00:00
Suren Baghdasaryan 159430beb8 [automerger skipped] lmkd: polling code cleanup am: 3f84a211e5 am: 7753f8a530 -s ours
am skip reason: Change-Id If0674eda954a25f0f6c9188501ff77db8ba0813b with SHA-1 3f84a211e5 is in history

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

Change-Id: I2820f85488c8f6616eabb6f05d5b2c628497e5cb
2020-09-14 23:59:57 +00:00
Suren Baghdasaryan 272c650dd3 lmkd: report kill reason, and meminfo details to statsd for each kill am: 3cc1f13044 am: 595d1c19c7 am: f527dfc9df am: f50a9ebb36
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1424049

Change-Id: I68a21b58828399cebd58552870015974296e1445
2020-09-14 22:40:15 +00:00
Suren Baghdasaryan f50a9ebb36 lmkd: report kill reason, and meminfo details to statsd for each kill am: 3cc1f13044 am: 595d1c19c7 am: f527dfc9df
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1424049

Change-Id: Ic7aee07c12f089aac0c41ee25389331b154d70f6
2020-09-14 21:56:11 +00:00
Suren Baghdasaryan f527dfc9df lmkd: report kill reason, and meminfo details to statsd for each kill am: 3cc1f13044 am: 595d1c19c7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1424049

Change-Id: I243c0a670ba02cc0762d0ea7f664d91afede2d9a
2020-09-14 21:24:45 +00: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 2d57fa30c5 [automerger skipped] lmkd: fix possible long stall state am: d816ab7c54 -s ours am: bb1a7d9b7a -s ours
am skip reason: Change-Id I10c65c85b718a656e3d8991bf09948b96da895cb with SHA-1 589b5752ee is in history

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

Change-Id: Id9e9795e2a4695ced316722a4292349ec4fc196d
2020-09-08 07:13:06 +00:00
Martin Liu c137bc5895 [automerger skipped] lmkd: avoid division by zero because of file_base_lru am: 91bf598282 -s ours am: 74129d3d9e -s ours
am skip reason: Change-Id If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7 with SHA-1 c3108416e7 is in history

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

Change-Id: Id4f71df3b817a1d81cdcecaddae2586bf26641a3
2020-09-08 07:13:05 +00:00
Martin Liu f761c01aeb [automerger skipped] lmkd: adjust thrashing dection strategy am: 94d99a7bc8 -s ours am: 14009f3ba7 -s ours
am skip reason: Change-Id Ie9f4121ea604179c0ad510cc8430e7a6aec6e6b2 with SHA-1 1f72f5fa4b is in history

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

Change-Id: I75e6ae59a5a16aa6dab87d27aa4b80ec5717a542
2020-09-08 07:13:03 +00:00
Martin Liu 6a7f526ac6 Revert "lmkd: Add a margin for watermark when swap free is low" am: cd5f08d8ee am: 7a57924ce8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/12445404

Change-Id: Id0d8e4fa7f6753623be2a4322a53083083a7daa2
2020-09-08 07:13:01 +00:00
Martin Liu bb1a7d9b7a [automerger skipped] lmkd: fix possible long stall state am: d816ab7c54 -s ours
am skip reason: Change-Id I10c65c85b718a656e3d8991bf09948b96da895cb with SHA-1 589b5752ee is in history

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

Change-Id: I0ec6db70a9b5c69cb2fd463409f11f04639fca82
2020-09-08 06:51:00 +00:00
Martin Liu 74129d3d9e [automerger skipped] lmkd: avoid division by zero because of file_base_lru am: 91bf598282 -s ours
am skip reason: Change-Id If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7 with SHA-1 c3108416e7 is in history

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

Change-Id: Ied58f07fa22194ca3a89017312140736c64c64f2
2020-09-08 06:50:56 +00:00
Martin Liu 14009f3ba7 [automerger skipped] lmkd: adjust thrashing dection strategy am: 94d99a7bc8 -s ours
am skip reason: Change-Id Ie9f4121ea604179c0ad510cc8430e7a6aec6e6b2 with SHA-1 1f72f5fa4b is in history

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

Change-Id: I6ff41029d3f4f4b153920101012454a513d1c375
2020-09-08 06:50:54 +00:00
Martin Liu 7a57924ce8 Revert "lmkd: Add a margin for watermark when swap free is low" am: cd5f08d8ee
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/12445404

Change-Id: I3056e7cf80a12a2245ce15cab325a9a6c75b006d
2020-09-08 06:50:53 +00:00
Martin Liu d816ab7c54 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>
Merged-In: I10c65c85b718a656e3d8991bf09948b96da895cb
Change-Id: I10c65c85b718a656e3d8991bf09948b96da895cb
2020-09-07 10:46:16 +08:00
Martin Liu 91bf598282 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
Bug: 163134367
Test: boot
Signed-off-by: Martin Liu <liumartin@google.com>
Merged-In: If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7
Change-Id: If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7
2020-09-07 10:43:24 +08:00
Martin Liu 94d99a7bc8 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>
Merged-In: Ie9f4121ea604179c0ad510cc8430e7a6aec6e6b2
Change-Id: Ie9f4121ea604179c0ad510cc8430e7a6aec6e6b2
2020-09-07 10:42:51 +08:00
Martin Liu cd5f08d8ee Revert "lmkd: Add a margin for watermark when swap free is low"
This reverts commit 95551f816a.

Reason to revert: don't need this change.
Bug: 163134367

Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: I8b209b054b6caec553bce13cd51f931401c1e42a
2020-09-07 10:42:40 +08:00
Martin Liu 50dfb961e5 lmkd: fix possible long stall state am: 589b5752ee am: d65f63c7d4 am: ff015bdf11 am: e51c46d048 am: b7dca7a294
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418830

Change-Id: Id13aa529391bff6cf7f5a1366656e5ca52b7b66a
2020-09-03 17:57:15 +00:00
Martin Liu 237b55a8f0 lmkd: avoid division by zero because of file_base_lru am: c3108416e7 am: b1294d486f am: d2d14448f3 am: 6e9525ad51 am: 1023db6172
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418831

Change-Id: I404cef9f4ed35f8cd0cb622775ce0e7079aaa821
2020-09-03 17:57:08 +00:00
Martin Liu b7dca7a294 lmkd: fix possible long stall state am: 589b5752ee am: d65f63c7d4 am: ff015bdf11 am: e51c46d048
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418830

Change-Id: Ibb6de9f34a31f81838797d02d4fe5b6488cafaf6
2020-09-03 17:18:45 +00:00
Martin Liu 1023db6172 lmkd: avoid division by zero because of file_base_lru am: c3108416e7 am: b1294d486f am: d2d14448f3 am: 6e9525ad51
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418831

Change-Id: I5be5af2eae1504066790dbbacb5e4c562da2d385
2020-09-03 17:18:16 +00:00
Martin Liu e51c46d048 lmkd: fix possible long stall state am: 589b5752ee am: d65f63c7d4 am: ff015bdf11
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418830

Change-Id: I2952fb217bba417e4726079389b6f9cdf3ddfe3f
2020-09-03 17:05:51 +00:00
Martin Liu 6e9525ad51 lmkd: avoid division by zero because of file_base_lru am: c3108416e7 am: b1294d486f am: d2d14448f3
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418831

Change-Id: Ic4287b1fb3ef6f7d0100a8e9ee0764b48ce77503
2020-09-03 17:05:46 +00:00
Martin Liu ff015bdf11 lmkd: fix possible long stall state am: 589b5752ee am: d65f63c7d4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1418830

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

Change-Id: Ic74cc56e98ff9851cd30dfaa9906781b69834aae
2020-09-03 16:51:58 +00: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 63fc9417fd lmkd: adjust thrashing dection strategy am: 1f72f5fa4b am: 58f6be8f3c am: c587b2629c am: 21a6082a6a am: 4bbbe5ef20
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1414468

Change-Id: I054efe052555f80b6e7c20507c12037ee0703aab
2020-09-02 22:17:25 +00:00
Martin Liu 4bbbe5ef20 lmkd: adjust thrashing dection strategy am: 1f72f5fa4b am: 58f6be8f3c am: c587b2629c am: 21a6082a6a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1414468

Change-Id: Ie57a1b9360b27873af9056d1bc286352c2762aa2
2020-09-02 21:35:02 +00:00
Martin Liu 21a6082a6a lmkd: adjust thrashing dection strategy am: 1f72f5fa4b am: 58f6be8f3c am: c587b2629c
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1414468

Change-Id: Ie55859692029d3946bf35a3b9fcfe692d14a25da
2020-09-02 21:06:37 +00:00
Martin Liu c587b2629c lmkd: adjust thrashing dection strategy am: 1f72f5fa4b am: 58f6be8f3c
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1414468

Change-Id: Ia9dab97711dbf1133821c104c18f76cc440623aa
2020-09-02 20:45:51 +00: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 f97e4d70ab [automerger skipped] Mark Android R (rvc-dev-plus-aosp-without-vendor@6692709) as merged am: 3bf11e828b -s ours am: cf7c2bc357 -s ours am: 9d02029885 -s ours am: 40e1efe466 -s ours
am skip reason: Change-Id I06968623ad7ea99ee61c001e367d3892249ed3a6 with SHA-1 0b8b47057e is in history

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

Change-Id: I29a809cc2fdddf5130946c8d708f668dfdb77ba9
2020-08-27 20:13:39 +00:00