Commit Graph

1653 Commits

Author SHA1 Message Date
Suren Baghdasaryan 83df0088a3 lmkd: Implement pid purge command to clear old pids when zygote restarts
lmkd keeps a list of pids registered by ActivityManager, however on rare
occasions when framework restarts and lmkd survives that list has to be
purged. Implement a command that can be used to clear the pid list.

Bug: 116801366
Test: locally by killing zygote process
Change-Id: I71d6012f86bb83a73edd5b687e05a0848e0569b1
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-10-15 16:22:17 +00:00
Suren Baghdasaryan f405453c44 lmkd: Implement pid purge command to clear old pids when zygote restarts am: c89be17730
am: e6fcbe0719

Change-Id: I560e7076a24f4122a7a0c73890234ba9d8c05389
2018-10-12 16:48:13 -07:00
Suren Baghdasaryan a6573c818c lmkd: Implement pid purge command to clear old pids when zygote restarts
am: c89be17730

Change-Id: I11ebb0c22eedeaebd1c8f55ad5bec17abb82ba82
2018-10-12 16:43:03 -07:00
Suren Baghdasaryan 19e96c9c8f Merge "lmkd: Fix an invalid access to a pointer after it's freed" am: 1f149d8d2a am: 8950a02d10
am: 3503445f7f

Change-Id: Ia6fe0dcf6814e29be1faba15f1c0a5ae67a59a34
2018-10-12 14:52:33 -07:00
Suren Baghdasaryan 3134deab6b Merge "lmkd: Fix an invalid access to a pointer after it's freed" am: 1f149d8d2a
am: 8950a02d10

Change-Id: I87ec58231106933ef3cdcec50110c307bd2b3b83
2018-10-12 14:44:40 -07:00
Suren Baghdasaryan fd42ffb457 Merge "lmkd: Fix an invalid access to a pointer after it's freed"
am: 1f149d8d2a

Change-Id: I3bd979baf13d574b0f3f6eef1236512d9342640e
2018-10-12 14:39:28 -07:00
Rajeev Kumar d128423ee4 Read memory stats from /proc/pid/stat file.
(cherry pick from commit 0301683e49ab255769b15469487feaab3466167a)
Bug: 117333340
Test: Manual testing using alloc-stress tool
Change-Id: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
Merged-In: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
2018-10-12 21:28:50 +00:00
Srinivas Paladugu 4f3def3776 Merge "lmkd: increase the soft limit for keyboard" 2018-10-12 19:08:28 +00:00
Suren Baghdasaryan 8b00c6d79a lmkd: Fix an invalid access to a pointer after it's freed
pid_remove() frees a structure representing registered process and the
pointer can't be used anymore. This change fixes an instance when pointer
was used after it was freed. pid_remove() is moved to the end of the
function and comments are added to prevent similar situation in the future.

Bug: 117625315

Change-Id: I6a922952a31232497b3f9caf87d5a21bd402db94
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-10-12 11:28:33 -07:00
Rajeev Kumar 91ed713fc5 [automerger skipped] Merge "Read memory stats from /proc/pid/stat file." into stage-aosp-master am: ab0cfea162 -s ours
am: d3bb07c799  -s ours

Change-Id: I626fee42fab6060b9036ae815889b6fad38a708e
2018-10-12 11:02:33 -07:00
Rajeev Kumar 2cbeb781f6 [automerger skipped] Merge "Read memory stats from /proc/pid/stat file." into stage-aosp-master
am: ab0cfea162  -s ours

Change-Id: I08e70c57079b586c34317f262f8a02d3bc9876f7
2018-10-12 10:58:43 -07:00
Srinivas Paladugu 2770ab17b3 lmkd: increase the soft limit for keyboard
lmkd sets the soft limit parameters for Go devices.
The limit for apps in the perceptible group is set to 16M.
However this limit is not sufficient for the keyboard app to
prevent pages from being re-claimed quickly. The mem usage of
the keyboard app is around 55M most cases with some occasional
spikes to 70-80M. Increasing the limit to 64M improves the warm
startup latency for keyboard. It is still lower than the limits
set for foreground and visible apps.

Test: Go device (1G)
Bug: 117517805
Change-Id: Id50e49327cfd76126e41ef6503971845f29196af
2018-10-11 13:53:40 -07:00
Rajeev Kumar 2b07944e79 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: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
2018-10-10 18:20:10 -07:00
Rajeev Kumar 5c0163adea [automerger skipped] Merge "Read memory stats from /proc/pid/stat file." am: d936e628a3 -s ours am: e10165769e
am: ecc05e6e54  -s ours

Change-Id: Ie3f81c1fa27a92175ec6f8744e26003f90aa335e
2018-10-10 18:13:15 -07:00
Rajeev Kumar f46ba8edf1 [automerger skipped] Merge "Read memory stats from /proc/pid/stat file." am: d936e628a3 -s ours
am: e10165769e

Change-Id: Ie08d729a9944e72f0392f4b626e29cff31166b53
2018-10-10 18:03:58 -07:00
Rajeev Kumar 6a4ee28b85 [automerger skipped] Merge "Read memory stats from /proc/pid/stat file."
am: d936e628a3  -s ours

Change-Id: Ifcc16f31ad7dc9b9a6f7071dbbb5741fc96c064d
2018-10-10 17:50:52 -07:00
Rajeev Kumar 2534d2e54d 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: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
2018-10-10 22:23:25 +00:00
Suren Baghdasaryan 08df7871d3 lmkd: Implement pid purge command to clear old pids when zygote restarts
lmkd keeps a list of pids registered by ActivityManager, however on rare
occasions when framework restarts and lmkd survives that list has to be
purged. Implement a command that can be used to clear the pid list.

Bug: 116801366
Test: locally by killing zygote process
Change-Id: I71d6012f86bb83a73edd5b687e05a0848e0569b1
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-10-10 22:11:23 +00:00
Rajeev Kumar b9ee75e58d Read memory stats from /proc/pid/stat file.
Bug: 117333340
Test: Manual testing using alloc-stress tool
Change-Id: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
2018-10-10 12:42:12 -07:00
Suren Baghdasaryan 9bce389557 [automerger skipped] lmkd: rate-limit and cleanup failed kill reports am: d6cbf3f41d -s ours
am: e603f04e6b  -s ours

Change-Id: Ia701df3276517f59d1c91ffee2d9b55f4448f9f9
2018-09-12 16:34:27 -07:00
Suren Baghdasaryan 0421ee6865 [automerger skipped] lmkd: rate-limit and cleanup failed kill reports
am: d6cbf3f41d  -s ours

Change-Id: Ic59dd4599ce3d9aaf3715aa40a58e9088e68c4ad
2018-09-12 15:41:44 -07:00
Suren Baghdasaryan 16e959bc67 lmkd: rate-limit and cleanup failed kill reports
Excessive number of failed kill reports when lmkd can't find an eligible
process to kill or frees not enough memory pollutes logs and bugreports.
Cleanup kill reports to remove duplicate information and rate limit failed
kill attempts at 1 report per sec. The number of suppressed failed kills
will be reported in the next lmkd report.

Bug: 113864581
Test: Verified using lmkd_unit_test
Change-Id: I67fa1fec97613f136c7582115edcbc56b1503c9c
Merged-In: I67fa1fec97613f136c7582115edcbc56b1503c9c
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-09-07 18:27:17 -07:00
Suren Baghdasaryan d60ccbaa3a Merge "lmkd: rate-limit and cleanup failed kill reports" am: 83193c6c78 am: b6d606d06a
am: 18d0260406

Change-Id: Ieb8d80612d9cb74afd6f1dc4207e560e07c8d848
2018-09-06 13:25:31 -07:00
Suren Baghdasaryan ba497f0324 Merge "lmkd: rate-limit and cleanup failed kill reports"
am: 83193c6c78

Change-Id: I087c782727e8c83afe606e0c23b42aa2e048e11b
2018-09-06 12:33:33 -07:00
Suren Baghdasaryan 61750b2ecc Merge "lmkd: Introduce system property to get minfree and oom_adj levels" am: ca2d03ebdb am: 4ca5f5be67
am: 4121aea7ac

Change-Id: I31a515121b68b6f7f74a96aac9bf80c205cad989
2018-09-05 21:22:47 -07:00
Suren Baghdasaryan 53be36e6d8 lmkd: rate-limit and cleanup failed kill reports
Excessive number of failed kill reports when lmkd can't find an eligible
process to kill or frees not enough memory pollutes logs and bugreports.
Cleanup kill reports to remove duplicate information and rate limit failed
kill attempts at 1 report per sec. The number of suppressed failed kills
will be reported in the next lmkd report.

Bug: 113864581
Test: Verified using lmkd_unit_test
Change-Id: I67fa1fec97613f136c7582115edcbc56b1503c9c
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-09-06 01:59:49 +00:00
Suren Baghdasaryan 3e81b52bb8 Merge "lmkd: Introduce system property to get minfree and oom_adj levels"
am: ca2d03ebdb

Change-Id: I8cfbfb8ec49336820692d04af6efc8adae23820d
2018-09-05 17:08:24 -07:00
Suren Baghdasaryan 1ed0db1a19 lmkd: Introduce system property to get minfree and oom_adj levels
Introduce sys.lmk.minfree_levels system property to allow minfree level
reporting. The format for this property is:

<minfree 1>:<oom_adj 1>, <minfree 2>:<oom_adj 2>, ...

Max number of minfree levels is 6 and they are specified in the
increasing order. For example:

sys.lmk.minfree_levels=18432:0,23040:100,27648:200,32256:300,55296:900,80640:906

sys.lmk.minfree_levels updates are ratelimited to once per second in order
to prevent DoS attacks.

Bug: 111521182
Test: getprop sys.lmk.minfree_levels returns expected value
Change-Id: I80d75d6836650b12457d6a99ca88898535837a97
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-09-05 10:54:22 -07:00
Vic Yang 209abafe0a Merge "lmkd: Do not downgrade/ignore events when swap is full" am: c48943165d am: a79d8384f1
am: 92e2212af0

Change-Id: I9857648f0803ac7356fb6e4b1963f26998837655
2018-08-14 19:59:50 -07:00
Vic Yang 19a9c239ba Merge "lmkd: Do not downgrade/ignore events when swap is full"
am: c48943165d

Change-Id: Id9497112443f9a11cbf2368dd10019359c4fc3ee
2018-08-14 16:10:18 -07:00
Treehugger Robot ac26903b12 Merge "lmkd: Do not downgrade/ignore events when swap is full" 2018-08-14 21:31:56 +00:00
Suren Baghdasaryan 050eeec93f Merge "lmkd: Add meminfo logging after each kill for easy troubleshooting" am: 7bb1ae2d88 am: e645496ecd am: 4b7f5af6c2
am: bbbc0c5ede

Change-Id: I07c6a260fe2cd65d294bd92f560d0fe339ebb7d4
2018-08-10 19:48:32 -07:00
Suren Baghdasaryan dcc35528fc Merge "lmkd: Add meminfo logging after each kill for easy troubleshooting"
am: 7bb1ae2d88

Change-Id: Ie54654d0dd35b9549b017a7e2d10b80536e4a3af
2018-08-10 18:57:09 -07:00
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