Commit Graph

275 Commits

Author SHA1 Message Date
Suren Baghdasaryan 3ee11d4392 lmkd: Prevent non-main threads being registered or killed by lmkd
Only thread group leaders should be registered with lmkd. Add a check to
ignore any non-leader TIDs and generate an error if such condition is
detected. Run the same check before killing a process to detect cases of
non-leader TIDs being used to kill a process. This might happen if PIDs
overflow and previously registered PID gets reused for a non-leader
thread in the following scenario:

1. pid X is a thread group leader and is registered with lmkd
2. pid X dies without lmkd knowing it and pid gets recycled
3. process Y creates a thread with tid X
4. lmkd kills pid X which results in process Y being killed

Bug: 136408020
Test: lmkd_unit_test
Change-Id: I46c5a0b273f2b72cefc20ec59b80b4393f2a1a37
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-07-12 15:11:54 +00:00
Xin Li 0946569e6e DO NOT MERGE - Skip pi-platform-release (PPRL.190505.001) in stage-aosp-master
Bug: 132622481
Change-Id: I14ace58ee5b4efd490f9213f7a2087d4d56334db
2019-05-14 12:10:14 -07:00
android-build-team Robot 07b0174090 Snap for 5450365 from e6ef013d2c8c1201540128d9961b73450257ab90 to pi-platform-release
Change-Id: I51d6a1b331634e927247a13a96bfdd10d4e00f4f
2019-05-07 22:04:02 +00:00
Jim Blackler ad823c6ac6 Merge "Allow memory metrics on devices that use kernel LMK"
am: 446014ecf9

Change-Id: I9b24267ab63bd4fb58fb36de50561a9c2bf47939
2019-04-30 03:24:06 -07:00
Jim Blackler 700b7191e1 Allow memory metrics on devices that use kernel LMK
Bug: 130017100
Test: Tested manually
Change-Id: I37f6edb71decc1260bd521595842508926fa86aa
2019-04-29 11:02:51 +00:00
Suren Baghdasaryan 8f33f1f8a6 Merge "lmkd: set PSI_POLL_PERIOD to 10ms"
am: e346d03c2b

Change-Id: Ia148c74acf22e2f863eb4f5f411f3e5f0f4e5f55
2019-03-26 22:14:26 -07:00
Suren Baghdasaryan 881a544aec lmkd: set PSI_POLL_PERIOD to 10ms
Occasionally we see cases when 40ms polling is still too conservative.
Change to 10ms polling period. Since the polling happens only after PSI
signal and continues for 1sec this should not affect system performance.

Test: lmkd_unit_test
Bug: 129358844

Change-Id: Ib759b865b2104be23741fc0eacaa541e22d50dde
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-03-27 02:10:10 +00:00
Suren Baghdasaryan 81211b235d Merge "lmkd: Fix meminfo logs missing SwapTotal and having wrong field order"
am: eedd5f6855

Change-Id: I89f2abf04b6b50a69528ccd383b38bb83a8b164c
2019-03-25 15:28:17 -07:00
Suren Baghdasaryan 8a3e0c15c1 lmkd: Fix meminfo logs missing SwapTotal and having wrong field order
Previous change If154dc364711bf7c86f32e24ddcd10be359386de called
"lmkd: Do not downgrade/ignore events when swap is full" added SwapTotal
into meminfo structure without adding the field into events.logtag file.
This results in logs which missing field and all fields starting with
"SwapFree" get reordered as a result. Fix this by adding the missing field
into events.logtag.

Bug: 129274901
Test: Confirm correct information in the logcat
Change-Id: Ia4de3790a7e9d49a0e4cba8b3161a715eaf6532e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-03-25 11:04:11 -07:00
Tim Murray f71c9beded Merge "lmkd: set PSI_POLL_PERIOD to 40ms"
am: 92dcfb3187

Change-Id: Ib8d6a2dc535e9cccad95c790da9454d5550b4cd2
2019-03-13 16:35:39 -07:00
Tim Murray 55e117bd2e Merge "lmkd: set PSI_POLL_PERIOD to 40ms" 2019-03-13 23:27:13 +00:00
Tim Murray 0fca3629ca lmkd: set PSI_POLL_PERIOD to 40ms
200ms was too lenient when under severe memory pressure.

Test: boots, works
Bug: 127765309

Change-Id: I8e047de6318574a107720c56473ed0f25582e182
Signed-off-by: Tim Murray <timmurray@google.com>
2019-03-13 10:13:19 -07:00
The Android Open Source Project 62324f3b00 [automerger skipped] DO NOT MERGE - Merge PPRL.190305.001 into master
am: 4d916a1ece -s ours
am skip reason: subject contains skip directive

Change-Id: I31a0756b75ab6d657dc26807ce8baeb42c40d232
2019-03-12 21:47:32 -07:00
The Android Open Source Project 8199c0f1ca DO NOT MERGE - Merge PPRL.190305.001 into master
Bug: 127812889
Change-Id: I16a546dc24d3cf980ad7ab09895c0d97ee436224
2019-03-11 11:57:28 -07:00
Suren Baghdasaryan e754f1d762 Merge "Add min_score_adj into LmkKillOccurred event"
am: a953ae0546

Change-Id: Ib1a35290221974736f86eda9db57e27e831a4813
2019-03-05 15:11:38 -08:00
Jim Blackler 9388d9d918 Add start time to LmkKillOccurred
This is to measure an application's behavior with respect to being LMKed
(the longer an app lives before being LMKed, the better).

Bug: 119854389
Test: Manual
Change-Id: I4ef6433391c8758626334731d2b5de038e4468ae
Merged-In: I4ef6433391c8758626334731d2b5de038e4468ae
(cherry picked from I4ef6433391c8758626334731d2b5de038e4468ae)
2019-03-05 11:53:17 -08:00
Rajeev Kumar eb7208fbf6 Read memory stats from /proc/pid/stat file.
(cherry pick from commit 0301683e49ab255769b15469487feaab3466167a)
Bug: 117333340
Test: Manual testing using alloc-stress tool
Merged-In: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd

Change-Id: I8ab08606dba7de2f65711204453067dbfbdcbdd8
2019-03-05 11:53:14 -08:00
Suren Baghdasaryan e1228bd545 Add min_score_adj into LmkKillOccurred event
Log min_score_adj when lmkd kills a process to determine the oom_score
levels that lmkd considers during the kill.

Bug: 123024834
Change-Id: I986ae8f2808199b1654bc8d2a32dd88046c79aa3
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-03-05 09:51:06 +00:00
Juju Sung 405fe42b53 Merge "lmkd: Remove redundant free swap and free memory check"
am: 89a7cc48cc

Change-Id: I905a1d573d2fa66588a4dd436f4d1bd4cdf009ff
2019-02-26 02:08:59 -08:00
Xin Li 32bc2d15ec DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master
Bug: 120848293
Change-Id: I92822048a7862acaa669847b2fa9c8f708159952
2019-02-21 11:28:44 -08:00
Juju Sung 94cd15bf22 lmkd: Remove redundant free swap and free memory check
lmkd can't kill processes because it has compare the size between free swap and free memory. Free swap is often larger than the free memory when system is under low memory with less swap-backed or swappable pages and finally leads to I/O thrashing.

Test: TreeHugger
Bug: 124727769
Change-Id: Ia2848859aa97a24bd13c704acee4b86cd2d3f647
2019-02-19 17:04:07 +00:00
Xin Li 27d4026e81 Merge "DO NOT MERGE - Skip pi-platform-release (PPRL.190205.001) into stage-aosp-master" into stage-aosp-master 2019-02-14 22:11:39 +00:00
Pirama Arumuga Nainar 65cc057be1 Merge "Make inlines static"
am: 68c5ce22fb

Change-Id: I08c066b7c49015b07aa46cff884a97d9dd2f675d
2019-02-12 22:42:21 -08:00
Xin Li 4f97674892 DO NOT MERGE - Skip pi-platform-release (PPRL.190205.001) into stage-aosp-master
Bug: 124234733
Change-Id: I10ec04a9bb7e61400796db3d9993ac870b792c99
2019-02-12 16:36:41 -08:00
android-build-team Robot 8600b07f2a Snap for 5180536 from cddcc0d9cf7cbba53e54d67455737a3900ae5d9f to pi-platform-release
Change-Id: Ie01971579962cce36d3170df9c1cb09f8b152520
2019-02-09 02:22:24 +00:00
Pirama Arumuga Nainar f85d4216fd Make inlines static
Bug: http://b/116873221

If not, building with coverage (and -O0) is broken since Clang does not
inline these functions, and does not emit a definition because they are
not static or extern.

Test: Build with coverage (-O0)

Change-Id: I2880119834f764164a1aac10b696e76a2b462b71
2019-02-06 15:19:00 -08:00
Greg Kaiser c5296202ff Merge "lmdk: Remove redundant 'if' check"
am: 6cb668b992

Change-Id: I119eac076221143d673867e2ed54e4c9cc0c2e73
2019-02-04 12:27:27 -08:00
Greg Kaiser 584f3fd35f lmdk: Remove redundant 'if' check
We already know that "polling" must be non-zero at this point,
because it hasn't been modified since our check on line 1960.
So we remove this check for code clarity.

Test: TreeHugger
Change-Id: I069d9fd0eef70748a5333733dd0518d1ac8021b7
2019-02-04 08:50:10 -08:00
Suren Baghdasaryan 627180e7c1 Merge "lmkd: Add support for psi monitors"
am: bec585440c

Change-Id: I68f6210177b96083990631da6d41795c948aeae5
2019-02-01 11:11:04 -08:00
Suren Baghdasaryan 55e3150842 lmkd: Add support for psi monitors
With new psi monitor support in the kernel lmkd can use it to register
custom pressure levels. Add lmkd support for psi monitors when they are
provided by the kernel and use them by default. When kernel does not
support psi lmkd will fall back to vmpressure usage.
Add ability to poll memory status after the initial psi event is triggered
because kernel throttles psi memory pressure events to one per PSI tracking
window (currently set to 1sec). Current implementation polls every 200ms
for 1sec duration after the initial event is triggered.
If ro.lmk.use_psi is set to false psi logic will be disabled even when psi
is supported in kernel.

Bug: 111308141
Test: lmkd_unit_test
Change-Id: I685774b176f393bab7412161773f5c9af51e0163
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-02-01 18:40:32 +00:00
Suren Baghdasaryan c750961a19 Merge "libpsi: initial revision"
am: bb405bf986

Change-Id: I7dde222de933f7f52d4d7e09a6d3806d88e23a69
2019-01-29 21:04:17 -08:00
Tim Murray d6348dfa08 libpsi: initial revision
New library to create, register and destroy PSI monitors in a consistent
way with lmkd.

Test: used within lmkd
Bug: 111308141
Change-Id: If243a97f178e90fe41e2de90c7b858ba82440279
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-30 04:47:28 +00:00
Suren Baghdasaryan 86f94e0e4a [automerger skipped] DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
am: 9491078300 -s ours
am skip reason: subject contains skip directive

Change-Id: I6a090381ab3764d9ea2a5bed1de39aef1872b6a7
2019-01-25 09:21:34 -08:00
Suren Baghdasaryan de92718882 DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
This reverts commit 1bef8c550c6c9118969a93f14d9c5933cb7b2811.

Reason for revert: AOSP is fixed with new vendor image

Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-25 16:49:18 +00:00
Suren Baghdasaryan 87cbcdc3fe [automerger skipped] DO NOT MERGE: Revert "Add libprocessgroup into VNDK"
am: c4a02d25a9 -s ours
am skip reason: subject contains skip directive

Change-Id: I9131c17d5fc372db05699f1aca5138fba1237c7a
2019-01-23 23:08:47 -08:00
Suren Baghdasaryan efeeaafc9b DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy users"
This reverts commit 02843339f998f05c712549658c9f8f8bc14ff57d.

Reason for revert: Broke AOSP

Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-23 20:43:28 -08:00
Wei Wang 6dd07fcb53 lmkd: bump process priority and set to FOREGROUND group before kill
This should help speed up reclaim memory.

Bug: 118468011
Bug: 121439388
Test: run mem-pressure with lmkd
Change-Id: Iae7aa35483eb0e8bbeccaa425559c6021c845ee1
Merged-In: Iae7aa35483eb0e8bbeccaa425559c6021c845ee1
2019-01-23 05:20:36 +00:00
Suren Baghdasaryan 8d13df7d38 Merge changes from topic "move sched_policy functions"
am: ca50ee91b5

Change-Id: I92310f7dd60384b95c056c98cdc616857ebcd1ec
2019-01-22 13:03:07 -08:00
Suren Baghdasaryan fb99b0a5f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Wei Wang 2b34702a8b Merge "lmkd: bump process priority and set to FOREGROUND group before kill"
am: 3f4b005022

Change-Id: Ib77699153224bcc95c0929bc59361702c50bce94
2019-01-15 19:13:21 -08:00
Wei Wang 8c55f2b664 Merge "lmkd: bump process priority and set to FOREGROUND group before kill" 2019-01-16 03:06:21 +00:00
Tom Cherry 281f6bb95e Merge "lmkd: add missing libcutils library to test" am: 173a02b439
am: 5928869e6f

Change-Id: Iba2f41f1c83b58df0ecff2fd6cf5d395bfa051b4
2019-01-15 17:23:58 -08:00
Tom Cherry ef9cbe71b2 Merge "lmkd: add missing libcutils library to test"
am: 173a02b439

Change-Id: Ib3dc6e124cfc129145e43ae806de73061652cb08
2019-01-15 17:03:49 -08:00
Wei Wang f1ee2e1505 lmkd: bump process priority and set to FOREGROUND group before kill
This should help speed up reclaim memory.

Bug: 118468011
Test: run mem-pressure with lmkd
Change-Id: Iae7aa35483eb0e8bbeccaa425559c6021c845ee1
2019-01-15 14:50:19 -08:00
Tom Cherry 4a28d2a270 lmkd: add missing libcutils library to test
lmkd's test depends on the socket_local_client() function from
libcutils, but since liblog also exposes this symbol weakly, that is
the symbol that gets used instead of the intended libcutil's copy of
the symbol.

Test: build
Change-Id: I294fa157a7f50881bf6360922419976eb1ee3ac7
2019-01-15 14:14:20 -08:00
Jim Blackler 5ce271a2c5 [automerger skipped] Merge "Add start time to LmkKillOccurred" am: 34f55bd45a
am: 258b220b01 -s ours
am skip reason: SHA1 258b220b01 skipped by user jimblackler

Change-Id: Iddcb13c6aacfefdc505c7fdcb1cd525c0713bb71
2019-01-09 05:19:00 -08:00
Jim Blackler 350fecb560 Merge "Add start time to LmkKillOccurred"
am: 34f55bd45a

Change-Id: I912af2f3ac71fda3d949deb5189ff1834340f08f
2019-01-09 00:57:22 -08:00
Jim Blackler f52bcb9c8f Add start time to LmkKillOccurred
This is to measure an application's behavior with respect to being LMKed
(the longer an app lives before being LMKed, the better).

Bug: 119854389
Test: Manual
Change-Id: I4ef6433391c8758626334731d2b5de038e4468ae
Merged-In: I4ef6433391c8758626334731d2b5de038e4468ae
(cherry picked from I4ef6433391c8758626334731d2b5de038e4468ae)
2019-01-04 11:36:54 +00:00
Xin Li 4500cc1cce [automerger skipped] DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master am: 2f2f638fdf -s ours
am: 0acfc87001  -s ours

Change-Id: I71bc8d4951bfdbbac6647f875827b7e1c217106e
2018-12-13 12:21:31 -08:00
Xin Li d45d6e6326 [automerger skipped] DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master
am: 2f2f638fdf  -s ours

Change-Id: Ieb3bb5fae81eebeca7596ca4901c2dc77ec8733e
2018-12-13 11:26:27 -08:00