Commit Graph

941 Commits

Author SHA1 Message Date
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 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 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 dbb9a69dc6 lmkd: use fd cache for cgroup migration am: 0162e0361f
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1833054

Change-Id: Ie70f8800acdef24ccf8731215ce1b1cae8e01539
2021-09-22 18:27:25 +00:00
Wei Wang 0162e0361f lmkd: use fd cache for cgroup migration
Test: Build
Bug: 199797672
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Ie7a9eb9676c58309f1407c5f8cc59b302f107d38
2021-09-21 14:38:49 -07:00
Wei Wang a95efc0941 lmkd: migrate process to FOREGROUND sched group before kill am: 0195bcdba7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1825954

Change-Id: I9b572a9786cf5b7a583730654facca0e30bf57bb
2021-09-14 14:48:51 +00:00
Wei Wang 0195bcdba7 lmkd: migrate process to FOREGROUND sched group before kill
BG group may have settings such as cpu.shares impacting reclaim
performance. Let us migrate task to foreground sched group similarly to
cpuset group.

Test: Build
Bug: 199797672
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I75ee9f3486a2c76e65267a98e39edff96a5e1673
2021-09-13 19:07:26 -07:00
Suren Baghdasaryan e87dd04e20 lmkd: Do not re-initialize lmkd when persistent properties are loaded am: 0e64eadc21
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1815756

Change-Id: I9862d501675abeec5f4306e111d148bcc7ae8fb9
2021-09-01 23:58:43 +00:00
Suren Baghdasaryan 0e64eadc21 lmkd: Do not re-initialize lmkd when persistent properties are loaded
When a device boots, lmkd starts before persistent properties are loaded,
therefore if experiments set any flags, the corresponding persistent
properties will trigger change notifications when they are first loaded
during boot.
In order to prevent lmkd from re-initializing on every property load,
mark persistent property change by setting lmkd.reinit to 0 and delay
lmkd re-initialization until sys.boot_completed=1 when all properties
are set and only one re-initialization will capture them all. On devices
with no experiment flags being set lmkd.reinit will be undefined at the
boot completion time and re-initialization will not be triggered at all.

Bug: 194316048
Test: adb shell device_config put lmkd_native thrashing_limit_critical 350
Test: adb shell device_config put lmkd_native thrashing_limit 100
Test: adb reboot; adb -b all logcat | grep lmkd
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iba34fc719a18d58b890549c7415bec869d471901
2021-09-01 00:56:35 -07:00
Suren Baghdasaryan c51f018a6d lmkd: Add support for persist.device_config.lmkd_native.* properties am: d0a800402c
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1785437

Change-Id: Ib77d4ce588ec31631e6721130ea0a163afe83bed
2021-08-31 19:52:44 +00:00
Suren Baghdasaryan d0a800402c lmkd: Add support for persist.device_config.lmkd_native.* properties
Allow persist.device_config.lmkd_native.* to override ro.lmk.*
properties to enable experiments with lmkd configuration properties.
Experiments will be able to set appropriate
persist.device_config.lmkd_native.<name> property which will issue
"lmkd --reinit" command to reinitialize lmkd with new parameters.

Bug: 194316048
Test: adb shell device_config put lmkd_native thrashing_limit_critical 350
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia48fd51eab126d307a1604530b642e86cf250688
2021-08-31 09:20:46 -07:00
Xin Li 597d5d2b61 Mark sc-dev-plus-aosp-without-vendor@7634622 as merged
Merged-In: I905d1733efec72c8e2745cff51cec0547ea57fea
Change-Id: If3648949cabbd47830dabc09b8c293d3c2ee274b
2021-08-14 06:04:15 +00:00
Suren Baghdasaryan 145613c986 lmkd: Add thrashing and max_thrashing into killinfo reports am: 39b54809fb
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1790959

Change-Id: Ia780dc3b3b96fdcbd48cb72dff62cf52d33c7a0d
2021-08-12 02:10:36 +00:00
Suren Baghdasaryan 39b54809fb lmkd: Add thrashing and max_thrashing into killinfo reports
Due to the increased importance of thrashing limits, include current and
max thrashing levels into killinfo reports.

Bug: 195979894
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I36f947e45e03a4d845d18881e137e4b242aacb65
2021-08-09 15:10:46 -07:00
George Burgess IV e4689257db lmkd: fix potential NULL pointer dereference am: e849f1414e am: 047e6e30e7
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1787727

Change-Id: I905d1733efec72c8e2745cff51cec0547ea57fea
2021-08-05 17:51:22 +00:00
George Burgess IV 047e6e30e7 lmkd: fix potential NULL pointer dereference am: e849f1414e
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1787727

Change-Id: I1b048df607f8503bcc93d68c44b061dfd148a2d2
2021-08-05 17:33:24 +00:00
George Burgess IV e849f1414e lmkd: fix potential NULL pointer dereference
`ki` appears to be potentially NULL. Output bogus values if it is.

Caught by the static analyzer:
> system/memory/lmkd/lmkd.cpp:2171:66: warning: Access to field
'kill_reason' results in a dereference of a null pointer (loaded from
variable 'ki') [clang-analyzer-core.NullDereference]

Bug: None
Test: TreeHugger
Change-Id: Iae26855528e1f7fec8f1455e06c7e813a732dc75
2021-08-05 06:59:42 +00:00
Suren Baghdasaryan dc2e03adf9 lmkd: Add a tracepoint for each kill with kill parameters am: 34928bb817 am: a2394fb247
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1782391

Change-Id: I80cdfcc2f323b16ea9f3518ac2b317be6c7b3f2a
2021-08-03 16:19:23 +00:00
Suren Baghdasaryan a2394fb247 lmkd: Add a tracepoint for each kill with kill parameters am: 34928bb817
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1782391

Change-Id: I805fa72d4784775bfc9c148a957417654a26d3c8
2021-08-03 16:04:54 +00:00
Suren Baghdasaryan 34928bb817 lmkd: Add a tracepoint for each kill with kill parameters
Add a trace for each kill that includes pid, kill reason, oom_adj_score,
min_oom_score and max_thrashing statistics at the time of the kill.

Bug: 195085238
Test: generate kills while tracing and observer the new tracepoints
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic2014adc08f5e5dd4aacd415970332618bd15250
2021-07-30 12:59:15 -07:00
Suren Baghdasaryan 6deecd4aa5 [automerger skipped] lmkd: Add current and max thrashing levels in LMK_MEMORY_STATS reports am: e16047516d am: 74c1874aa2 -s ours
am skip reason: Merged-In I8a34dc41e7f03668bfad4ac2cbcb5d2570a10752 with SHA-1 81bb801dd2 is already in history

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

Change-Id: I2831e9f8024f7809373cb2d3499c112f5f125c51
2021-07-26 18:18:39 +00:00
Suren Baghdasaryan ee01679a16 [automerger skipped] Revert "lmkd: Disable critical thrashing limit by default" am: 1ef4718aed am: ccd7f3f735 -s ours
am skip reason: Merged-In I15be5b3d67a71b68bca6dea9c2d5b4aa54d6c260 with SHA-1 dded82877f is already in history

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

Change-Id: I0fe9b16c095298e4b9836f5e5b06d813f57e7f22
2021-07-26 18:18:38 +00:00
Suren Baghdasaryan 74c1874aa2 lmkd: Add current and max thrashing levels in LMK_MEMORY_STATS reports am: e16047516d
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1776906

Change-Id: Idf1f7e4011c25bf645eda165cc0604ff324597a7
2021-07-26 18:03:10 +00:00
Suren Baghdasaryan ccd7f3f735 Revert "lmkd: Disable critical thrashing limit by default" am: 1ef4718aed
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1776905

Change-Id: I813228ae2107df1ee31a18ffae4853e01bcad5fd
2021-07-26 18:03:09 +00:00
Suren Baghdasaryan 559c0d11a8 lmkd: Add current and max thrashing levels in LMK_MEMORY_STATS reports am: 81bb801dd2
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15365195

Change-Id: If9fbee8fab4c2abf05ec288382deb9432f6ada6d
2021-07-23 21:42:14 +00:00
Suren Baghdasaryan e16047516d lmkd: Add current and max thrashing levels in LMK_MEMORY_STATS reports
Thrashing threshold tuning requires collecting thrashing level data from
the field and correlating these levels with other indications of device
being non-responsive.
Include current and max thrashing levels in the lmkd kill reports. Max
thrashing level captures the highest level seen since the last kill report.

Bug: 194433891
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I8a34dc41e7f03668bfad4ac2cbcb5d2570a10752
Merged-In: I8a34dc41e7f03668bfad4ac2cbcb5d2570a10752
2021-07-23 19:11:36 +00:00
Suren Baghdasaryan 1ef4718aed Revert "lmkd: Disable critical thrashing limit by default"
This reverts commit e1ffef4e36.

Reason for revert: Restore the default thrashing limits to prevent unresponsive devices.

Bug: 194199500
Change-Id: I15be5b3d67a71b68bca6dea9c2d5b4aa54d6c260
Merged-In: I15be5b3d67a71b68bca6dea9c2d5b4aa54d6c260
2021-07-23 12:01:55 -07:00
Suren Baghdasaryan 81bb801dd2 lmkd: Add current and max thrashing levels in LMK_MEMORY_STATS reports
Thrashing threshold tuning requires collecting thrashing level data from
the field and correlating these levels with other indications of device
being non-responsive.
Include current and max thrashing levels in the lmkd kill reports. Max
thrashing level captures the highest level seen since the last kill report.

Bug: 194433891
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I8a34dc41e7f03668bfad4ac2cbcb5d2570a10752
2021-07-22 16:51:46 -07:00
Suren Baghdasaryan d042af50d1 Revert "lmkd: Disable critical thrashing limit by default" am: dded82877f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15362664

Change-Id: I1bf0676d3bddbbb391da637931305a67bb38e46b
2021-07-22 23:14:16 +00:00
Suren Baghdasaryan dded82877f Revert "lmkd: Disable critical thrashing limit by default"
This reverts commit e1ffef4e36.

Reason for revert: Restore the default thrashing limits to prevent unresponsive devices.

Bug: 194199500
Change-Id: I15be5b3d67a71b68bca6dea9c2d5b4aa54d6c260
2021-07-22 21:01:14 +00:00
TreeHugger Robot 1cbd4a6ce4 [automerger skipped] Merge "lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark" into sc-dev am: 9d08f060ac -s ours
am skip reason: Merged-In I49ca4cd2f33b27fdbc432d9ce6944b1a1794b749 with SHA-1 11221d4062 is already in history

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

Change-Id: I449d797c0d420753d952bd8d28c20d53a3624278
2021-07-21 07:45:56 +00:00
TreeHugger Robot 9d08f060ac Merge "lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark" into sc-dev 2021-07-21 07:34:31 +00:00
Suren Baghdasaryan 05bf34f100 lmkd: Disable critical thrashing limit by default am: c1171394a3 am: 05a14bada0
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1773246

Change-Id: I9f326e632fbb8cda92b19f2b1cf91031fee5fc63
2021-07-20 21:28:33 +00:00
Suren Baghdasaryan 05a14bada0 lmkd: Disable critical thrashing limit by default am: c1171394a3
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1773246

Change-Id: I878ee527439b88c108d006feef6b491c6f8f5db3
2021-07-20 21:14:09 +00:00
Suren Baghdasaryan 1ef8e2f767 lmkd: Disable critical thrashing limit by default am: e1ffef4e36
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/memory/lmkd/+/15339915

Change-Id: I5614425c8b29377aae1fde3fa1e5dba910e85792
2021-07-20 19:35:27 +00:00
Suren Baghdasaryan c1171394a3 lmkd: Disable critical thrashing limit by default
Critical thrashing limit determines the balance between how much
thrashing should be tolerated before killing a perceptible app.
This threshold might differ between devices, therefore we disable
critical thrashing limit by default allowing each device to set it
individually. This is done to prevent excessive kills of perceptible
apps.

Bug: 194199500
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Idd1715564c3727b09fcb0a109ab3d6bae9d0b99a
2021-07-20 18:12:22 +00:00
Suren Baghdasaryan e1ffef4e36 lmkd: Disable critical thrashing limit by default
Critical thrashing limit determines the balance between how much
thrashing should be tolerated before killing a perceptible app.
This threshold might differ between devices, therefore we disable
critical thrashing limit by default allowing each device to set it
individually. This is done to prevent excessive kills of perceptible
apps.

Bug: 194199500
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Idd1715564c3727b09fcb0a109ab3d6bae9d0b99a
2021-07-20 18:06:43 +00:00
Suren Baghdasaryan 57f12d13ce lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark
We see many cases when device keeps thrashing despite lmkd kills. This
happens because killed processes do not free enough filecache to fit
the current workingset completely.
To prevent such cases, introduce ro.lmk.filecache_min_kb property to
specify min filecache size in KB that should be reached after thrashing
is detected. Lmkd will keep killing background processes until this
filecache size limit is satisfied.

Bug: 193293513
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I49ca4cd2f33b27fdbc432d9ce6944b1a1794b749
Merged-In: I49ca4cd2f33b27fdbc432d9ce6944b1a1794b749
2021-07-19 09:50:49 +00:00
Suren Baghdasaryan e499b231a5 lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark am: 11221d4062 am: 47fc8fc026
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1766838

Change-Id: I004c501da601d7e5020e921d85326f80a3d2ba29
2021-07-16 16:55:22 +00:00
Suren Baghdasaryan 47fc8fc026 lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark am: 11221d4062
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1766838

Change-Id: I7ba3f64ccf9bbe2a4125c563697b4c9498659f16
2021-07-16 16:39:35 +00:00
Suren Baghdasaryan 11221d4062 lmkd: Add ro.lmk.filecache_min_kb property for min filecache watermark
We see many cases when device keeps thrashing despite lmkd kills. This
happens because killed processes do not free enough filecache to fit
the current workingset completely.
To prevent such cases, introduce ro.lmk.filecache_min_kb property to
specify min filecache size in KB that should be reached after thrashing
is detected. Lmkd will keep killing background processes until this
filecache size limit is satisfied.

Bug: 193293513
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I49ca4cd2f33b27fdbc432d9ce6944b1a1794b749
2021-07-15 11:05:09 -07:00
Bill Yi 414187f3e7 [automerger skipped] Merge RQ3A.210705.001 to aosp-master - DO NOT MERGE am: af5221c0aa -s ours am: bb644e429d -s ours
am skip reason: Merged-In Ie5a50c392ef5124a0c2390c8d4f902808d672739 with SHA-1 4571e22641 is already in history

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

Change-Id: I2115de4b4c22260f0b89ef6fc65a5855a4d22889
2021-07-13 01:21:32 +00:00
Bill Yi bb644e429d [automerger skipped] Merge RQ3A.210705.001 to aosp-master - DO NOT MERGE am: af5221c0aa -s ours
am skip reason: Merged-In Ie5a50c392ef5124a0c2390c8d4f902808d672739 with SHA-1 4571e22641 is already in history

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

Change-Id: Ie6aa987914131dc840a522707f0492e88e2dfc1c
2021-07-13 01:02:57 +00:00
Bill Yi af5221c0aa Merge RQ3A.210705.001 to aosp-master - DO NOT MERGE
Merged-In: Ie5a50c392ef5124a0c2390c8d4f902808d672739
Merged-In: I89b3edde09dfcf35b8214fecbed18ce5092701cc
Merged-In: I89b3edde09dfcf35b8214fecbed18ce5092701cc
Change-Id: I25eccb8109695125480f0da0e136ab98dabfaa0d
2021-07-12 11:08:30 -07:00
Bill Yi f3a348d82f [automerger skipped] Merge RQ3A.210705.001 to stage-aosp-master - DO NOT MERGE am: 3e0118d834 -s ours
am skip reason: Merged-In I19b3c21e31e1ea4750e3e185474e82d0ed04f9a7 with SHA-1 ba6f7e4a74 is already in history

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

Change-Id: I5e671dd7acafbc61af958240b1109c8c354f17ed
2021-07-12 13:27:13 +00:00
Bill Yi 3e0118d834 Merge RQ3A.210705.001 to stage-aosp-master - DO NOT MERGE
Merged-In: I89b3edde09dfcf35b8214fecbed18ce5092701cc
Merged-In: I19b3c21e31e1ea4750e3e185474e82d0ed04f9a7
Change-Id: I9234fbd1f3434582615e56f662b76aa67a506d7d
2021-07-11 22:43:43 -07:00
Xin Li ba6f7e4a74 [automerger skipped] DO NOT MERGE - Mark RQ3A.210410.001 as merged am: 4571e22641 -s ours
am skip reason: Merged-In Ibd98f113f81a4f699b11dbc843a95ee2e2197c92 with SHA-1 e0d6203d39 is already in history

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

Change-Id: I19b3c21e31e1ea4750e3e185474e82d0ed04f9a7
2021-06-18 06:19:00 +00:00
Xin Li 4571e22641 DO NOT MERGE - Mark RQ3A.210410.001 as merged
Bug: 190855093
Merged-In: Ibd98f113f81a4f699b11dbc843a95ee2e2197c92
Change-Id: Ie5a50c392ef5124a0c2390c8d4f902808d672739
2021-06-17 22:43:30 -07:00
Suren Baghdasaryan 0e61541dfe [automerger skipped] lmkd: Include total GPU memory usage in killinfo reports am: a01f251ff2 -s ours
am skip reason: Merged-In Icc1ed8ab2593530fa293ff9c82f6c8dc400485f5 with SHA-1 940e7cf8bd is already in history

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

Change-Id: Ib66f41abf2b9057b66fc26c07fe33fa5567a9cd3
2021-06-16 20:42:47 +00:00