Commit Graph

1235 Commits

Author SHA1 Message Date
Bart Van Assche 01663fe2d5 lmkd: Look up cgroup attribute paths instead of hardcoding these am: b4d26bb22b am: 08f4720373 am: def6a3f12f am: cbe6b65f72
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1990496

Change-Id: I6406e60724d9e5197f7008be5f8be6b930edbea8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 22:46:41 +00:00
Bart Van Assche cbe6b65f72 lmkd: Look up cgroup attribute paths instead of hardcoding these am: b4d26bb22b am: 08f4720373 am: def6a3f12f
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1990496

Change-Id: Ica6100474a8ed7dce01045ad3a5362ce4e7721ab
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 22:32:33 +00:00
Bart Van Assche def6a3f12f lmkd: Look up cgroup attribute paths instead of hardcoding these am: b4d26bb22b am: 08f4720373
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1990496

Change-Id: I4d84abb1687325d3e153fe6dc59de6dd5c5bfd3d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 22:15:26 +00:00
Bart Van Assche 08f4720373 lmkd: Look up cgroup attribute paths instead of hardcoding these am: b4d26bb22b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1990496

Change-Id: Idd2fa5330216242e8e99c60811c0beb57d970752
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 21:53:03 +00:00
Bart Van Assche 77f29486aa statslog: Make this library compatible with the cgroups v2 hierarchy am: 16ba8bc773 am: d3401c8ae9 am: aac55955a2 am: 51feb261e5
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1975449

Change-Id: I4e9e7b9ee5379f6a6438af71527ff9fae07278ae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 17:54:36 +00:00
Bart Van Assche 51feb261e5 statslog: Make this library compatible with the cgroups v2 hierarchy am: 16ba8bc773 am: d3401c8ae9 am: aac55955a2
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1975449

Change-Id: I32ab72a005ff992beb9b1daf3b4c07164deea799
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 17:38:23 +00:00
Bart Van Assche aac55955a2 statslog: Make this library compatible with the cgroups v2 hierarchy am: 16ba8bc773 am: d3401c8ae9
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1975449

Change-Id: Ic144cf22d834ef77774a2c6f7287d031cf53a993
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 17:17:08 +00:00
Bart Van Assche d3401c8ae9 statslog: Make this library compatible with the cgroups v2 hierarchy am: 16ba8bc773
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1975449

Change-Id: I7594f669aa8902b6b066a4a11689faadf08911d4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-25 16:59:36 +00:00
Bart Van Assche b4d26bb22b lmkd: Look up cgroup attribute paths instead of hardcoding these
Retrieve cgroup attribute paths from task_profiles.json instead of
hardcoding these paths.

Bug: 213617178
Test: Tested lmkd in Cuttlefish.
Change-Id: I03f40ac8ccd4635f21432214e1acf997c505d1e9
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-24 15:58:02 -07:00
Bart Van Assche 16ba8bc773 statslog: Make this library compatible with the cgroups v2 hierarchy
Call memcg_apps_dir() instead of hard-coding the top-level directory of
the memcg controller.

Bug: 213617178
Test: Verified lmkd operation inside Cuttlefish.
Change-Id: I659610ebdabe3b69b0b1097aa5cf248d6f3273c5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-24 15:58:00 -07:00
Bart Van Assche 6774c81652 liblmkd_utils: Use libprocessgroup to create cgroups am: 911f106a4a am: f0544971d4 am: 84dbabc1b2 am: e93c0f63f7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/2034587

Change-Id: I23bf6c1cee77729fd043f811fd79be5ba470e9d5
2022-03-22 21:16:22 +00:00
Bart Van Assche e93c0f63f7 liblmkd_utils: Use libprocessgroup to create cgroups am: 911f106a4a am: f0544971d4 am: 84dbabc1b2
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/2034587

Change-Id: Id2891d0b356b986ddaa846e53495a939eb6daaba
2022-03-22 20:38:55 +00:00
Bart Van Assche 84dbabc1b2 liblmkd_utils: Use libprocessgroup to create cgroups am: 911f106a4a am: f0544971d4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/2034587

Change-Id: I02fe722830a1b5ef282262ac0a2799fbf0f483fe
2022-03-22 20:17:13 +00:00
Bart Van Assche f0544971d4 liblmkd_utils: Use libprocessgroup to create cgroups am: 911f106a4a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/2034587

Change-Id: I682dfc8e3b463bd5203d5102ec37c2af5422e64f
2022-03-22 20:02:44 +00:00
Bart Van Assche 911f106a4a liblmkd_utils: Use libprocessgroup to create cgroups
Bug: 213617178
Test: Ran lmkd_tests inside Cuttlefish
Change-Id: Ic34b731dfe5d6b1e90d258c2b0af538a216b054a
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-21 15:57:37 -07:00
Presubmit Automerger Backend 6616cd05fe [automerger skipped] [automerged blank] lmkd: Log psi averages in killinfo reports 2p: 0e0da56b4f am: 1bb11f2730 -s ours am: e7ba6bbd71 -s ours
am skip reason: Merged-In Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49 with SHA-1 014dd7156e is already in history

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

Change-Id: Ieb7ded7e87367494c630725056403a4f59a9e4a4
2022-02-25 00:41:02 +00:00
Presubmit Automerger Backend e7ba6bbd71 [automerger skipped] [automerged blank] lmkd: Log psi averages in killinfo reports 2p: 0e0da56b4f am: 1bb11f2730 -s ours
am skip reason: Merged-In Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49 with SHA-1 014dd7156e is already in history

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

Change-Id: I92056854199896a9f6a65780348851f51a36cab7
2022-02-25 00:16:53 +00:00
Presubmit Automerger Backend 1bb11f2730 [automerged blank] lmkd: Log psi averages in killinfo reports 2p: 0e0da56b4f
Blank merge reason: Change-Id Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49 with SHA-1 014dd7156e is in history

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

Bug: 205182133
Change-Id: I117fdb2489a3614d2028cd683b0235c2ab7531f1
Merged-In: Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49
2022-02-24 04:01:06 +00:00
Suren Baghdasaryan 0e0da56b4f lmkd: Log psi averages in killinfo reports
Add psi memory, io and cpu 10sec averages into killinfo reports.

Bug: 205182133
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49
Merged-In: Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49
2022-02-24 12:00:44 +08:00
Bart Van Assche 4fe00c065e lmkd: Fix a potential buffer overflow am: 5ebc4e8f51 am: 75a98b56ab am: bcc461658b am: b893101ac1
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972105

Change-Id: I567efba7b052412d1eecb3e77a53ceeea41fc7c8
2022-02-23 20:21:50 +00:00
Bart Van Assche 7ba01bd357 lmkd: Use std::array<> and remove the ARRAY_SIZE() definition am: 545067957c am: f9489027a1 am: 350a02e15d am: a02c2dc079
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972104

Change-Id: Idac0ba80ee2e729a66810191c718a445c29dc9b0
2022-02-23 20:21:49 +00:00
Bart Van Assche cd68af3c9f lmkd: Use std::min() and std::max() instead of defining min() and max() macros am: 80a3dba57a am: c53ab08bf5 am: 20f9f7e0b7 am: 65b793bb9a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972103

Change-Id: I5eb26426674e154eb725740e28c28c59539286ea
2022-02-23 20:21:48 +00:00
Bart Van Assche b893101ac1 lmkd: Fix a potential buffer overflow am: 5ebc4e8f51 am: 75a98b56ab am: bcc461658b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972105

Change-Id: I986dbc2faa98ffa2dd3a849b25fcfd6c955ea56b
2022-02-23 19:45:15 +00:00
Bart Van Assche a02c2dc079 lmkd: Use std::array<> and remove the ARRAY_SIZE() definition am: 545067957c am: f9489027a1 am: 350a02e15d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972104

Change-Id: Ibff73f0b29a47624a374d46b92e98124a3d49f19
2022-02-23 19:45:13 +00:00
Bart Van Assche 65b793bb9a lmkd: Use std::min() and std::max() instead of defining min() and max() macros am: 80a3dba57a am: c53ab08bf5 am: 20f9f7e0b7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972103

Change-Id: I2de7ccd6d194fa959140a29f4b9963707aa37555
2022-02-23 19:45:12 +00:00
Bart Van Assche bcc461658b lmkd: Fix a potential buffer overflow am: 5ebc4e8f51 am: 75a98b56ab
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972105

Change-Id: I4778df4e1f58a665beb519f16287e4b84a0849e2
2022-02-23 19:21:31 +00:00
Bart Van Assche 350a02e15d lmkd: Use std::array<> and remove the ARRAY_SIZE() definition am: 545067957c am: f9489027a1
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972104

Change-Id: If6a3e2e00794ec8df993a6bead87d564a2eea047
2022-02-23 19:21:30 +00:00
Bart Van Assche 20f9f7e0b7 lmkd: Use std::min() and std::max() instead of defining min() and max() macros am: 80a3dba57a am: c53ab08bf5
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972103

Change-Id: I56abe6f693c848eeae3acc3a39f723746f92b30a
2022-02-23 19:21:29 +00:00
Bart Van Assche 75a98b56ab lmkd: Fix a potential buffer overflow am: 5ebc4e8f51
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972105

Change-Id: I4dca955fd118a16fc3bd1a37beeb8fe317bcbcc2
2022-02-23 18:55:06 +00:00
Bart Van Assche f9489027a1 lmkd: Use std::array<> and remove the ARRAY_SIZE() definition am: 545067957c
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972104

Change-Id: Icb6ad2718ff8170bc457268688b9ae94e53a4c1f
2022-02-23 18:55:05 +00:00
Bart Van Assche c53ab08bf5 lmkd: Use std::min() and std::max() instead of defining min() and max() macros am: 80a3dba57a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972103

Change-Id: Ifd1a8218fd0d6fbb4bbca9b0cc65b39c8b0e7226
2022-02-23 18:55:04 +00:00
Suren Baghdasaryan a4feb98740 [automerger skipped] lmkd: Allow killing perceptible apps when recorded stall is too high am: 65e7d14e2a -s ours am: 77d001ed58 -s ours am: 7c4c36107f -s ours
am skip reason: Merged-In I9713e30d82641d86d1b7edb5e1ba2971b935c898 with SHA-1 5ae47a9563 is already in history

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

Change-Id: I0c1508341ad1a1ed0376b817184b3fa72b1878a6
2022-02-23 17:19:08 +00:00
Bart Van Assche 5ebc4e8f51 lmkd: Fix a potential buffer overflow
Prevent that the statement that writes '\0' past the read data can write
past the end of the buffer.

Bug: 213617178
Test: Compile-tested only.
Change-Id: I6922c343a6bcb52dce0b5cf54f09b2850e9dfde2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-23 17:05:11 +00:00
Bart Van Assche 545067957c lmkd: Use std::array<> and remove the ARRAY_SIZE() definition
Using ARRAY_SIZE() on a pointer yields 1 while applying .size() to a
pointer triggers a compiler error. Hence use .size() instead of
ARRAY_SIZE().

Bug: 213617178
Test: Compile-tested only.
Change-Id: Ie0f9740f59470c943f8d62b9475f7f987ed8707b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-23 17:05:11 +00:00
Bart Van Assche 80a3dba57a lmkd: Use std::min() and std::max() instead of defining min() and max() macros
std::min() and std::max() check whether the argument types match but
min() and max() not. Hence switch to std::min() and std::max().

Bug: 213617178
Test: Compile-tested only.
Change-Id: Iaf1f63360c9360938db56d485dbd1e504129c52d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-02-23 17:05:10 +00:00
Suren Baghdasaryan 7c4c36107f [automerger skipped] lmkd: Allow killing perceptible apps when recorded stall is too high am: 65e7d14e2a -s ours am: 77d001ed58 -s ours
am skip reason: Merged-In I9713e30d82641d86d1b7edb5e1ba2971b935c898 with SHA-1 5ae47a9563 is already in history

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

Change-Id: I8d5a6c82f6c980ed7ec2488dbc8c2972716456f2
2022-02-22 23:24:33 +00:00
Suren Baghdasaryan 77d001ed58 [automerger skipped] lmkd: Allow killing perceptible apps when recorded stall is too high am: 65e7d14e2a -s ours
am skip reason: Merged-In I9713e30d82641d86d1b7edb5e1ba2971b935c898 with SHA-1 5ae47a9563 is already in history

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

Change-Id: I80f87a21806b6d78063673ff0d8c4b5de329246f
2022-02-22 23:02:14 +00:00
Suren Baghdasaryan 4609284014 lmkd: Log psi averages in killinfo reports am: 014dd7156e am: 58fa91d0cf am: 7475f87830 am: b3ffc654fd
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992291

Change-Id: Ic7fef56fc049a8bf5b19996874b14d7d8b21efca
2022-02-22 21:14:52 +00:00
Suren Baghdasaryan b3ffc654fd lmkd: Log psi averages in killinfo reports am: 014dd7156e am: 58fa91d0cf am: 7475f87830
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992291

Change-Id: I19c8d578df21710989921bea09cce98b8c103905
2022-02-22 20:49:54 +00:00
Suren Baghdasaryan 7475f87830 lmkd: Log psi averages in killinfo reports am: 014dd7156e am: 58fa91d0cf
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992291

Change-Id: Ibeae28dd24c0b748ea63a902ed904178c85d8209
2022-02-22 20:27:40 +00:00
Suren Baghdasaryan 58fa91d0cf lmkd: Log psi averages in killinfo reports am: 014dd7156e
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992291

Change-Id: I4c0d6094b137cb996d48f07bd528db4c346d1ee1
2022-02-22 19:47:43 +00:00
Suren Baghdasaryan cddacf8864 lmkd: Allow killing perceptible apps when recorded stall is too high am: 5ae47a9563 am: 744462fdf0 am: 38cbc12b33 am: 915a384a57
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992290

Change-Id: I3820ed100c64683f6ff1c5b50405678436d02cb7
2022-02-22 12:32:57 +00:00
Suren Baghdasaryan 915a384a57 lmkd: Allow killing perceptible apps when recorded stall is too high am: 5ae47a9563 am: 744462fdf0 am: 38cbc12b33
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992290

Change-Id: Iab5c69a5d7b5fbe6e72559c2db858dae833ee826
2022-02-22 12:02:12 +00:00
Suren Baghdasaryan 38cbc12b33 lmkd: Allow killing perceptible apps when recorded stall is too high am: 5ae47a9563 am: 744462fdf0
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992290

Change-Id: Ieb445737f6ba7ea2913c08076c2c11e95350c528
2022-02-22 11:40:39 +00:00
Suren Baghdasaryan 744462fdf0 lmkd: Allow killing perceptible apps when recorded stall is too high am: 5ae47a9563
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992290

Change-Id: I5f5c75c6673b9d72b18a1730cf3e5a9c34c9562c
2022-02-22 11:19:32 +00:00
Suren Baghdasaryan 65e7d14e2a lmkd: Allow killing perceptible apps when recorded stall is too high
When system is under heavy memory pressure the system might be able
to keep free memory above the min watermark avoiding perceptible app
kills. In such situation system might end up using all its cpu
capacity on memory reclaim and not doing productive work. To detect
this condition, check memory full stall and compare it with the new
ro.lmk.stall_limit_critical tunable representing the stall threshold.
When the recorded level is over ro.lmk.stall_limit_critical, lmkd will
be allowed to kill perceptible apps. ro.lmk.stall_limit_critical
represents the max memory full stall in % that is allowed before
perceptible apps will get killed. By default it is set to 100%, which
effectively disables the feature.
Currently system stall is measured based on psi memory stall 10s average
value, however this definition might change in the future if better
metrics are developed. Setting ro.lmk.stall_limit_critical to 5 means
the system should be fully stalled (no productive work is done) for 5%
of the 10sec period, resulting in 0.5 sec loss due to the stall.

Bug: 205182133
Test: verify on heavy memory pressure test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: I9713e30d82641d86d1b7edb5e1ba2971b935c898
Merged-In: I9713e30d82641d86d1b7edb5e1ba2971b935c898
2022-02-22 15:03:28 +08:00
Suren Baghdasaryan 014dd7156e lmkd: Log psi averages in killinfo reports
Add psi memory, io and cpu 10sec averages into killinfo reports.

Bug: 205182133
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ifbcf47cab291fb20dbf0b5d32f1965f4e6462b49
2022-02-21 20:30:50 -08:00
Suren Baghdasaryan 5ae47a9563 lmkd: Allow killing perceptible apps when recorded stall is too high
When system is under heavy memory pressure the system might be able
to keep free memory above the min watermark avoiding perceptible app
kills. In such situation system might end up using all its cpu
capacity on memory reclaim and not doing productive work. To detect
this condition, check memory full stall and compare it with the new
ro.lmk.stall_limit_critical tunable representing the stall threshold.
When the recorded level is over ro.lmk.stall_limit_critical, lmkd will
be allowed to kill perceptible apps. ro.lmk.stall_limit_critical
represents the max memory full stall in % that is allowed before
perceptible apps will get killed. By default it is set to 100%, which
effectively disables the feature.
Currently system stall is measured based on psi memory stall 10s average
value, however this definition might change in the future if better
metrics are developed. Setting ro.lmk.stall_limit_critical to 5 means
the system should be fully stalled (no productive work is done) for 5%
of the 10sec period, resulting in 0.5 sec loss due to the stall.

Bug: 205182133
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9713e30d82641d86d1b7edb5e1ba2971b935c898
2022-02-21 20:27:45 -08:00
Xin Li ad00642f43 [automerger skipped] Empty merge of sc-v2-dev-plus-aosp-without-vendor@8084891 am: 2a6c586684 -s ours am: b30fc24fa5 -s ours
am skip reason: Merged-In I56a55834582e11c06cc6cf9da3bc7380e634b301 with SHA-1 af1b0e0627 is already in history

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

Change-Id: I4f847ea218d2be02444ff7d41509a5e30455e0ba
2022-02-11 15:59:04 +00:00
Xin Li b30fc24fa5 [automerger skipped] Empty merge of sc-v2-dev-plus-aosp-without-vendor@8084891 am: 2a6c586684 -s ours
am skip reason: Merged-In I56a55834582e11c06cc6cf9da3bc7380e634b301 with SHA-1 af1b0e0627 is already in history

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

Change-Id: I425ecd3dc45128d36438baabc23a9bd1d4bc7f31
2022-02-11 15:42:00 +00:00