Suren Baghdasaryan
ed79eb8f6c
lmkd: Allow killing perceptible apps when recorded stall is too high am: 5ae47a9563 am: 744462fdf0 am: 38cbc12b33 am: 915a384a57 am: cddacf8864
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1992290
Change-Id: I97db54a753ab388a8a21a9813ea9483d5d16eaa5
2022-02-22 12:55:42 +00:00
Suren Baghdasaryan
6b34e5423e
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: If0e1ba079c04e386b64b54784ce248c5db4e412d
2022-02-22 12:34:12 +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
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
Xin Li
2a6c586684
Empty merge of sc-v2-dev-plus-aosp-without-vendor@8084891
...
Bug: 214455710
Merged-In: I56a55834582e11c06cc6cf9da3bc7380e634b301
Change-Id: I797ed9d8872a2bdef27a9f2e4053874f88bdd56c
2022-02-11 06:17:36 +00:00
Suren Baghdasaryan
b66ac6134a
lmkd/tests: Consume memory more aggressively to avoid test timeout am: 2bf5487381 am: 99cb321008 am: c701f32c23 am: 81b6597577
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972099
Change-Id: I7f4504ff20c0029d8c208739187c363f55b3f321
2022-02-04 01:10:54 +00:00
Suren Baghdasaryan
81b6597577
lmkd/tests: Consume memory more aggressively to avoid test timeout am: 2bf5487381 am: 99cb321008 am: c701f32c23
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972099
Change-Id: I9d964c75c5f923e5d4db2790fa96382eb5e387f6
2022-02-04 00:59:36 +00:00
Suren Baghdasaryan
c701f32c23
lmkd/tests: Consume memory more aggressively to avoid test timeout am: 2bf5487381 am: 99cb321008
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972099
Change-Id: I35abb6e745ed1c874d38b1eadd22c1daf021e4ec
2022-02-04 00:38:32 +00:00
Suren Baghdasaryan
99cb321008
lmkd/tests: Consume memory more aggressively to avoid test timeout am: 2bf5487381
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1972099
Change-Id: I16cbef5d2680d974604c27b5940c5dadaf9395e9
2022-02-04 00:26:37 +00:00
Suren Baghdasaryan
2bf5487381
lmkd/tests: Consume memory more aggressively to avoid test timeout
...
Increase the allocation step to 5MB and decrease the delay between
allocations to 200ms in order to speed up memory consumption and
avoid the test timing out.
Bug: 217478668
Test: atest lmkd_tests:lmkd_tests.LmkdTest#TargetReaping -- --abi x86_64
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia36229b280d79acd9d93a5ca1961d6cf1ef223df
2022-02-03 14:53:00 -08:00
Suren Baghdasaryan
f0674bce25
lmkd/tests: Move tests into presubmit-large category to avoid timeouts am: c58acac201 am: baeb509b2e am: 441dc7c66b am: 7cb56c0b12
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1969139
Change-Id: I5de02e4848e55c642711327b42240163a375abbc
2022-02-02 20:23:48 +00:00
Suren Baghdasaryan
7cb56c0b12
lmkd/tests: Move tests into presubmit-large category to avoid timeouts am: c58acac201 am: baeb509b2e am: 441dc7c66b
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1969139
Change-Id: I11f82cd53ed8692fd3946ca55bd88efbb5646a70
2022-02-02 20:07:08 +00:00
Suren Baghdasaryan
441dc7c66b
lmkd/tests: Move tests into presubmit-large category to avoid timeouts am: c58acac201 am: baeb509b2e
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1969139
Change-Id: Ic7f3b601c89299404fec4be0281cd03cce48fffc
2022-02-02 19:55:20 +00:00
Suren Baghdasaryan
baeb509b2e
lmkd/tests: Move tests into presubmit-large category to avoid timeouts am: c58acac201
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1969139
Change-Id: I5adb706b3a6f70bdded22a11ca3eb3709573554e
2022-02-02 19:44:08 +00:00
Suren Baghdasaryan
c58acac201
lmkd/tests: Move tests into presubmit-large category to avoid timeouts
...
Since lmkd tests require time to build up memory pressure, they cause
timeouts when run as part of presubmits. Move them into the
presubmit-large category with higher timeout to prevent such failures.
Bug: 217478668
Bug: 203597692
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I690133c9f849da58b85884a7d7b463f5b518c12f
2022-02-02 09:27:47 -08:00
Suren Baghdasaryan
599d11ab51
lmkd/tests: Add a test to check for lmkd process reaping capability am: 683d6cbc2d am: 4805030ba6 am: 73bdbb628e am: 1eccbfacfe
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1964686
Change-Id: Ie10c754b2d84d7e9352f14873dc324a47221bd96
2022-02-02 02:50:30 +00:00
Suren Baghdasaryan
1eccbfacfe
lmkd/tests: Add a test to check for lmkd process reaping capability am: 683d6cbc2d am: 4805030ba6 am: 73bdbb628e
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1964686
Change-Id: I1459eea1dc1a0bb2ff746e13f8cfb5b46779c17c
2022-02-02 02:31:24 +00:00
Suren Baghdasaryan
73bdbb628e
lmkd/tests: Add a test to check for lmkd process reaping capability am: 683d6cbc2d am: 4805030ba6
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1964686
Change-Id: Ib62946f204fd993e380b8a51d1af7bedba6035b2
2022-02-02 02:15:09 +00:00
Suren Baghdasaryan
4805030ba6
lmkd/tests: Add a test to check for lmkd process reaping capability am: 683d6cbc2d
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1964686
Change-Id: I87df80195eb51d156930e98d3ae862fe4a40cd12
2022-02-02 01:58:40 +00:00
Suren Baghdasaryan
683d6cbc2d
lmkd/tests: Add a test to check for lmkd process reaping capability
...
Add a test to verify a process killed by lmkd is being reaped when
kernel supports process_mrelease syscall.
Bug: 203597692
Test: atest LmkdTest
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iac46f68c811e6e89378952ce1d29daf8a47514e2
2022-02-01 11:40:47 -08:00
Suren Baghdasaryan
7ed77b51a3
[automerger skipped] lmkd: Set task profiles to the entire process am: b8cdb6ac91 -s ours am: 9f0e529b51 -s ours
...
am skip reason: Merged-In I9c1917172019a42809385f6c9c084b8cb343b520 with SHA-1 2bdf7f0c74 is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/16687016
Change-Id: Iebf6d96ced5fe476d0e539680084ef528f30fedf
2022-01-26 01:10:02 +00:00
Suren Baghdasaryan
9f0e529b51
[automerger skipped] lmkd: Set task profiles to the entire process am: b8cdb6ac91 -s ours
...
am skip reason: Merged-In I9c1917172019a42809385f6c9c084b8cb343b520 with SHA-1 2bdf7f0c74 is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/16687016
Change-Id: I1fdfa86e29514f91dc06eaa35c6f1ed10b7f7ce4
2022-01-26 00:51:33 +00:00
Suren Baghdasaryan
d385f7ec5c
lmkd: Set task profiles to the entire process am: 2bdf7f0c74 am: a734b3bff1 am: 85154e02b0 am: 3fcdbaaeab
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1956501
Change-Id: I2d05287f66408b2cead68ca92b51c63904e8a6aa
2022-01-25 06:15:25 +00:00
Suren Baghdasaryan
3fcdbaaeab
lmkd: Set task profiles to the entire process am: 2bdf7f0c74 am: a734b3bff1 am: 85154e02b0
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1956501
Change-Id: I824f5e7303b33eb4bc132f0e1237fde462d600a6
2022-01-25 06:01:54 +00:00
Suren Baghdasaryan
85154e02b0
lmkd: Set task profiles to the entire process am: 2bdf7f0c74 am: a734b3bff1
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1956501
Change-Id: I4dbfdc5d49055ef386aa5aa4dc1354a41010744f
2022-01-25 05:46:16 +00:00
Suren Baghdasaryan
a734b3bff1
lmkd: Set task profiles to the entire process am: 2bdf7f0c74
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1956501
Change-Id: I752c7df4c1bc4fe9867f88da95081949eaaa51b3
2022-01-25 05:32:53 +00:00
Suren Baghdasaryan
b8cdb6ac91
lmkd: Set task profiles to the entire process
...
set_process_group_and_prio sets task profiles for each thread in the
process separately. This can be avoided by setting task profiles to
the entire process using its pid.
Bug: 215557553
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9c1917172019a42809385f6c9c084b8cb343b520
Merged-In: I9c1917172019a42809385f6c9c084b8cb343b520
2022-01-25 05:17:00 +00:00
Suren Baghdasaryan
2bdf7f0c74
lmkd: Set task profiles to the entire process
...
set_process_group_and_prio sets task profiles for each thread in the
process separately. This can be avoided by setting task profiles to
the entire process using its pid.
Bug: 215557553
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9c1917172019a42809385f6c9c084b8cb343b520
2022-01-24 13:43:42 -08:00
Yi Kong
d5a3026a3c
Turn on AFDO for lmkd am: edd3325830 am: 7fb6b9cfb3 am: 4185e681b1 am: 467ea66616
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1951041
Change-Id: Id94da60288d145bee04644efb2c0508fa4201b11
2022-01-18 22:12:37 +00:00
Yi Kong
467ea66616
Turn on AFDO for lmkd am: edd3325830 am: 7fb6b9cfb3 am: 4185e681b1
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1951041
Change-Id: Ic8cb804c2b32a0f75d29ae30f14981de7d5962ed
2022-01-18 21:54:23 +00:00
Yi Kong
4185e681b1
Turn on AFDO for lmkd am: edd3325830 am: 7fb6b9cfb3
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1951041
Change-Id: Id74a11b3c1ddb9d374f76c10417d32051e08121a
2022-01-18 21:37:32 +00:00
Yi Kong
7fb6b9cfb3
Turn on AFDO for lmkd am: edd3325830
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1951041
Change-Id: Iedc6b4d34d9489a66807d791261b4fa909cfab02
2022-01-18 21:16:51 +00:00
Yi Kong
edd3325830
Turn on AFDO for lmkd
...
Enable PGO (profile guided optimisation) for better performance.
Bug: 195134194
Bug: 175205560
Test: presubmit
Change-Id: I97fb9945bfe9afa3396b850518fadaf7b9f38eaa
2022-01-17 07:36:59 +00:00
Suren Baghdasaryan
e28853cc7c
lmkd: Implement watchdog thread am: af1b0e0627 am: ac20c53b63 am: c871dc1afc am: bdb7ccf532
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1894200
Change-Id: If69f77981ae78431b8b3c078ee01e13314b7f85e
2022-01-06 22:52:50 +00:00
Suren Baghdasaryan
9a3d1b6515
lmkd: Use process_mrelease to reap the target process from a thread am: 7c3addb2a1 am: c4067fc9f2 am: 0fee08b289 am: 4253f17b9d
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1904583
Change-Id: I1ea8615d891415d005efc8cb70b2c26b36da9f92
2022-01-06 22:52:48 +00:00
Suren Baghdasaryan
bdb7ccf532
lmkd: Implement watchdog thread am: af1b0e0627 am: ac20c53b63 am: c871dc1afc
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1894200
Change-Id: I13e24f1b7dfe92359d56344e133843f0f64cec4e
2022-01-06 22:39:07 +00:00
Suren Baghdasaryan
4253f17b9d
lmkd: Use process_mrelease to reap the target process from a thread am: 7c3addb2a1 am: c4067fc9f2 am: 0fee08b289
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1904583
Change-Id: I24dc3a14edb46028b1768b7e5e9244a48559216d
2022-01-06 22:39:06 +00:00
Suren Baghdasaryan
c871dc1afc
lmkd: Implement watchdog thread am: af1b0e0627 am: ac20c53b63
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1894200
Change-Id: I66fc6bd55480517fd1374e376476ffef174f6679
2022-01-06 22:24:04 +00:00
Suren Baghdasaryan
0fee08b289
lmkd: Use process_mrelease to reap the target process from a thread am: 7c3addb2a1 am: c4067fc9f2
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1904583
Change-Id: I224057073a3fd0c569eb5803eb2c56710b01fc77
2022-01-06 22:24:03 +00:00
Suren Baghdasaryan
ac20c53b63
lmkd: Implement watchdog thread am: af1b0e0627
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1894200
Change-Id: Ic96fb2bed49eb019d8163cd31671beb3176afd43
2022-01-06 22:02:58 +00:00
Suren Baghdasaryan
c4067fc9f2
lmkd: Use process_mrelease to reap the target process from a thread am: 7c3addb2a1
...
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1904583
Change-Id: I21a13a46890d2eee9ddd66cbeaec1c8f3e9317f4
2022-01-06 22:02:57 +00:00
Suren Baghdasaryan
af1b0e0627
lmkd: Implement watchdog thread
...
To detect lmkd being stuck on a syscall for prolonged period of time,
introduce a watchdog thread which gets set when lmkd starts handling of
events and is reset after handling is done. If it takes more than the
timeout period (2 sec) to handle an event, watchdog wakes up and kills
the least important process to prevent mounting memory pressure caused
by lmkd lockup. After a kill, watchdog will wait for the reset for
another timeout period and kill again. This repeats until lmkd unlocks
and resets the watchdog.
Bug: 201671997
Test: induce random sleep in lmkd main handler and observe watchdog kills
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I56a55834582e11c06cc6cf9da3bc7380e634b301
2022-01-06 18:14:25 +00:00
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