summaryrefslogtreecommitdiffstats
path: root/lmkd
Commit message (Collapse)AuthorAgeFilesLines
* lmkd: use after freeMark Salyzyn2018-02-051-3/+3
| | | | | | | | | Remove a use-after free reference of procp->pid, using the already captured pid variable. Test: lmkd_unit_tests Bug: 33808187 Change-Id: I3f5f8dd9acab2e28c81465d6195b73ae47e0a3c4
* Add MCL_ONFAULT to mlockallDaniel Colascione2018-01-241-1/+10
| | | | | | | | | | | This way, we don't fault in the entirety of our DSOs immediately; instead, used pages are "sticky" in memory. Works only on kernel 4.4 and up: downlevel, we ignore the mlockall failure. Once we get statically-linked lmkd in better shape, we'll just switch to that. Change-Id: I07a75ee3bc1264a1db41635c2acf611fede99b91
* Pin lmkd for realDaniel Colascione2018-01-031-1/+3
| | | | | | | | | | | | | | | | | We pin lmkd in memory so that we don't take page faults (and thus requisition memory) while we're in the process of responding to a low-memory condition. mlockall(2) is the right primitive for this pinning. Previously, we used the MCL_FUTURE flag to mlockall: used this way, mlockall doesn't actually pin all pages in memory, since MCL_FUTURE affects only the default flags for future mappings and doesn't affect mapping already in existence at the time of the mlockall call --- like the lmkd executable itself. This patch adds the MCL_CURRENT flag, which also pins all pages already mapped. Test: code inspection Change-Id: I4563959367a2f0a9cadc3ea41731b7f311326685
* Merge "Add lmkd/OWNERS."Elliott Hughes2017-12-091-0/+1
|\
| * Add lmkd/OWNERS.Elliott Hughes2017-12-081-0/+1
| | | | | | | | | | | | Bug: N/A Test: N/A Change-Id: Ic4970a95d799c16ffe06bc94a85adabc18d6cc0b
* | Simplify lmkd functionalityRobert Benea2017-09-171-5/+4
| | | | | | | | | | | | | | | | Get min adj score when needed, instead to propagate from caller funct. Bug:65642829 Test: tested on gobo_512 Change-Id: I87f15c5c6206d471002828a24d0462b0abb0d196
* | Downgrade memory pressure eventsRobert Benea2017-09-141-9/+30
| | | | | | | | | | | | | | | | | | If the system has enough memory the pressure events are ignored or downgraded from critical to medium. Bug: 65642829 Test: tested on gobo Change-Id: I44e66d2e35508aceee5c1719313db217b80d582e
* | Allow ANDROID_LOW_MEMORY_KILLER to coexist with lmkdRobert Benea2017-09-111-4/+8
| | | | | | | | | | | | | | | | | | | | For Go devices fallback to memcg/memory pressure events for LMK. Go devices will use memcg pressure events while inkernel module is disabled. Bug: 64852905 Test: tested on gobo Change-Id: I267ab00be85e324331f6c91551ba013184de817e
* | Detect critical preassureRobert Benea2017-08-251-2/+50
| | | | | | | | | | | | | | | | | | | | | | When close to oom the system tend to become very thrashy and keeps paging. This change looks at the current working sent and checks it against swap. Test: tested on gobo Bug: 64721547 Change-Id: I93d42def93cbc03a01a54988fd5286ec9f124e36
* | Improvements to lmkdRobert Benea2017-08-111-18/+17
| | | | | | | | | | | | | | | | | | | | | | - Don't show misleading messages, add the correct description for the reason of process killing - Don't kill Launcher3 upgrade the score to perceptible (200) - Limit the verbose logging Test: tested on gobo Bug: 64316273 Change-Id: Ic7c13853d939afe4f20cdaa5b488b6e1810f5ddf
* | Make lmkd memory pressure levels configurable.Robert Benea2017-08-021-1/+8
| | | | | | | | | | | | | | | | | | | | | | By doing so different platforms can customize them accordingly. For instance a low mem, 512MB device can do ro.lmk.medium=400, while a device with more memory can keep the default(800). Test: tested on gobo. Bug: 64316084 Change-Id: Ifc4f3853bc06f30488adb25883ccd9aaf683ba9b
* | Make lmkd use medium/critical mem pressure, and update soft limit based on ↵Robert Benea2017-06-141-52/+68
|/ | | | | | | | | | adj score. Test: GO device (512MB/1GB), both show improvements under heavy load. Bug: 62626918 Change-Id: I98afc8b1171db5b57056bc05d1f1ae9c5eed8506
* lmkd: Android.mk -> Android.bpSteven Moreland2017-04-282-12/+13
| | | | | Test: links Change-Id: I19aa62270488af02d64830ca90faf80b35423009
* liblog: use log/log.h when utilizing ALOG macrosMark Salyzyn2017-01-111-1/+1
| | | | | | Test: compile Bug: 30465923 Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
* system/core: preparation to pull back interfaces from android/log.hMark Salyzyn2016-10-201-0/+1
| | | | | | | | | | | | | | | | Point to log/log.h where necessary, define LOG_TAG where necessary. Accept that private/android_logger.h is suitable replacement for log/logger.h and android/log.h. Correct liblog/README Effectively a cleanup and controlled select revert of 'system/core: drop or replace log/logger.h' and 'system/core: Replace log/log.h with android/log.h'. Test: compile Bug: 30465923 Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
* system/core Replace log/log.h with android/log.hMark Salyzyn2016-09-301-1/+1
| | | | | | | | | | | Should use android/log.h instead of log/log.h as a good example to all others. Adjust header order to comply with Android Coding standards. Test: Compile Bug: 26552300 Bug: 31289077 Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
* Move android_get_control_socket out of lineColin Cross2016-09-231-1/+1
| | | | | | | | | | | | android_get_control_socket has a warning from the implicit cast from long to int. The warning was being hidden because cutils/sockets.h was included with -isystem. Move android_get_control_socket to sockets.cpp, since we don't want header only dependencies anyways, and fix the warning with a range check and a static_cast. Bug: 31492149 Test: m -j <module that uses sockets.h and -Wall> Change-Id: I1f394ab26d4ec8a7dd0e7907c10416d7f8647624
* Merge "Most accept/accept4 calls in system/core don't actually want the ↵Elliott Hughes2016-08-231-5/+1
|\ | | | | | | | | | | | | | | remote address." am: 299d64144b Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
| * Most accept/accept4 calls in system/core don't actually want the remote address.Elliott Hughes2016-08-231-5/+1
| | | | | | | | | | | | | | So don't write the extra code for it or waste the kernel's time copying it around. Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
* | resolve merge conflicts of 3252d11 to nyc-dev-plus-aospChih-Hung Hsieh2016-05-191-1/+1
|\| | | | | | | Change-Id: I2973439a194a3048d009159d75572a5366021f21
| * Fix misc-macro-parentheses warnings in lmkd.Chih-Hung Hsieh2016-05-181-1/+1
| | | | | | | | | | Bug: 28705665 Change-Id: I43388c0f9fdc8c2a0c0f4495f96bbc27e3de8a1d
* | lmkd: subscribe to low mempressure events.Martijn Coenen2016-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This will make sure we get invoked in time, and combined with a kernel change to increase the window size (and thus rate-limit the notifications) based on the amount of memory on the device, this should provide a nice balance between receiving too many notifications vs getting notified too late. Change-Id: I2f5e92390b94e582aaa06d88763a232e39673496
* | Merge "more O_CLOEXEC" am: 920d637d25Nick Kralevich2015-12-181-7/+7
|\| | | | | | | | | | | | | am: 890cd99709 * commit '890cd997098795b7a58c1d56c49c23895da7b4f9': more O_CLOEXEC
| * more O_CLOEXECNick Kralevich2015-12-181-7/+7
| | | | | | | | Change-Id: I330aef8d6f1fc35d6649995ef312954b84dff555
* | Merge "Switch from using sockaddr to sockaddr_storage." am: 46b0b1c694 am: ↵Erik Kline2015-12-081-3/+4
|\| | | | | | | | | | | | | | | | | 4c1b3840f0 am: cbc6f68e32 * commit 'cbc6f68e320bd30d0cd7fbe73847deacbd54e073': Switch from using sockaddr to sockaddr_storage.
| * Switch from using sockaddr to sockaddr_storage.Erik Kline2015-12-071-3/+4
| | | | | | | | | | | | This is to ensure sufficient space is always available. Change-Id: Ifa87b93ecdc90dcacbfb24446c872344da6703d3
* | Merge "Enable hidepid=2 on /proc" am: 2d8f1d4c47 am: ea8452cc72Nick Kralevich2015-11-091-0/+1
|\| | | | | | | | | | | | | am: 7dafe5b818 * commit '7dafe5b818f7771cb00c4a0ea3ab1dbf74593185': Enable hidepid=2 on /proc
| * Enable hidepid=2 on /procNick Kralevich2015-11-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the following mount options to the /proc filesystem: hidepid=2,gid=3009 This change blocks /proc access unless you're in group 3009 (aka AID_READPROC). Please see https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt for documentation on the hidepid option. hidepid=2 is preferred over hidepid=1 since it leaks less information and doesn't generate SELinux ptrace denials when trying to access /proc without being in the proper group. Add AID_READPROC to processes which need to access /proc entries for other UIDs. Bug: 23310674 Change-Id: I22bb55ff7b80ff722945e224845215196f09dafa
* | lmkd: allow client to use oom score in [-1000, 1000]Chong Zhang2015-10-191-22/+9
|/ | | | | | bug: 21411311 Change-Id: I20ddd1b30881712d03b5f85f270e1b56661fdfd1
* resolved conflicts for 5caca3dd to mnc-dr-dev-plus-aospTom Cherry2015-09-211-0/+1
|\ | | | | | | Change-Id: I773e514a8232b77cdd566dc36c9efc4e15f206f0
* | bundle init.rc contents with its serviceTom Cherry2015-08-212-0/+6
|/ | | | | Bug: 23186545 Change-Id: I52616b8ab1165fdef716f9b8f958665f2308c12e
* Lmkd: Fix unused variablesAndreas Gampe2014-11-241-2/+0
| | | | | | For build-system CFLAGS clean-up, fix unused variables. Change-Id: I841192e92585814b8691d544cc48433b2ca1b3d3
* lmkd: kill a process if zoneinfo can't be readColin Cross2014-07-141-2/+4
| | | | | | | | Opening /proc/zoneinfo may return -ENOMEM under memory pressure, assume something needs to be killed if that happens. Bug: 16236289 Change-Id: I25aab09f4c3f2b9e176eaaeca94fd6bd790dad4e
* lmkd: kill multiple tasksColin Cross2014-07-141-53/+88
| | | | | | | | | The task selected to die may be small, add its approximate size to other_free and other_file and keep killing until all thresholds are met. Bug: 16236289 Change-Id: Iceeca4c63fec98cae2bf53e258f7707cea408b07
* lmkd: use open instead of fopenColin Cross2014-07-141-27/+61
| | | | | | | | fopen and fgets require allocations, switch to open/read with stack allocated buffers. Bug: 16236289 Change-Id: I10586883fe78caf59d309eff7f7989b3e45beb7d
* lmkd: make lmkd SCHED_FIFOColin Cross2014-07-141-0/+5
| | | | | | | | | If kswapd runs more than lmkd it may throw away all page cache pages before lmkd gets a chance to kill a process. Make lmkd SCHED_FIFO so it can react quickly to kernel low memory notifications. Bug: 16236289 Change-Id: I46767b4ec81ef8638d0c9e47d168a68b62e3cac5
* lmkd: mlock all memoryColin Cross2014-07-141-0/+2
| | | | | | | | | | | Use mlockall(MCL_FUTURE) to lock all lmkd pages in memory. This avoids lmkd thrashing when the system is low on memory. As a side effect, it will also keep the .text sections of liblog, libm, libc, and libprocessgroup in memory at all times. Bug: 16236289 Change-Id: Idd70557efa4b1e14bc86f14220672a30f6c956e3
* lmkd: remove libcutils from LOCAL_SHARED_LIBRARIESColin Cross2014-07-141-1/+1
| | | | | | | | | While lmkd does technically use libcutils' socket.h, it only uses a static inline. Remove libcutils from LOCAL_SHARED_LIBRARIES so it doesn't end up mlock'd in memory in the next patch. Bug: 16236289 Change-Id: I744d69bfff06cb904836f64e1d5f6e530604bff4
* lmkd: use libprocessgroup to kill forked processesColin Cross2014-07-092-1/+3
| | | | | | | | After sending sigkill to the main process, also call into libprocessgroup to kill any processes that were forked. Bug: 15313911 Change-Id: I05577c6f5b70800ce0a01f480c8870c2c601afda
* lmkd: pass uid from ActivityManager to lmkdColin Cross2014-07-091-5/+8
| | | | | | | lmkd will use the uid to find processgroups and kill forked processes. Bug: 15313911 Change-Id: I3f7bb003ccf15650cae6ebc2c042ddeb4cc796fc
* Make lmkd dynamically linkedNick Kralevich2014-05-071-2/+1
| | | | | | | | | | | | Statically linked binaries cannot take advantage of ASLR, making them less secure. In addition, statically linked binaries consume more ram, because shared libraries cannot be reused. executable size before: 87728 executable size after: 13656 Change-Id: I9d02d865f9beeaaaadcd5009f64ac015931d4b11
* lmkd: turn on -WerrorMark Salyzyn2014-05-072-10/+14
| | | | | | - Deal with some -Wunused issues Change-Id: Id037c44a0ca2d00ae10a939fb001bc24a3e9410c
* low memory killer: switch to kernel oom_score_adj interfaceTodd Poynor2013-09-231-2/+14
| | | | | | | Use oom_score_adj for setting OOM score adjustment values instead of the older, deprecated oom_adj interface. Change-Id: I5ba7801d4b8971be092b31ae0fd8af8c3001d613
* Add lmkd low memory killer daemonTodd Poynor2013-08-302-0/+745
Move kernel low memory killer logic to new daemon lmkd. ActivityManager communicates with this daemon over a named socket. Change-Id: Ie957da7e9b1f7150e23c689fdadf23ff260b47be