Commit Graph

1447 Commits

Author SHA1 Message Date
Suren Baghdasaryan 7c3addb2a1 lmkd: Use process_mrelease to reap the target process from a thread
process_mrelease syscall can be used to expedite memory release of
a process after it was killed. This allows memory to be released
without the target process being scheduled, therefore does not depend
on target's priority or the CPU it's running on.
However process_mrelease syscall can take considerable time. Blocking
lmkd main thread during that time can cause memory pressure events
being missed while lmkd is busy reaping previous target's memory.
For this reason reaping should be done in a separate thread. This way
lmkd main thread can keep monitoring memory pressure while memory is
being released.
Introduce Reaper class which maintains a pool of threads to perform
process killing and reaping. The main thread submits a request to the
Reaper to kill and reap the process without blocking. If all the threads
in the pool are busy at the time the next kill is needed, the kill is
performed by the main thread without reaping.

Bug: 130172058
Bug: 189803002
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If7b10fdd1838bdfeea3fed3031565feffe0b52be
2022-01-06 18:14:14 +00:00
Suren Baghdasaryan 3f691834b7 [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours am: 521ecf770e -s ours am: 57cdc19e34 -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: I2a1fc6cc80dcdbebea5986be2b13cb71bfcc7872
2021-12-22 21:05:10 +00:00
Suren Baghdasaryan cff4f589b3 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours am: 4056ed3b29 -s ours am: 9a5d09e4f7 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I8e2c1922e3f6e021a5fe9a165b6495d96bdcbb66
2021-12-22 21:05:09 +00:00
Suren Baghdasaryan 57cdc19e34 [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours am: 521ecf770e -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: Ic8216d7b3cbf98eb4f3d8629056d177b8a4e4224
2021-12-22 21:01:50 +00:00
Suren Baghdasaryan 9a5d09e4f7 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours am: 4056ed3b29 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I91db060dc84b1d403c21f8cff24b4f0c32d01ab4
2021-12-22 21:01:49 +00:00
Suren Baghdasaryan 7482bdf080 [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours am: 931bf0954f -s ours am: 3ffa7f5391 -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: Iab4226e82164d412b578b7af13590298d83dda15
2021-12-22 20:58:05 +00:00
Suren Baghdasaryan f924fe90f8 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours am: 4fe0d250e8 -s ours am: 6cba2d654c -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: Ia32fa33e11e496f83c4c159a81ff9a64fcd97cbf
2021-12-22 20:58:05 +00:00
Suren Baghdasaryan 521ecf770e [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: I64fbffc972ef685cb42314ae9c272165b7735eae
2021-12-22 20:51:46 +00:00
Suren Baghdasaryan 4056ed3b29 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I05a07bc6ccd42c8cb809bfed6863d2992ae97371
2021-12-22 20:51:45 +00:00
Suren Baghdasaryan 3ffa7f5391 [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours am: 931bf0954f -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: I8b849ade888210c334e1e1bdc783c906094d520d
2021-12-22 20:34:06 +00:00
Suren Baghdasaryan 6cba2d654c [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours am: 4fe0d250e8 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I5e0b25a603424ac0e2c22839704c212e0b6a0133
2021-12-22 20:34:05 +00:00
Suren Baghdasaryan 931bf0954f [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours am: 2b9d78486a -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: Ic3c8969383c707767e286ba25cfb15f747aa5a7b
2021-12-22 20:29:15 +00:00
Suren Baghdasaryan 4fe0d250e8 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours am: e01b07d4a7 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: Ic9aa0f37cb0f0b8d6bb8440a921965030f3a9fbc
2021-12-22 20:29:13 +00:00
Suren Baghdasaryan 2b9d78486a [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: Ic644b480d12e69b2a4efa4625c3c30dcbac4f616
2021-12-22 20:26:03 +00:00
Suren Baghdasaryan e01b07d4a7 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I2379d168b62945e550bf521f8100454b8cf6a3f2
2021-12-22 20:26:00 +00:00
Suren Baghdasaryan 256a5f2c0b [automerger skipped] lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991 am: 54e25eb877 -s ours
am skip reason: Merged-In Iba34fc719a18d58b890549c7415bec869d471901 with SHA-1 fcb9cb6de4 is already in history

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

Change-Id: Iee35860de1a308219f97439ea514f3a89bedc60f
2021-12-22 10:03:13 +00:00
Suren Baghdasaryan f9fc611522 [automerger skipped] lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8 am: 1277a130db -s ours
am skip reason: Merged-In Ia48fd51eab126d307a1604530b642e86cf250688 with SHA-1 e7d82ee7e7 is already in history

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

Change-Id: I5d00923862f7d00b62d4594afde3ba8d4eaf1e61
2021-12-22 10:03:12 +00:00
Suren Baghdasaryan 54e25eb877 lmkd: Do not re-initialize lmkd when persistent properties are loaded am: aced711991
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15738844

Change-Id: I3082e77c9699065bf2b7f1622ec3eb6f143b85aa
2021-12-22 09:42:30 +00:00
Suren Baghdasaryan 1277a130db lmkd: Add support for persist.device_config.lmkd_native.* properties am: b91ecaa3e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15738843

Change-Id: I765d1f73f5a4c3759e5c14a59c04a4ba9005f07a
2021-12-22 09:42:29 +00:00
liuhailong 4426238c51 lmkd: Fix lowmem_minfree out of bounds am: cf8af501dc am: 53df06cdf1 am: 986595819d am: 0ea9a37079
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1908669

Change-Id: If848e331616c15f13de4989fa9da9b0ebd709a7c
2021-12-07 03:40:45 +00:00
liuhailong 0ea9a37079 lmkd: Fix lowmem_minfree out of bounds am: cf8af501dc am: 53df06cdf1 am: 986595819d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1908669

Change-Id: Idd0176344f3d3a96cb972dd695ade200c1013a15
2021-12-07 03:23:35 +00:00
liuhailong 986595819d lmkd: Fix lowmem_minfree out of bounds am: cf8af501dc am: 53df06cdf1
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1908669

Change-Id: I203fb9b1d0719c4fb8fccda44d48dc468b3927cf
2021-12-07 03:07:50 +00:00
liuhailong 53df06cdf1 lmkd: Fix lowmem_minfree out of bounds am: cf8af501dc
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1908669

Change-Id: Ie928b2d3c3882dafcf591a0487eb73c0d3b0b73a
2021-12-07 02:52:13 +00:00
liuhailong cf8af501dc lmkd: Fix lowmem_minfree out of bounds
lmkd daemon launches before system_server. If lowmem_targets_size
does not initialize by system_server, the value will be zero.
Before system_server starts lmkd receives a psi event
and debug_process_killing on, the lmkd crashes here.

Bug: 209090314
Signed-off-by: liuhailong <liuhailong@oppo.com>
Change-Id: I0736a882ed1ff5eee2b07676ae590a2cb2a7721c
2021-12-04 17:59:24 +08:00
Suren Baghdasaryan 2aea8f78c8 lmkd: fix low swap threshold failing to update after reinit am: 6e6d14b387 am: 07de899509 am: 6d2d6d4d62 am: ac36e3a50a am: d3677b36ef
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1874517

Change-Id: I0f97ebeea533eebeff113fb16c17e2672f712a83
2021-10-29 00:05:34 +00:00
Suren Baghdasaryan d3677b36ef lmkd: fix low swap threshold failing to update after reinit am: 6e6d14b387 am: 07de899509 am: 6d2d6d4d62 am: ac36e3a50a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1874517

Change-Id: Id29a68a3ca01890be656f3cbfe4c8e99e6e83b96
2021-10-28 23:47:20 +00:00
Suren Baghdasaryan ac36e3a50a lmkd: fix low swap threshold failing to update after reinit am: 6e6d14b387 am: 07de899509 am: 6d2d6d4d62
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1874517

Change-Id: I5efeb150d303d81fbd3575171bb6cef40a278505
2021-10-28 23:30:18 +00:00
Suren Baghdasaryan 6d2d6d4d62 lmkd: fix low swap threshold failing to update after reinit am: 6e6d14b387 am: 07de899509
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1874517

Change-Id: I1527091b5889d57c237cbaccea373effc2ee94a6
2021-10-28 23:18:38 +00:00
Suren Baghdasaryan 07de899509 lmkd: fix low swap threshold failing to update after reinit am: 6e6d14b387
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1874517

Change-Id: I2d5854cca756b90ac16b941628b35fe2a32ec802
2021-10-28 23:00:59 +00:00
Suren Baghdasaryan 6e6d14b387 lmkd: fix low swap threshold failing to update after reinit
lmkd calculates low swap threshold using total available swap and
ro.lmk.swap_free_low_percentage property. A wrong assumption is made that
both these values are constant and therefore the threshold can be
calculated once and reused later. However ro.lmk.swap_free_low_percentage
can be changed by the user and lmkd --reinit issued to reapply new
configuration. If that happens low swap threshold will not be updated.
Fix this by calculating the threshold whenever it is used. The overhead
of that calculation is negligible.

Bug: 203161607
Test: setprop ro.lmk.swap_free_low_percentage <new value>; lmkd --reinit
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Idff50655a75d006ea86d9ab10ca54c375c4bea46
2021-10-28 13:30:08 -07:00
Suren Baghdasaryan 57d1c53dc7 Replace writepid with task_profiles command for cgroup migration am: 1938f90eb8 am: 95b23108fa am: 9e0fe78675 am: f269e20364 am: 96dbc22dbc
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1740140

Change-Id: Ia390a2b8e9c1ca9bc636f3236e717d3a55ec42cd
2021-10-15 19:08:37 +00:00
Suren Baghdasaryan 96dbc22dbc Replace writepid with task_profiles command for cgroup migration am: 1938f90eb8 am: 95b23108fa am: 9e0fe78675 am: f269e20364
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1740140

Change-Id: I86b478316ceefc19b2e61c2fdf4b518230db2c7a
2021-10-15 18:55:56 +00:00
Suren Baghdasaryan f269e20364 Replace writepid with task_profiles command for cgroup migration am: 1938f90eb8 am: 95b23108fa am: 9e0fe78675
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1740140

Change-Id: I72c4b517729b76c66090c86f2824773055036118
2021-10-15 18:44:28 +00:00
Suren Baghdasaryan 9e0fe78675 Replace writepid with task_profiles command for cgroup migration am: 1938f90eb8 am: 95b23108fa
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1740140

Change-Id: I0b4f462cc61e8c4b6388edd239ab417a86ca8921
2021-10-15 18:30:04 +00:00
Suren Baghdasaryan 95b23108fa Replace writepid with task_profiles command for cgroup migration am: 1938f90eb8
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1740140

Change-Id: I0762beb6cf6e7a081956938335f85c91f4716bac
2021-10-15 18:18:07 +00:00
Suren Baghdasaryan 1938f90eb8 Replace writepid with task_profiles command for cgroup migration
writepid command usage to join a cgroup has been deprecated in favor
of a more flexible approach using task_profiles. This way cgroup path
is not hardcoded and cgroup changes can be easily made. Replace
writepid with task_profiles command to migrate between cgroups.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I594a5fc5e988f812237bd226aaecefa5f1159d2d
2021-10-15 16:40:18 +00:00
Wei Wang b1a5fa7f59 [automerger skipped] lmkd: move to foreground cpuset before killing am: e80774f4b7 am: c69a10f2e2 -s ours am: 76c70fa606 -s ours
am skip reason: Merged-In Id475625e0d892fb7111a2cf054d1b57d17003d5a with SHA-1 e80774f4b7 is already in history

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

Change-Id: I118cbd73ee5350295712e0805427a294a2eebde6
2021-10-01 21:01:52 +00:00
Wei Wang 18d5549a8f [automerger skipped] lmkd: move to foreground cpuset before killing am: e80774f4b7 -s ours am: cdfda035f2 -s ours am: be5e5bb40e -s ours
am skip reason: Merged-In Id475625e0d892fb7111a2cf054d1b57d17003d5a with SHA-1 730e7a9248 is already in history

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

Change-Id: I64585fd58e58c52387db8205e2dcff330acf1916
2021-10-01 21:01:45 +00:00
Wei Wang 76c70fa606 [automerger skipped] lmkd: move to foreground cpuset before killing am: e80774f4b7 am: c69a10f2e2 -s ours
am skip reason: Merged-In Id475625e0d892fb7111a2cf054d1b57d17003d5a with SHA-1 e80774f4b7 is already in history

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

Change-Id: Ia18cdd6d15a1f2bc24b9b7e97e148bee43a9877a
2021-10-01 20:51:33 +00:00
Wei Wang be5e5bb40e [automerger skipped] lmkd: move to foreground cpuset before killing am: e80774f4b7 -s ours am: cdfda035f2 -s ours
am skip reason: Merged-In Id475625e0d892fb7111a2cf054d1b57d17003d5a with SHA-1 730e7a9248 is already in history

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

Change-Id: Ie87ac4f9b2aee3de378342a0f3c00857a8cd3b1b
2021-10-01 20:50:12 +00:00
Wei Wang cdfda035f2 [automerger skipped] lmkd: move to foreground cpuset before killing am: e80774f4b7 -s ours
am skip reason: Merged-In Id475625e0d892fb7111a2cf054d1b57d17003d5a with SHA-1 730e7a9248 is already in history

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

Change-Id: I56b16242e84de7041d06fca9f434e9765b828e5f
2021-10-01 20:34:31 +00:00
Wei Wang c69a10f2e2 lmkd: move to foreground cpuset before killing am: e80774f4b7
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15956952

Change-Id: I61c3eea83e48d139813d987831b1a72eb7d051d9
2021-10-01 20:34:18 +00:00
Wei Wang b5c806179d lmkd: move to foreground cpuset before killing am: 730e7a9248 am: c2fdae89e4 am: 7cc53280b3 am: efff2cd14b am: 44cd71066b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1842588

Change-Id: Ib2a8367cdcf70d828555a7f4fbcd76a4a3b6d11c
2021-10-01 18:33:05 +00:00
Wei Wang 44cd71066b lmkd: move to foreground cpuset before killing am: 730e7a9248 am: c2fdae89e4 am: 7cc53280b3 am: efff2cd14b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1842588

Change-Id: I205a26b8f45d42c471a6145cdbcebc4be1b4ee7a
2021-10-01 18:23:39 +00:00
Wei Wang efff2cd14b lmkd: move to foreground cpuset before killing am: 730e7a9248 am: c2fdae89e4 am: 7cc53280b3
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1842588

Change-Id: Ieee9b828bd2bf1b754a039284db6775fe8f9c9c5
2021-10-01 18:15:26 +00:00
Wei Wang 7cc53280b3 lmkd: move to foreground cpuset before killing am: 730e7a9248 am: c2fdae89e4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1842588

Change-Id: Ibbc084bafb4b4cbc5ec870076d2aa35238af799d
2021-10-01 18:06:29 +00:00
Wei Wang c2fdae89e4 lmkd: move to foreground cpuset before killing am: 730e7a9248
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1842588

Change-Id: I167412b9121920a1efea698a45447c1bd507f671
2021-10-01 17:58:01 +00:00
Wei Wang e80774f4b7 lmkd: move to foreground cpuset before killing
Test: Build and boot
Bug: 199797672
Signed-off-by: Wei Wang <wvw@google.com>
Merged-In: Id475625e0d892fb7111a2cf054d1b57d17003d5a
Change-Id: Id475625e0d892fb7111a2cf054d1b57d17003d5a
(cherry picked from commit 730e7a9248)
2021-09-30 23:25:34 -07:00
Wei Wang 730e7a9248 lmkd: move to foreground cpuset before killing
Test: Build and boot
Bug: 199797672
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Id475625e0d892fb7111a2cf054d1b57d17003d5a
2021-09-30 23:24:11 -07:00
Wei Wang 12ce19e1e7 [automerger skipped] lmkd: use fd cache for cgroup migration am: 328e612f1b -s ours am: f59352a4d3 -s ours am: 9cfac3746d -s ours
am skip reason: Merged-In Ie7a9eb9676c58309f1407c5f8cc59b302f107d38 with SHA-1 0162e0361f is already in history

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

Change-Id: I7f53f962e05dd51a29ca7e8f1f70cb64dc7e0555
2021-09-22 22:32:43 +00:00