lmkd: Do not downgrade/ignore events when swap is full
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
This commit is contained in:
parent
953a455938
commit
65680690d7
14
lmkd.c
14
lmkd.c
|
|
@ -116,6 +116,7 @@ static bool kill_heaviest_task;
|
||||||
static unsigned long kill_timeout_ms;
|
static unsigned long kill_timeout_ms;
|
||||||
static bool use_minfree_levels;
|
static bool use_minfree_levels;
|
||||||
static bool per_app_memcg;
|
static bool per_app_memcg;
|
||||||
|
static int swap_free_low_percentage;
|
||||||
|
|
||||||
/* data required to handle events */
|
/* data required to handle events */
|
||||||
struct event_handler_info {
|
struct event_handler_info {
|
||||||
|
|
@ -194,6 +195,7 @@ enum meminfo_field {
|
||||||
MI_BUFFERS,
|
MI_BUFFERS,
|
||||||
MI_SHMEM,
|
MI_SHMEM,
|
||||||
MI_UNEVICTABLE,
|
MI_UNEVICTABLE,
|
||||||
|
MI_TOTAL_SWAP,
|
||||||
MI_FREE_SWAP,
|
MI_FREE_SWAP,
|
||||||
MI_DIRTY,
|
MI_DIRTY,
|
||||||
MI_FIELD_COUNT
|
MI_FIELD_COUNT
|
||||||
|
|
@ -206,6 +208,7 @@ static const char* const meminfo_field_names[MI_FIELD_COUNT] = {
|
||||||
"Buffers:",
|
"Buffers:",
|
||||||
"Shmem:",
|
"Shmem:",
|
||||||
"Unevictable:",
|
"Unevictable:",
|
||||||
|
"SwapTotal:",
|
||||||
"SwapFree:",
|
"SwapFree:",
|
||||||
"Dirty:",
|
"Dirty:",
|
||||||
};
|
};
|
||||||
|
|
@ -218,6 +221,7 @@ union meminfo {
|
||||||
int64_t buffers;
|
int64_t buffers;
|
||||||
int64_t shmem;
|
int64_t shmem;
|
||||||
int64_t unevictable;
|
int64_t unevictable;
|
||||||
|
int64_t total_swap;
|
||||||
int64_t free_swap;
|
int64_t free_swap;
|
||||||
int64_t dirty;
|
int64_t dirty;
|
||||||
/* fields below are calculated rather than read from the file */
|
/* fields below are calculated rather than read from the file */
|
||||||
|
|
@ -1296,6 +1300,10 @@ static void mp_event_common(int data, uint32_t events __unused) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we still have enough swap space available, check if we want to
|
||||||
|
// ignore/downgrade pressure events.
|
||||||
|
if (mi.field.free_swap >=
|
||||||
|
mi.field.total_swap * swap_free_low_percentage / 100) {
|
||||||
// If the pressure is larger than downgrade_pressure lmk will not
|
// If the pressure is larger than downgrade_pressure lmk will not
|
||||||
// kill any process, since enough memory is available.
|
// kill any process, since enough memory is available.
|
||||||
if (mem_pressure > downgrade_pressure) {
|
if (mem_pressure > downgrade_pressure) {
|
||||||
|
|
@ -1303,14 +1311,14 @@ static void mp_event_common(int data, uint32_t events __unused) {
|
||||||
ALOGI("Ignore %s memory pressure", level_name[level]);
|
ALOGI("Ignore %s memory pressure", level_name[level]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (level == VMPRESS_LEVEL_CRITICAL &&
|
} else if (level == VMPRESS_LEVEL_CRITICAL && mem_pressure > upgrade_pressure) {
|
||||||
mem_pressure > upgrade_pressure) {
|
|
||||||
if (debug_process_killing) {
|
if (debug_process_killing) {
|
||||||
ALOGI("Downgrade critical memory pressure");
|
ALOGI("Downgrade critical memory pressure");
|
||||||
}
|
}
|
||||||
// Downgrade event, since enough memory available.
|
// Downgrade event, since enough memory available.
|
||||||
level = downgrade_level(level);
|
level = downgrade_level(level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do_kill:
|
do_kill:
|
||||||
if (low_ram_device) {
|
if (low_ram_device) {
|
||||||
|
|
@ -1580,6 +1588,8 @@ int main(int argc __unused, char **argv __unused) {
|
||||||
property_get_bool("ro.lmk.use_minfree_levels", false);
|
property_get_bool("ro.lmk.use_minfree_levels", false);
|
||||||
per_app_memcg =
|
per_app_memcg =
|
||||||
property_get_bool("ro.config.per_app_memcg", low_ram_device);
|
property_get_bool("ro.config.per_app_memcg", low_ram_device);
|
||||||
|
swap_free_low_percentage =
|
||||||
|
property_get_int32("ro.lmk.swap_free_low_percentage", 10);
|
||||||
|
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
statslog_init(&log_ctx, &enable_stats_log);
|
statslog_init(&log_ctx, &enable_stats_log);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue