summaryrefslogtreecommitdiffstats
path: root/lmkd
Commit message (Collapse)AuthorAgeFilesLines
* lmkd: use ALOGE for logging killsTim Murray2019-05-301-2/+2
| | | | | | | | | Test: boots, works Bug: 133761317 Signed-off-by: Tim Murray <timmurray@google.com> Exempt-From-Owner-Approval: trivial change Change-Id: I1a4a3741694078eec124f1f560ea68e78754bca6
* lmkd: set PSI_POLL_PERIOD to 10msSuren Baghdasaryan2019-03-271-1/+1
| | | | | | | | | | | | 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>
* lmkd: Fix meminfo logs missing SwapTotal and having wrong field orderSuren Baghdasaryan2019-03-251-1/+1
| | | | | | | | | | | | | | 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>
* lmkd: set PSI_POLL_PERIOD to 40msTim Murray2019-03-131-1/+1
| | | | | | | | | | 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>
* Add min_score_adj into LmkKillOccurred eventSuren Baghdasaryan2019-03-053-6/+17
| | | | | | | | | 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>
* lmkd: Remove redundant free swap and free memory checkJuju Sung2019-02-191-10/+0
| | | | | | | | 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
* Make inlines staticPirama Arumuga Nainar2019-02-061-20/+17
| | | | | | | | | | | | 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
* lmdk: Remove redundant 'if' checkGreg Kaiser2019-02-041-5/+3
| | | | | | | | | 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
* lmkd: Add support for psi monitorsSuren Baghdasaryan2019-02-012-14/+140
| | | | | | | | | | | | | | | | | | 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>
* libpsi: initial revisionTim Murray2019-01-304-0/+190
| | | | | | | | | | 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>
* DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for ↵Suren Baghdasaryan2019-01-251-0/+1
| | | | | | | | | | | 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>
* DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy ↵Suren Baghdasaryan2019-01-231-1/+0
| | | | | | | | | | | users" This reverts commit 02843339f998f05c712549658c9f8f8bc14ff57d. Reason for revert: Broke AOSP Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf Signed-off-by: Suren Baghdasaryan <surenb@google.com>
* Add dependencies on libprocessgroup for sched_policy usersSuren Baghdasaryan2019-01-221-0/+1
| | | | | | | | | | | | | | 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>
* Merge "lmkd: bump process priority and set to FOREGROUND group before kill"Wei Wang2019-01-161-0/+43
|\
| * lmkd: bump process priority and set to FOREGROUND group before killWei Wang2019-01-151-0/+43
| | | | | | | | | | | | | | | | This should help speed up reclaim memory. Bug: 118468011 Test: run mem-pressure with lmkd Change-Id: Iae7aa35483eb0e8bbeccaa425559c6021c845ee1
* | lmkd: add missing libcutils library to testTom Cherry2019-01-151-0/+1
|/ | | | | | | | | | 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
* Add start time to LmkKillOccurredJim Blackler2019-01-043-8/+14
| | | | | | | | | | | 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)
* lmkd: Cleanup unused code for killing processes in bulkSuren Baghdasaryan2018-10-291-33/+16
| | | | | | | | find_and_kill_processes() does not kill multiple processes at a time anymore. Remove support for bulk process killing. Change-Id: Id09132a9cebe44589a1a3ebcbff800a16fa56557 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
* lmkd: retune rate at which processes are killedTim Murray2018-10-291-6/+30
| | | | | | | | | Kill a single process at a time and try to wait up to 100ms for that process to reclaim memory before triggering another kill. Test: boots, works bug: 116877958 Change-Id: I6775d0534b3e3728c04389d3eae1a00e3cbf9f27
* lmkd: Add command to get number of killsSuren Baghdasaryan2018-10-242-1/+141
| | | | | | | | | | Intrduce LMK_GETKILLCNT command for ActivityManager to get the number of kills from lmkd. Bug: 117126077 Test: used lmkd_unit_test to verify correct reporting Change-Id: I09c720a7176b4df95efc544177cd2694f8d791be Signed-off-by: Suren Baghdasaryan <surenb@google.com>
* lmkd: increase the soft limit for keyboardSrinivas Paladugu2018-10-161-1/+1
| | | | | | | | | | | | | | | | 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 Merged-In: Id50e49327cfd76126e41ef6503971845f29196af Change-Id: Id50e49327cfd76126e41ef6503971845f29196af
* lmkd: Implement pid purge command to clear old pids when zygote restartsSuren Baghdasaryan2018-10-152-0/+40
| | | | | | | | | | | 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>
* lmkd: Fix an invalid access to a pointer after it's freedSuren Baghdasaryan2018-10-121-8/+16
| | | | | | | | | | | | 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>
* Read memory stats from /proc/pid/stat file.Rajeev Kumar2018-10-102-11/+51
| | | | | | | | (cherry pick from commit 0301683e49ab255769b15469487feaab3466167a) Bug: 117333340 Test: Manual testing using alloc-stress tool Merged-In: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd Change-Id: Ie555933aafa6a6b7aa1dbf5518ebe804376e0afd
* lmkd: rate-limit and cleanup failed kill reportsSuren Baghdasaryan2018-09-062-37/+46
| | | | | | | | | | | | | 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>
* lmkd: Introduce system property to get minfree and oom_adj levelsSuren Baghdasaryan2018-09-051-17/+65
| | | | | | | | | | | | | | | | | | | | 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>
* Merge "lmkd: Do not downgrade/ignore events when swap is full"Treehugger Robot2018-08-141-13/+23
|\
| * lmkd: Do not downgrade/ignore events when swap is fullVic Yang2018-08-081-13/+23
| | | | | | | | | | | | | | | | | | | | 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
* | lmkd: Add meminfo logging after each kill for easy troubleshootingSuren Baghdasaryan2018-08-103-3/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lmkd: Skip memory.stat usage when per-app memcgs are not usedSuren Baghdasaryan2018-08-081-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lmkd: Protect against buffer overflowGreg Kaiser2018-08-071-2/+5
|/ | | | | | | | | | | 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
* Merge "lmkd: Disable memory.stat usage when per-application memcgs are not used"Suren Baghdasaryan2018-08-031-1/+4
|\ | | | | | | | | | | am: 615745cead Change-Id: I57f3142ed217d4f1b3edb526087076fc588354d7
| * lmkd: Disable memory.stat usage when per-application memcgs are not usedSuren Baghdasaryan2018-08-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge "Declare __fake_use_va_args as a variadic function."Chih-Hung Hsieh2018-07-251-1/+1
|\| | | | | | | | | | | am: e352a75b90 Change-Id: I4cfeb23cab215741944485baa47450115ed671e0
| * Declare __fake_use_va_args as a variadic function.Chih-Hung Hsieh2018-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | * 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
| * lmkd: Do not set soft_limit_in_bytes on high-end devicesSuren Baghdasaryan2018-05-221-39/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | resolve merge conflicts of 20686f061eebddb7d49d9a061fc736dad0b96c93 to ↵Suren Baghdasaryan2018-05-211-39/+49
|\ \ | | | | | | | | | | | | | | | | | | | | | pi-dev-plus-aosp BUG: None Test: I solemnly swear I tested this conflict resolution. Change-Id: I02b5973366351604bf46df7ad4e2235b1dda014a
| * | lmkd: Do not set soft_limit_in_bytes on high-end devicesSuren Baghdasaryan2018-05-211-31/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge "Only log the lmkd state change when the killing really happened." ↵Yang Lu2018-05-161-5/+11
|\| | | | | | | | | | | | | | | | | | | | | | | into pi-dev am: 7905b1e162 Change-Id: I2abda8ab40e766c882bdd8746bdf21bc222e7c50
| * | Only log the lmkd state change when the killing really happened.Yang Lu2018-05-151-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | BUG: b/78603347 Test: statsd test Change-Id: I0345a47e1cd1c79a67103e401a2eb0a7fbe0631b
* | | Revert "Only log the lmkd state change when the killing really happened."Dan Willemsen2018-05-141-10/+5
|\| | | | | | | | | | | | | | | | | am: 0051684905 Change-Id: I3fc6842348d7ede95dd5fcdca06271d90c4facb4
| * | Revert "Only log the lmkd state change when the killing really happened."Dan Willemsen2018-05-151-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5e60f88cab8a22d88d76f7fd49f5a6e9cc0d931b. Reason for revert: broke some builds Bug: 78603347 Change-Id: I46bf6face35f5399d7d43146b360c0703eedfb1a
* | | Only log the lmkd state change when the killing really happened.Yangster-mac2018-05-141-5/+10
|\| | | | | | | | | | | | | | | | | am: 5e60f88cab Change-Id: I95e347eeb0d69493a15ed11d32ca91d532eb043e
| * | Only log the lmkd state change when the killing really happened.Yangster-mac2018-05-141-5/+10
| | | | | | | | | | | | | | | | | | Test: statsd test BUG: b/78603347 Change-Id: Ie08b0c3260f2f96b48e9e12c2c88208a3613042d
* | | lmkd: Enable more logs during a killSuren Baghdasaryan2018-05-111-18/+15
|\| | | | | | | | | | | | | | | | | am: da88b24c97 Change-Id: Ieb4ed09ac5224843ee8f7fb44494eb291054223d
| * | lmkd: Enable more logs during a killSuren Baghdasaryan2018-05-111-18/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Fix the stats log in lmkdYao Chen2018-05-044-8/+27
|\| | | | | | | | | | | | | | | | | am: 389aee1117 Change-Id: I533b09089280681a9c41a3597c62ec621a870839
| * | Fix the stats log in lmkdYao Chen2018-05-034-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "lmkd: limit capability set to minimum" am: 01ce44b734Mark Salyzyn2018-04-172-4/+17
|\ \ \ | | |/ | |/| | | | | | | | | | am: c2d4d08be2 Change-Id: Ic97ab3c4312d260c2aa8c7a30e203564cd72f61a
| * | lmkd: limit capability set to minimumMark Salyzyn2018-04-162-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set F() capability set and 'drop' lmkd from AID_ROOT to AID_LMKD uid and from AID_ROOT to AID_LMKD and AID_SYSTEM gid. /dev/memcg/memory.pressure defaults to root.root mode 0000, set it up as root.system mode 0040 to allow lmkd read access. Instrument failure to set SCHED_FIFO. Annotate access points that require elevated capabilities. Test: check /proc/`pidof lmkd`/status for capability set Test: lmkd_unit_test Bug: 77650566 Change-Id: I986081a0434cf6e842b63a55726380205b30a3ea