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 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
8c224cca69
commit
4671c3d9c4
90
lmkd.c
90
lmkd.c
|
|
@ -484,47 +484,50 @@ static void cmd_procprio(LMKD_CTRL_PACKET packet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.oomadj >= 900) {
|
if (low_ram_device) {
|
||||||
soft_limit_mult = 0;
|
if (params.oomadj >= 900) {
|
||||||
} else if (params.oomadj >= 800) {
|
soft_limit_mult = 0;
|
||||||
soft_limit_mult = 0;
|
} else if (params.oomadj >= 800) {
|
||||||
} else if (params.oomadj >= 700) {
|
soft_limit_mult = 0;
|
||||||
soft_limit_mult = 0;
|
} else if (params.oomadj >= 700) {
|
||||||
} else if (params.oomadj >= 600) {
|
soft_limit_mult = 0;
|
||||||
// Launcher should be perceptible, don't kill it.
|
} else if (params.oomadj >= 600) {
|
||||||
params.oomadj = 200;
|
// Launcher should be perceptible, don't kill it.
|
||||||
soft_limit_mult = 1;
|
params.oomadj = 200;
|
||||||
} else if (params.oomadj >= 500) {
|
soft_limit_mult = 1;
|
||||||
soft_limit_mult = 0;
|
} else if (params.oomadj >= 500) {
|
||||||
} else if (params.oomadj >= 400) {
|
soft_limit_mult = 0;
|
||||||
soft_limit_mult = 0;
|
} else if (params.oomadj >= 400) {
|
||||||
} else if (params.oomadj >= 300) {
|
soft_limit_mult = 0;
|
||||||
soft_limit_mult = 1;
|
} else if (params.oomadj >= 300) {
|
||||||
} else if (params.oomadj >= 200) {
|
soft_limit_mult = 1;
|
||||||
soft_limit_mult = 2;
|
} else if (params.oomadj >= 200) {
|
||||||
} else if (params.oomadj >= 100) {
|
soft_limit_mult = 2;
|
||||||
soft_limit_mult = 10;
|
} else if (params.oomadj >= 100) {
|
||||||
} else if (params.oomadj >= 0) {
|
soft_limit_mult = 10;
|
||||||
soft_limit_mult = 20;
|
} else if (params.oomadj >= 0) {
|
||||||
} else {
|
soft_limit_mult = 20;
|
||||||
// Persistent processes will have a large
|
} else {
|
||||||
// soft limit 512MB.
|
// Persistent processes will have a large
|
||||||
soft_limit_mult = 64;
|
// soft limit 512MB.
|
||||||
|
soft_limit_mult = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(path, sizeof(path), MEMCG_SYSFS_PATH
|
||||||
|
"apps/uid_%d/pid_%d/memory.soft_limit_in_bytes",
|
||||||
|
params.uid, params.pid);
|
||||||
|
snprintf(val, sizeof(val), "%d", soft_limit_mult * EIGHT_MEGA);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* system_server process has no memcg under /dev/memcg/apps but should be
|
||||||
|
* registered with lmkd. This is the best way so far to identify it.
|
||||||
|
*/
|
||||||
|
is_system_server = (params.oomadj == SYSTEM_ADJ &&
|
||||||
|
(pwdrec = getpwnam("system")) != NULL &&
|
||||||
|
params.uid == pwdrec->pw_uid);
|
||||||
|
writefilestring(path, val, !is_system_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path, sizeof(path), MEMCG_SYSFS_PATH "apps/uid_%d/pid_%d/memory.soft_limit_in_bytes",
|
|
||||||
params.uid, params.pid);
|
|
||||||
snprintf(val, sizeof(val), "%d", soft_limit_mult * EIGHT_MEGA);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* system_server process has no memcg under /dev/memcg/apps but should be
|
|
||||||
* registered with lmkd. This is the best way so far to identify it.
|
|
||||||
*/
|
|
||||||
is_system_server = (params.oomadj == SYSTEM_ADJ &&
|
|
||||||
(pwdrec = getpwnam("system")) != NULL &&
|
|
||||||
params.uid == pwdrec->pw_uid);
|
|
||||||
writefilestring(path, val, !is_system_server);
|
|
||||||
|
|
||||||
procp = pid_lookup(params.pid);
|
procp = pid_lookup(params.pid);
|
||||||
if (!procp) {
|
if (!procp) {
|
||||||
procp = malloc(sizeof(struct proc));
|
procp = malloc(sizeof(struct proc));
|
||||||
|
|
@ -1250,8 +1253,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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Free up enough pages to push over the highest minfree level */
|
/* Free up enough pages to push over the highest minfree level */
|
||||||
pages_to_free = lowmem_minfree[lowmem_targets_size - 1] -
|
pages_to_free = lowmem_minfree[lowmem_targets_size - 1] -
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue