Commit Graph

1070 Commits

Author SHA1 Message Date
Suren Baghdasaryan 08bfa985d1 lmkd: Add meminfo logging after each kill for easy troubleshooting
While troubleshooting memory pressure related issues it's hard to get a
good view of the memory state when lmkd kill happens. Logging relevant
information from /proc/meminfo file that was used to make a kill decision
is very helpful for further analysis. To do this efficiently we are using
Android Logger event library functions and log the data used for kill
decision after the kill signal was issued.

Test: Run lmkd_unit_test and logcat -b events -v descriptive
Change-Id: Id5de41b9d91a04dd5d3eb9b85d4e1babe9755628
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-08-10 14:21:31 -07:00
Suren Baghdasaryan 6c60925290 [automerger skipped] Merge "lmkd: Skip memory.stat usage when per-app memcgs are not used" am: 1e0e1b44bd -s ours am: 42f5cfbd45 -s ours am: 6d066c9a4c -s ours
am: 297257295a  -s ours

Change-Id: I4b8a19e2cba6609ea691aa38f14ab9b602ea7b45
2018-08-08 19:48:48 -07:00
Suren Baghdasaryan b01837accd Merge "lmkd: Protect against buffer overflow" am: 41950dd414 am: 26beb5ca71 am: 904648c7dc
am: 47725e6afe

Change-Id: I1f4e363e6e09442f5d49ca59244c9d6afde7827e
2018-08-08 19:45:43 -07:00
Suren Baghdasaryan 456cdfd896 [automerger skipped] Merge "lmkd: Skip memory.stat usage when per-app memcgs are not used"
am: 1e0e1b44bd  -s ours

Change-Id: Ic2a13be530643b3b30c69587ec7dfbe76725474b
2018-08-08 11:38:50 -07:00
Vic Yang 65680690d7 lmkd: Do not downgrade/ignore events when swap is full
When the swap space is full, a pressure event is unlikely to resolve by
itself.  In this case, do not downgrade or ignore the events.

Bug: 112056451
Test: Fill up swap on a 1GB device and check critical vmpressure events
      are not downgraded.
Change-Id: If154dc364711bf7c86f32e24ddcd10be359386de
2018-08-08 10:00:06 -07:00
Suren Baghdasaryan 2f81a77326 lmkd: Skip memory.stat usage when per-app memcgs are not used
Initial change to remove memory.stat usage when per-application memcgs
are disabled was partially merged into AOSP under the following id:
Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
This change adds the missing parts.

Bug: 110384555
Change-Id: I1265021b1ede0e68efbf80d6430a959eaf46a69a
Merged-In: Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-08-08 01:18:38 +00:00
Greg Kaiser f5b1d14fa8 lmkd: Protect against buffer overflow
We're passing a 'line' whose backing buffer is PAGE_MAX in size
into memory_stat_parse_line().  We protect overflowing the smaller
LINE_MAX 'key' buffer via some C preprocessing macros to assure
we limit the size.

Test: Local build with LMKD_LOG_STATS set for this file.
Bug: 76220622
Change-Id: I9e50d4270f7099e37a9bfc7fb9b9b95cc7adb086
2018-08-07 15:42:19 -07:00
Suren Baghdasaryan e105afc6ba [automerger skipped] Merge "Enable lmkd kill tracing everywhere" am: e961bbcadc -s ours am: 5d95ac61d7 -s ours am: af1e0d7274 -s ours
am: d5b98ee1d7  -s ours

Change-Id: Ib2438e0f6bfa7c6350eeb00dd1c7987f544dc2cc
2018-08-03 11:18:38 -07:00
Suren Baghdasaryan 953a455938 [automerger skipped] Merge "Enable lmkd kill tracing everywhere"
am: e961bbcadc  -s ours

Change-Id: I8551e637d4aec87c75ff6079040d0cde1b8f248c
2018-08-03 10:58:06 -07:00
Suren Baghdasaryan 5a811c7e61 [automerger skipped] Merge "lmkd: Disable memory.stat usage when per-application memcgs are not used" am: 615745cead am: 9461708ec9 am: 768df3c344
am: 07a913046e  -s ours

Change-Id: I7f80d8ba552ad7554adcd205a15911d355eeb359
2018-08-03 09:27:45 -07:00
Suren Baghdasaryan 7dca058d60 Merge "lmkd: Disable memory.stat usage when per-application memcgs are not used"
am: 615745cead

Change-Id: I57f3142ed217d4f1b3edb526087076fc588354d7
2018-08-03 09:14:09 -07:00
Daniel Colascione 59e40dfd14 Enable lmkd kill tracing everywhere
Test: asdf
Exempt-From-Owner-Approval: vacation
Merged-In: If6af7df74d303466aac4a69cdfe558e9748f72b9
Change-Id: If6af7df74d303466aac4a69cdfe558e9748f72b9
2018-08-03 16:08:01 +00:00
Suren Baghdasaryan 8389fdbece lmkd: Disable memory.stat usage when per-application memcgs are not used
Per-application memory.stat files are not available when per-application
memcgs are not used (per_app_memcg=false). Disable its usage based on
ro.config.per_app_memcg property.

minchan:
* correct indentation of memory_stat_parse
* move per_app_memcg check into memory_stat_parse inside
* change low_ram_device to per_app_memcg

Bug: 110384555
Test: manual test to see lkmd log message with memory hogger
Merged-In: Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
Change-Id: Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
Signed-off-by: Minchan Kim <minchan@google.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-08-03 16:06:54 +00:00
Chih-Hung Hsieh afa129c112 Merge "Declare __fake_use_va_args as a variadic function." am: e352a75b90 am: 7585d2270e am: bc7f7e7311
am: 044942e5b8

Change-Id: I72571e509dcda07ce4f2e36639523e23f5752146
2018-07-25 16:56:27 -07:00
Chih-Hung Hsieh 77f64e0509 Merge "Declare __fake_use_va_args as a variadic function."
am: e352a75b90

Change-Id: I4cfeb23cab215741944485baa47450115ed671e0
2018-07-25 16:44:45 -07:00
Chih-Hung Hsieh 234a5a0350 Declare __fake_use_va_args as a variadic function.
* New clang compiler requires variadic function to have
  at least one named parameter type.
* Use ##__VA_ARGS__ to work with empty __VA_ARGS__.
* Fix one ALOG_ASSERT parameter bug in lmkd/lmkd.c.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I90f35aa88527a6897954f69a35b256a157a725c5
2018-07-25 14:36:35 -07:00
Suren Baghdasaryan 922b24b93c lmkd: Disable memory.stat usage when per-application memcgs are not used
Per-application memory.stat files are not available when per-application
memcgs are not used (per_app_memcg=false). Disable its usage based on
ro.config.per_app_memcg property.

minchan:
* correct indentation of memory_stat_parse
* move per_app_memcg check into memory_stat_parse inside
* change low_ram_device to per_app_memcg

Bug: 110384555
Test: manual test to see lkmd log message with memory hogger
Change-Id: Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
Signed-off-by: Minchan Kim <minchan@google.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-06-21 10:36:55 +09:00
Suren Baghdasaryan cfdfbfd064 [automerger skipped] Merge "lmkd: Do not set soft_limit_in_bytes on high-end devices" am: 827de19932 am: a7084943c9 -s ours
am: 3a77313c9f  -s ours

Change-Id: I3a9606c7a0d4292568aa0955042df26247b8cf57
2018-05-22 12:32:24 -07:00
Suren Baghdasaryan 2aa6bbb5d0 [automerger skipped] Merge "lmkd: Do not set soft_limit_in_bytes on high-end devices" am: 827de19932
am: a7084943c9  -s ours

Change-Id: Ibdc4154eca3340facc2702e749af3e540d0c05f8
2018-05-22 12:20:21 -07:00
Suren Baghdasaryan fe78b931fa lmkd: Do not set soft_limit_in_bytes on high-end devices
Setting memory.soft_limit_in_bytes on high-end devices with large memory
reserves affects performance of memory-hungry applications that have
large workingsets and keep thrashing because of the memory limits imposed.
Limit the usage of memory.soft_limit_in_bytes to low-memory devices only.
Add debug messages for future troubleshooting to capture cases when
vmpressure events are being ignored.

Bug: 78916015
Test: collect vmstat while running a heavy app
Change-Id: Ib4434b96d2be802ef89960b573486eae8d12f198
Merged-In: Ib4434b96d2be802ef89960b573486eae8d12f198
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-05-22 10:25:38 -07:00
android-build-team Robot f4a8a1aa26 Snap for 4796401 from 93d48fe0b6e891d785caefdc02065da58e749c69 to pi-release
Change-Id: I9d5a3d4d48b6944b00e032511151eb1a4a391d4b
2018-05-22 07:27:05 +00:00
Suren Baghdasaryan b3bddfa598 Merge "resolve merge conflicts of 20686f061eebddb7d49d9a061fc736dad0b96c93 to pi-dev-plus-aosp" into pi-dev-plus-aosp
am: bbda5b6092

Change-Id: I516dae0e97658f8c340d63f6bcc262734c8400bc
2018-05-21 22:07:21 -07:00
Suren Baghdasaryan bf919ff222 resolve merge conflicts of 20686f061eebddb7d49d9a061fc736dad0b96c93 to pi-dev-plus-aosp
BUG: None
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I02b5973366351604bf46df7ad4e2235b1dda014a
2018-05-21 19:48:47 -07:00
Suren Baghdasaryan b0bda55c12 lmkd: Do not set soft_limit_in_bytes on high-end devices
Setting memory.soft_limit_in_bytes on high-end devices with large memory
reserves affects performance of memory-hungry applications that have
large workingsets and keep thrashing because of the memory limits imposed.
Limit the usage of memory.soft_limit_in_bytes to low-memory devices only.
Add debug messages for future troubleshooting to capture cases when
vmpressure events are being ignored.

Bug: 78916015
Test: collect vmstat while running a heavy app
Change-Id: Ib4434b96d2be802ef89960b573486eae8d12f198
Merged-In: Ib4434b96d2be802ef89960b573486eae8d12f198
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-05-21 23:17:46 +00:00
Suren Baghdasaryan 4671c3d9c4 lmkd: Do not set soft_limit_in_bytes on high-end devices
Setting memory.soft_limit_in_bytes on high-end devices with large memory
reserves affects performance of memory-hungry applications that have
large workingsets and keep thrashing because of the memory limits imposed.
Limit the usage of memory.soft_limit_in_bytes to low-memory devices only.
Add debug messages for future troubleshooting to capture cases when
vmpressure events are being ignored.

Bug: 78916015
Test: collect vmstat while running a heavy app
Change-Id: Ib4434b96d2be802ef89960b573486eae8d12f198
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-05-21 14:42:15 -07:00
android-build-team Robot f73aab11e7 Snap for 4787078 from 7905b1e16286653679b7ff9b595f3ed7de5e182f to pi-release
Change-Id: Id0a5125ffd734a0b158ab867f8ffd9c0e0ae930a
2018-05-17 07:22:36 +00:00
Yang Lu 8c224cca69 Merge "Only log the lmkd state change when the killing really happened." into pi-dev am: 7905b1e162
am: 45695becc5

Change-Id: I63f288d064b896ae16908035f41fed3346154daa
2018-05-16 09:17:19 -07:00
Yang Lu caf318e0f7 Merge "Only log the lmkd state change when the killing really happened." into pi-dev
am: 7905b1e162

Change-Id: I2abda8ab40e766c882bdd8746bdf21bc222e7c50
2018-05-16 09:12:41 -07:00
Yang Lu 5dfffbc7a9 Only log the lmkd state change when the killing really happened.
BUG: b/78603347

Test: statsd test

Change-Id: I0345a47e1cd1c79a67103e401a2eb0a7fbe0631b
2018-05-15 16:54:45 +00:00
android-build-team Robot 786a5e0f4a Snap for 4781566 from 09b309807ff4cbf53545749dabbfe2838a1755ff to pi-release
Change-Id: I792bce225a67d61a24674a71b8db05bb9486aad7
2018-05-15 07:26:06 +00:00
Dan Willemsen 6e24015a96 Revert "Only log the lmkd state change when the killing really happened." am: 0051684905
am: 971f23bf66

Change-Id: Ia57c8d7e63c538442780fa20809c886a3af31941
2018-05-14 20:35:38 -07:00
Dan Willemsen fa4c1d7be3 Revert "Only log the lmkd state change when the killing really happened."
am: 0051684905

Change-Id: I3fc6842348d7ede95dd5fcdca06271d90c4facb4
2018-05-14 20:31:29 -07:00
Dan Willemsen 8ce604bd15 Revert "Only log the lmkd state change when the killing really happened."
This reverts commit 5e60f88cab8a22d88d76f7fd49f5a6e9cc0d931b.

Reason for revert: broke some builds

Bug: 78603347
Change-Id: I46bf6face35f5399d7d43146b360c0703eedfb1a
2018-05-15 03:26:05 +00:00
Yangster-mac 4052ab6cf5 Only log the lmkd state change when the killing really happened. am: 5e60f88cab
am: 6d709b77c6

Change-Id: I29f7ff85bf67c2784c8e1399423c5d9746da5d5a
2018-05-14 19:27:32 -07:00
Yangster-mac 6411512fb9 Only log the lmkd state change when the killing really happened.
am: 5e60f88cab

Change-Id: I95e347eeb0d69493a15ed11d32ca91d532eb043e
2018-05-14 19:22:33 -07:00
Yangster-mac 7154a883f2 Only log the lmkd state change when the killing really happened.
Test: statsd test
BUG: b/78603347
Change-Id: Ie08b0c3260f2f96b48e9e12c2c88208a3613042d
2018-05-14 22:25:29 +00:00
android-build-team Robot 7388e2ea02 Snap for 4778776 from da88b24c9787f8babf790c7fca93e129143b41fe to pi-release
Change-Id: I487f4e0e0b4505d3bd4f264b2f95174743107226
2018-05-13 07:26:59 +00:00
Suren Baghdasaryan dbf2878449 lmkd: Enable more logs during a kill am: da88b24c97
am: 740d940074

Change-Id: I7d62f4afd52ccc657c060cca3392ac116a2c8e67
2018-05-11 16:05:13 -07:00
Suren Baghdasaryan c51a9c1e7f lmkd: Enable more logs during a kill
am: da88b24c97

Change-Id: Ieb4ed09ac5224843ee8f7fb44494eb291054223d
2018-05-11 14:15:09 -07:00
Suren Baghdasaryan eff8233ce4 lmkd: Enable more logs during a kill
Logs that provide information about memory conditions during a process
kill event contain useful information and do not affect device
performance because these events are rare. Enabling them even when
ro.config.debug flag is not set will help in understanding low memory
conditions.

Bug: 79572814

Change-Id: Iae6e9bb612b9a7904ca491de3f1ddc727f24c7e0
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-05-11 21:03:14 +00:00
android-build-team Robot ece1fc9bde Snap for 4765094 from 35c76427a2918434c9d7b38d2e9a7710b67c94cf to pi-release
Change-Id: I13426caff58344bbf5013d18ceb46b721e9c3522
2018-05-06 07:23:14 +00:00
Yao Chen b67737a586 Fix the stats log in lmkd am: 389aee1117
am: 89c1ea6deb

Change-Id: I092f761249940703eb6388ba02a8d43f825ee519
2018-05-04 13:55:47 -07:00
Yao Chen daf5980e0a Fix the stats log in lmkd
am: 389aee1117

Change-Id: I533b09089280681a9c41a3597c62ec621a870839
2018-05-04 13:40:47 -07:00
Yao Chen 337606cc8b Fix the stats log in lmkd
1. let logs be written to statsd directly like all other stats logs.
   + stats log should not write to logd anymore(b/78239479)
2. fixed the log format
   + need to embed the elapsed real time in the log
3. fixed the log context reuse problem
   +reset the log context buffer and internal state before reuse

Bug: 78603347
Bug: 78239479

Test: tested with alloc_stress, and saw logs written to statsd

performance measurement (memory & cpu):
https://paste.googleplex.com/5508158646648832

Change-Id: I345f0eace8ba1687ff480fb88e9abba1d8533f76
2018-05-03 16:04:27 -07:00
android-build-team Robot f9639bf07f Snap for 4728508 from e58d713e47bc798a546c3d2a2c40e2339527133d to pi-release
Change-Id: I00aaa6f7baef271b8b0cd90ef78adca9a0656c39
2018-04-18 07:26:11 +00:00
Mark Salyzyn b53f40a494 Merge "lmkd: limit capability set to minimum" am: 01ce44b734 am: c2d4d08be2
am: 7977e3d24d

Change-Id: Ib640b564c87255aa07ff8ce20224fae364966438
2018-04-17 15:47:18 -07:00
Mark Salyzyn 7339c79cfd Merge "lmkd: limit capability set to minimum" am: 01ce44b734
am: c2d4d08be2

Change-Id: Ic97ab3c4312d260c2aa8c7a30e203564cd72f61a
2018-04-17 15:34:06 -07:00
Suren Baghdasaryan fa4e5dfeb1 [automerger skipped] Merge "lmkd: Introduce support for legacy kill algorithm that uses minfree levels" am: 22dc27b9fa am: 6575d86d3d -s ours
am: 109024fc1e  -s ours

Change-Id: I45ecb6d88bec0b42831fb31c3ee93f8894f70134
2018-04-17 12:19:50 -07:00
Suren Baghdasaryan 4a3210d759 [automerger skipped] Merge "lmkd: Switch to using /proc/meminfo to have access to file cache size" am: 5176b4b37a am: 4573186a35 -s ours
am: 078583a7d5  -s ours

Change-Id: Ieb2dce5f0f54522c25bffbd4657dbe56315044bf
2018-04-17 12:17:48 -07:00
Suren Baghdasaryan 81063f17a7 resolve merge conflicts of 885ff611d73db3ebf62dbbba5ec331836721bde1 to pi-dev-plus-aosp
am: 7bdfc321a8

Change-Id: I798862c015074a0ce1fd494e620618de3a949fc2
2018-04-17 12:14:36 -07:00