Commit Graph

1307 Commits

Author SHA1 Message Date
Vova Sharaienko b518701c91 lmkd: reroute atoms logging to AMS am: 6f11aff418
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/14313337

Change-Id: I244bd8606c3aefb426939ed65c9d54f3c784c1bc
2021-05-11 15:35:16 +00:00
Vova Sharaienko a92b76b54d lmkd: reroute atoms logging to AMS
- Added new lmkd message for clients to subscribe LMK_ASYNC_EVENT_STAT
- Added support to write kill & mem stats information via data socket
  to be read & parsed on the AMS Java side for future logging to statsd

Bug: 184698933
Test: lmkd_unit_test - test check_for_oom tests lmkd message send to AMS
Test: statsd_testdrive 51 54 to inspect statsd logged atoms data
Change-Id: Id682a438c87b3e4503261d26461f6cee641d86c4
Merged-In: Id682a438c87b3e4503261d26461f6cee641d86c4
2021-05-11 00:00:56 +00:00
Vova Sharaienko 35804ede5f lmkd: reroute atoms logging to AMS am: 6f11aff418 am: 56a9b111e6
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/14313337

Change-Id: I066f8050b7575351f637feedd34c3e3f2619760c
2021-05-10 23:54:27 +00:00
Vova Sharaienko 56a9b111e6 lmkd: reroute atoms logging to AMS am: 6f11aff418
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/14313337

Change-Id: I724e3fa85935a7986055cec4566f573b5da40c51
2021-05-10 23:48:17 +00:00
Vova Sharaienko 45fa6a05cb lmkd: reroute atoms logging to AMS am: 6f11aff418
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/14313337

Change-Id: Ib2853c76fbdd6c427b657b79c03a5499fc64a43c
2021-05-10 23:46:10 +00:00
Vova Sharaienko ac99efa3ad lmkd: reroute atoms logging to AMS am: 6f11aff418
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/14313337

Change-Id: I5938ed104f5cbb2dad158b8f79cd68624f9b9638
2021-05-10 23:45:57 +00:00
Vova Sharaienko 6f11aff418 lmkd: reroute atoms logging to AMS
- Added new lmkd message for clients to subscribe LMK_ASYNC_EVENT_STAT
- Added support to write kill & mem stats information via data socket
  to be read & parsed on the AMS Java side for future logging to statsd

Bug: 184698933
Test: lmkd_unit_test - test check_for_oom tests lmkd message send to AMS
Test: statsd_testdrive 51 54 to inspect statsd logged atoms data
Change-Id: Id682a438c87b3e4503261d26461f6cee641d86c4
2021-05-03 21:47:22 +00:00
Suren Baghdasaryan 4de47eb096 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6 am: 918648b001 am: a8c2e1ece9
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: Ie627c0c28e256c329c64d10c8d672cddee7545cf
2021-04-30 03:04:38 +00:00
Suren Baghdasaryan a8c2e1ece9 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6 am: 918648b001
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: Icc800f4159c7875bb28988aae9bc4240e23ff015
2021-04-30 02:40:45 +00:00
Suren Baghdasaryan 9aede48461 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6 am: 918648b001
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: Ib8be1ec661265fb33bd5420dcf2374fd153375db
2021-04-30 02:39:38 +00:00
Suren Baghdasaryan 5ceb07c9c7 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6 am: 918648b001
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: I94a95b724ce88a97f94ea9e83a95cdff8f085e1f
2021-04-30 02:39:05 +00:00
Suren Baghdasaryan 1174827c4d lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6 am: 918648b001
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: I5b38c0bbf186df02c2679a619fce20af02303b12
2021-04-30 02:38:43 +00:00
Suren Baghdasaryan 918648b001 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0 am: 28164d3cc6
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: Id8369cec0cbd39e4895e24eeffe824506fd3fb13
2021-04-30 01:40:22 +00:00
Suren Baghdasaryan 28164d3cc6 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800 am: 8aec07bbe0
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: Id59a056468b053d2c28206959d8295937c9788e1
2021-04-30 00:59:58 +00:00
Suren Baghdasaryan 8aec07bbe0 lmkd: Do not treat RSS=0 as a sign of a process being dead am: 5263aa7800
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1690656

Change-Id: I785575f6428b89bb59df690828fb60dc73f7d6e7
2021-04-30 00:35:22 +00:00
Suren Baghdasaryan 5263aa7800 lmkd: Do not treat RSS=0 as a sign of a process being dead
With kernel SPLIT_RSS_COUNTING feature it is possible for a valid
process to report RSS of 0 size when reading /proc/pid/statm. This
happens because split RSS accounting aggregates per-thread counters
asynchronously and depending on the timing of the read, reported
value can be inaccurate and occasionally be 0.
lmkd currently treats processes reporting RSS of 0 as dead and
removes them from the list of processes being tracked. This might
lead to a valid process becoming unkillable.
Change lmkd to stop treating RSS of 0 as a sign of a dead process.

Bug: 160199622
Test: set ro.lmk.kill_heaviest_task=true and hack kernel to report RSS=0
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia311d2f98649c92d1a487657f94ea51f57813b73
2021-04-29 15:33:06 -07:00
Suren Baghdasaryan f42759567e lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a am: d7838b8e06 am: c30dd665ba am: e67d7be9e4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: Id1b01af0d1c5b3655dae734a02dabc590b79ebce
2021-04-24 00:14:34 +00:00
Suren Baghdasaryan d9cae1e040 lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a am: d7838b8e06 am: c30dd665ba am: e67d7be9e4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: Iabc973097334994ffbbc6111a3fa8f36b298f478
2021-04-24 00:14:25 +00:00
Suren Baghdasaryan 5800a8474d lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a am: d7838b8e06 am: c30dd665ba am: e67d7be9e4
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: I3ce5bfb7818f784db02ae6a4618edc3c2b8a4563
2021-04-24 00:11:49 +00:00
Suren Baghdasaryan e67d7be9e4 lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a am: d7838b8e06 am: c30dd665ba
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: I0b430aeda1892a8916ac2538824496b0132c551e
2021-04-23 23:48:05 +00:00
Suren Baghdasaryan c30dd665ba lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a am: d7838b8e06
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: I0ee304f6d85704ffdfe7868379a2dfe5ab28c22e
2021-04-23 23:25:43 +00:00
Suren Baghdasaryan d7838b8e06 lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: I048051fbbcf880642206e0a219171e7474fc677d
2021-04-23 23:04:06 +00:00
Suren Baghdasaryan e5995b8269 lmkd: Handle cases when proc_get_name() might return NULL
proc_get_name() can return NULL if the corresponding process has died
or open fails with ENOMEM due to memory shortages.
Ensure such cases are handled without NULL pointer access.

Bug: 186157675
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I05b288e3808bec0bdb73db32de02ba3a322ca6e1
2021-04-23 21:18:35 +00:00
Suren Baghdasaryan 9f1be12b9a lmkd: Handle cases when proc_get_name() might return NULL
proc_get_name() can return NULL if the corresponding process has died
or open fails with ENOMEM due to memory shortages.
Ensure such cases are handled without NULL pointer access.

Bug: 186157675
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I05b288e3808bec0bdb73db32de02ba3a322ca6e1
2021-04-23 21:18:18 +00:00
android-build-team Robot 547707cc2e Snap for 7269201 from e68bfe9a73 to rvc-qpr3-release
Change-Id: I4121184ff7bb28e9ee2d7e029d6d875833c46504
2021-04-08 22:07:02 +00:00
Suren Baghdasaryan 78c0e9721a [automerger skipped] lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: e68bfe9a73 -s ours am: 0107f3c655 -s ours am: 3fc2bcd6ad -s ours
am skip reason: skip tag Change-Id Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0 with SHA-1 0142b3c166 is already in history

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

Change-Id: I8cffc3dfa7b690bb7d6047c2673e73f9d3e7ddaa
2021-04-08 06:55:45 +00:00
Suren Baghdasaryan 3bb9e3613c [automerger skipped] lmkd: choose the heaviest task when killing perceptible processes am: 720abce177 -s ours am: c5bc8cb7fa -s ours am: 09a988ee63 -s ours
am skip reason: skip tag Change-Id I775ff774430b6fde4d619ede794825dbae59fd8e with SHA-1 858e8c6373 is already in history

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

Change-Id: If0508ce65fa4f9d2b1d90c606253ac149fa80632
2021-04-08 06:55:43 +00:00
Suren Baghdasaryan 98aad848f9 [automerger skipped] lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: e68bfe9a73 -s ours am: 0107f3c655 -s ours am: 3fc2bcd6ad -s ours
am skip reason: skip tag Change-Id Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0 with SHA-1 0142b3c166 is already in history

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

Change-Id: I9828fd3c371c2ba8eb1bdfcf11beb089340daf4f
2021-04-08 06:55:24 +00:00
Suren Baghdasaryan efd8fd8440 [automerger skipped] lmkd: choose the heaviest task when killing perceptible processes am: 720abce177 -s ours am: c5bc8cb7fa -s ours am: 09a988ee63 -s ours
am skip reason: skip tag Change-Id I775ff774430b6fde4d619ede794825dbae59fd8e with SHA-1 858e8c6373 is already in history

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

Change-Id: I02cf9bcc8edec0fc114bb95020b88b5a051006ad
2021-04-08 06:55:23 +00:00
Suren Baghdasaryan 3fc2bcd6ad [automerger skipped] lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: e68bfe9a73 -s ours am: 0107f3c655 -s ours
am skip reason: skip tag Change-Id Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0 with SHA-1 0142b3c166 is already in history

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

Change-Id: I166723399de996ccfcd2eececd6ad8bc7ae557e7
2021-04-08 06:20:01 +00:00
Suren Baghdasaryan 09a988ee63 [automerger skipped] lmkd: choose the heaviest task when killing perceptible processes am: 720abce177 -s ours am: c5bc8cb7fa -s ours
am skip reason: skip tag Change-Id I775ff774430b6fde4d619ede794825dbae59fd8e with SHA-1 858e8c6373 is already in history

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

Change-Id: Ib28ff7ce4e4b7f20b2fb6758b9d50320d6d9afad
2021-04-08 06:20:01 +00:00
Suren Baghdasaryan 0107f3c655 [automerger skipped] lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: e68bfe9a73 -s ours
am skip reason: skip tag Change-Id Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0 with SHA-1 0142b3c166 is already in history

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

Change-Id: Ic33eb574acd23965cb6f7742ccc2093b3e0033b3
2021-04-08 05:52:00 +00:00
Suren Baghdasaryan c5bc8cb7fa [automerger skipped] lmkd: choose the heaviest task when killing perceptible processes am: 720abce177 -s ours
am skip reason: skip tag Change-Id I775ff774430b6fde4d619ede794825dbae59fd8e with SHA-1 858e8c6373 is already in history

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

Change-Id: I38ceae15c85ab3e02f4bb3e25d88729ed779406e
2021-04-08 05:51:59 +00:00
Suren Baghdasaryan e68bfe9a73 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing
Occasionally a system can get into heavy file cache thrashing situation
and become unresponsive. In these situations we observe lmkd wakeups,
however it does not kill because all non-perceptible apps are already
killed and the system manages to reclaim enough memory to stay above
min watermark.
Add ro.lmk.thrashing_limit_critical property which when breached will
allow lmkd to kill perceptible apps. The property represents the
percentage of refaulted workingset pages as a fraction of overall file
cache size. By default it is disabled.

Bug: 181778155
Test: thrashing.py 500 10 200
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0
Change-Id: Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0
2021-04-07 11:55:04 +08:00
Suren Baghdasaryan 720abce177 lmkd: choose the heaviest task when killing perceptible processes
When killing a task at or lower than oom_score_adj PERCEPTIBLE_APP_ADJ
choose the heaviest task among the ones at that level to try minimizing
the number of required kills. Because killing a perceptible app will
affect user experience anyway, it makes sense to choose the one that
will release the most memory and therefore no more kills might be
necessary.

Bug: 181778155
Test: running thrashing.py script
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Merged-In: I775ff774430b6fde4d619ede794825dbae59fd8e
Change-Id: I775ff774430b6fde4d619ede794825dbae59fd8e
2021-04-07 11:50:57 +08:00
Suren Baghdasaryan dda9c07f98 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: 0142b3c166 am: 7ccd2c10ee am: eb09287574 am: dff35b7973
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1653491

Change-Id: I9bc8321ba0d306bac0a78693355501aaf80c44ef
2021-03-31 21:54:35 +00:00
Suren Baghdasaryan 87da516822 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: 0142b3c166 am: 7ccd2c10ee am: eb09287574 am: dff35b7973
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1653491

Change-Id: I6d1a1ca31455c8da156b6527016ec484f709bfe3
2021-03-31 21:53:14 +00:00
Suren Baghdasaryan dff35b7973 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: 0142b3c166 am: 7ccd2c10ee am: eb09287574
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1653491

Change-Id: I993499fa1c3b3fc8e0ff278ea31df8ff9c606af7
2021-03-31 21:18:13 +00:00
Suren Baghdasaryan eb09287574 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: 0142b3c166 am: 7ccd2c10ee
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1653491

Change-Id: I3bd353b448a3a6f886805704d64ffd23bc8f46a4
2021-03-31 20:32:29 +00:00
Suren Baghdasaryan 7ccd2c10ee lmkd: Allow lmkd to kill perceptible apps during heavy thrashing am: 0142b3c166
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1653491

Change-Id: I1e014a9ccf2b1d6db1407c01feb3bc9794243c05
2021-03-31 19:56:50 +00:00
Suren Baghdasaryan 0142b3c166 lmkd: Allow lmkd to kill perceptible apps during heavy thrashing
Occasionally a system can get into heavy file cache thrashing situation
and become unresponsive. In these situations we observe lmkd wakeups,
however it does not kill because all non-perceptible apps are already
killed and the system manages to reclaim enough memory to stay above
min watermark.
Add ro.lmk.thrashing_limit_critical property which when breached will
allow lmkd to kill perceptible apps. The property represents the
percentage of refaulted workingset pages as a fraction of overall file
cache size. By default it is disabled.

Bug: 181778155
Test: thrashing.py 500 10 200
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Icb38ef6c90adaa4f5c956593b6ea0c4febc91dc0
2021-03-25 17:00:09 -07:00
Josh Gao 27e61cbf4a Switch to Bionic's pidfd wrappers. am: 84623bef7b am: 7e7793b48d am: 46b431749e am: dfd2dff7cb
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1646355

Change-Id: Ic36605f82ee6e0df8ce227fdc4cf52eff0dcc2d0
2021-03-19 19:58:06 +00:00
Josh Gao e3c33315f2 Switch to Bionic's pidfd wrappers. am: 84623bef7b am: 7e7793b48d am: 46b431749e am: dfd2dff7cb
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1646355

Change-Id: I150c51aa021f79b5597d5c472ca0561792312c4f
2021-03-19 19:57:58 +00:00
Josh Gao dfd2dff7cb Switch to Bionic's pidfd wrappers. am: 84623bef7b am: 7e7793b48d am: 46b431749e
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1646355

Change-Id: I7ea977c432125052ba7d845f3a59587806c355cb
2021-03-19 19:21:06 +00:00
Josh Gao 46b431749e Switch to Bionic's pidfd wrappers. am: 84623bef7b am: 7e7793b48d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1646355

Change-Id: Ib9c7982acf005a17d113bd36d96635884d531bde
2021-03-19 18:58:24 +00:00
Josh Gao 7e7793b48d Switch to Bionic's pidfd wrappers. am: 84623bef7b
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1646355

Change-Id: I14598a17121770a9175b3ac1e6f46c31b21751de
2021-03-19 18:38:42 +00:00
Josh Gao 84623bef7b Switch to Bionic's pidfd wrappers.
Bug: http://b/172518739
Test: treehugger
Change-Id: Ib6cac8f31ec64343c6eec6b82dac52888890c688
2021-03-18 17:16:08 -07:00
Suren Baghdasaryan 488929daf0 lmkd: choose the heaviest task when killing perceptible processes am: 858e8c6373 am: c71ce3fed4 am: e1bfcc3cac am: 5498a6e98d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1619563

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7adf5dae9b119e09cf8a116aed804d26abf75565
2021-03-05 20:35:03 +00:00
Suren Baghdasaryan f9d7b22e31 lmkd: fix log message reporting the breached watermark am: 236781873f am: e452c6be98 am: 4847bb51f5 am: 8d0351f6d5
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1619562

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I5170247334482f83a96062239535316ee01adfbc
2021-03-05 20:35:02 +00:00
Suren Baghdasaryan 094c37f632 lmkd: choose the heaviest task when killing perceptible processes am: 858e8c6373 am: c71ce3fed4 am: e1bfcc3cac am: 5498a6e98d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1619563

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I492d727e5ec65e6424b239078000680250f59497
2021-03-05 20:34:46 +00:00