diff options
author | Suren Baghdasaryan <surenb@google.com> | 2018-05-18 14:42:00 -0700 |
---|---|---|
committer | Suren Baghdasaryan <surenb@google.com> | 2018-05-21 23:17:46 +0000 |
commit | 20686f061eebddb7d49d9a061fc736dad0b96c93 (patch) | |
tree | b0abfa98196ccf3cb4b72500e565c7bac79e81ba | |
parent | 34de3c84feeda18880d25ba4e58536b7416eae1f (diff) | |
download | core-20686f061eebddb7d49d9a061fc736dad0b96c93.tar.gz |
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>
-rw-r--r-- | lmkd/lmkd.c | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index 76344b98a..cc5a7c2cf 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c @@ -459,39 +459,41 @@ static void cmd_procprio(LMKD_CTRL_PACKET packet) { if (use_inkernel_interface) return; - if (params.oomadj >= 900) { - soft_limit_mult = 0; - } else if (params.oomadj >= 800) { - soft_limit_mult = 0; - } else if (params.oomadj >= 700) { - soft_limit_mult = 0; - } else if (params.oomadj >= 600) { - // Launcher should be perceptible, don't kill it. - params.oomadj = 200; - soft_limit_mult = 1; - } else if (params.oomadj >= 500) { - soft_limit_mult = 0; - } else if (params.oomadj >= 400) { - soft_limit_mult = 0; - } else if (params.oomadj >= 300) { - soft_limit_mult = 1; - } else if (params.oomadj >= 200) { - soft_limit_mult = 2; - } else if (params.oomadj >= 100) { - soft_limit_mult = 10; - } else if (params.oomadj >= 0) { - soft_limit_mult = 20; - } else { - // Persistent processes will have a large - // soft limit 512MB. - soft_limit_mult = 64; - } + if (low_ram_device) { + if (params.oomadj >= 900) { + soft_limit_mult = 0; + } else if (params.oomadj >= 800) { + soft_limit_mult = 0; + } else if (params.oomadj >= 700) { + soft_limit_mult = 0; + } else if (params.oomadj >= 600) { + // Launcher should be perceptible, don't kill it. + params.oomadj = 200; + soft_limit_mult = 1; + } else if (params.oomadj >= 500) { + soft_limit_mult = 0; + } else if (params.oomadj >= 400) { + soft_limit_mult = 0; + } else if (params.oomadj >= 300) { + soft_limit_mult = 1; + } else if (params.oomadj >= 200) { + soft_limit_mult = 2; + } else if (params.oomadj >= 100) { + soft_limit_mult = 10; + } else if (params.oomadj >= 0) { + soft_limit_mult = 20; + } else { + // Persistent processes will have a large + // soft limit 512MB. + soft_limit_mult = 64; + } - snprintf(path, sizeof(path), + snprintf(path, sizeof(path), "/dev/memcg/apps/uid_%d/pid_%d/memory.soft_limit_in_bytes", params.uid, params.pid); - snprintf(val, sizeof(val), "%d", soft_limit_mult * EIGHT_MEGA); - writefilestring(path, val); + snprintf(val, sizeof(val), "%d", soft_limit_mult * EIGHT_MEGA); + writefilestring(path, val); + } procp = pid_lookup(params.pid); if (!procp) { @@ -1214,8 +1216,15 @@ static void mp_event_common(int data, uint32_t events __unused) { } } - if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) + if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) { + if (debug_process_killing) { + ALOGI("Ignore %s memory pressure event " + "(free memory=%ldkB, cache=%ldkB, limit=%ldkB)", + level_name[level], other_free * page_k, other_file * page_k, + (long)lowmem_minfree[lowmem_targets_size - 1] * page_k); + } return; + } /* Free up enough pages to push over the highest minfree level */ pages_to_free = lowmem_minfree[lowmem_targets_size - 1] - |