diff options
author | Daniel Colascione <dancol@google.com> | 2018-01-03 12:01:02 -0800 |
---|---|---|
committer | Daniel Colascione <dancol@google.com> | 2018-01-03 12:32:14 -0800 |
commit | 4dd5d00eccd8a70862f9129601ebe1e0e1bebcc3 (patch) | |
tree | 100c03a29f612370eac6f0f90c1ca160e7d1ed2d /lmkd/lmkd.c | |
parent | 93d344d98cd02d66c3aac8067718be828ea283f9 (diff) | |
download | core-4dd5d00eccd8a70862f9129601ebe1e0e1bebcc3.tar.gz core-4dd5d00eccd8a70862f9129601ebe1e0e1bebcc3.tar.bz2 core-4dd5d00eccd8a70862f9129601ebe1e0e1bebcc3.zip |
Pin lmkd for real
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
Diffstat (limited to 'lmkd/lmkd.c')
-rw-r--r-- | lmkd/lmkd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index 5cfa2c887..fd83ecc28 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c @@ -900,7 +900,9 @@ int main(int argc __unused, char **argv __unused) { downgrade_pressure = (int64_t)property_get_int32("ro.lmk.downgrade_pressure", 60); is_go_device = property_get_bool("ro.config.low_ram", false); - mlockall(MCL_FUTURE); + if (mlockall(MCL_CURRENT | MCL_FUTURE)) + ALOGW("mlockall failed: errno=%d", errno); + sched_setscheduler(0, SCHED_FIFO, ¶m); if (!init()) mainloop(); |