lmkd: Handle workingset_refault vmstat field change in 5.9 kernel
Linux kernel 5.9 change some vmstat fields including workingset_refault which affects lmkd operation. Update vmstat parsing to handle both old (workingset_refault) and new (workingset_refault_file) names for that field. Bug: 175617952 Test: lmkd_unit_test Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: I8f9b3d027ca96154f07e7252902a5aa04cf05a9f
This commit is contained in:
parent
9f8d3dec72
commit
dc60f9717b
18
lmkd.cpp
18
lmkd.cpp
|
|
@ -449,6 +449,7 @@ enum vmstat_field {
|
||||||
VS_INACTIVE_FILE,
|
VS_INACTIVE_FILE,
|
||||||
VS_ACTIVE_FILE,
|
VS_ACTIVE_FILE,
|
||||||
VS_WORKINGSET_REFAULT,
|
VS_WORKINGSET_REFAULT,
|
||||||
|
VS_WORKINGSET_REFAULT_FILE,
|
||||||
VS_PGSCAN_KSWAPD,
|
VS_PGSCAN_KSWAPD,
|
||||||
VS_PGSCAN_DIRECT,
|
VS_PGSCAN_DIRECT,
|
||||||
VS_PGSCAN_DIRECT_THROTTLE,
|
VS_PGSCAN_DIRECT_THROTTLE,
|
||||||
|
|
@ -460,6 +461,7 @@ static const char* const vmstat_field_names[MI_FIELD_COUNT] = {
|
||||||
"nr_inactive_file",
|
"nr_inactive_file",
|
||||||
"nr_active_file",
|
"nr_active_file",
|
||||||
"workingset_refault",
|
"workingset_refault",
|
||||||
|
"workingset_refault_file",
|
||||||
"pgscan_kswapd",
|
"pgscan_kswapd",
|
||||||
"pgscan_direct",
|
"pgscan_direct",
|
||||||
"pgscan_direct_throttle",
|
"pgscan_direct_throttle",
|
||||||
|
|
@ -471,6 +473,7 @@ union vmstat {
|
||||||
int64_t nr_inactive_file;
|
int64_t nr_inactive_file;
|
||||||
int64_t nr_active_file;
|
int64_t nr_active_file;
|
||||||
int64_t workingset_refault;
|
int64_t workingset_refault;
|
||||||
|
int64_t workingset_refault_file;
|
||||||
int64_t pgscan_kswapd;
|
int64_t pgscan_kswapd;
|
||||||
int64_t pgscan_direct;
|
int64_t pgscan_direct;
|
||||||
int64_t pgscan_direct_throttle;
|
int64_t pgscan_direct_throttle;
|
||||||
|
|
@ -2343,6 +2346,7 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
int min_score_adj = 0;
|
int min_score_adj = 0;
|
||||||
int swap_util = 0;
|
int swap_util = 0;
|
||||||
long since_thrashing_reset_ms;
|
long since_thrashing_reset_ms;
|
||||||
|
int64_t workingset_refault_file;
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm) != 0) {
|
if (clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm) != 0) {
|
||||||
ALOGE("Failed to get current time");
|
ALOGE("Failed to get current time");
|
||||||
|
|
@ -2368,6 +2372,8 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
ALOGE("Failed to parse vmstat!");
|
ALOGE("Failed to parse vmstat!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* Starting 5.9 kernel workingset_refault vmstat field was renamed workingset_refault_file */
|
||||||
|
workingset_refault_file = vs.field.workingset_refault ? : vs.field.workingset_refault_file;
|
||||||
|
|
||||||
if (meminfo_parse(&mi) < 0) {
|
if (meminfo_parse(&mi) < 0) {
|
||||||
ALOGE("Failed to parse meminfo!");
|
ALOGE("Failed to parse meminfo!");
|
||||||
|
|
@ -2380,7 +2386,7 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
cycle_after_kill = true;
|
cycle_after_kill = true;
|
||||||
/* Reset file-backed pagecache size and refault amounts after a kill */
|
/* Reset file-backed pagecache size and refault amounts after a kill */
|
||||||
base_file_lru = vs.field.nr_inactive_file + vs.field.nr_active_file;
|
base_file_lru = vs.field.nr_inactive_file + vs.field.nr_active_file;
|
||||||
init_ws_refault = vs.field.workingset_refault;
|
init_ws_refault = workingset_refault_file;
|
||||||
thrashing_reset_tm = curr_tm;
|
thrashing_reset_tm = curr_tm;
|
||||||
prev_thrash_growth = 0;
|
prev_thrash_growth = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2401,12 +2407,12 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
} else if (vs.field.pgscan_kswapd > init_pgscan_kswapd) {
|
} else if (vs.field.pgscan_kswapd > init_pgscan_kswapd) {
|
||||||
init_pgscan_kswapd = vs.field.pgscan_kswapd;
|
init_pgscan_kswapd = vs.field.pgscan_kswapd;
|
||||||
reclaim = KSWAPD_RECLAIM;
|
reclaim = KSWAPD_RECLAIM;
|
||||||
} else if (vs.field.workingset_refault == prev_workingset_refault) {
|
} else if (workingset_refault_file == prev_workingset_refault) {
|
||||||
/* Device is not thrashing and not reclaiming, bail out early until we see these stats changing*/
|
/* Device is not thrashing and not reclaiming, bail out early until we see these stats changing*/
|
||||||
goto no_kill;
|
goto no_kill;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_workingset_refault = vs.field.workingset_refault;
|
prev_workingset_refault = workingset_refault_file;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It's possible we fail to find an eligible process to kill (ex. no process is
|
* It's possible we fail to find an eligible process to kill (ex. no process is
|
||||||
|
|
@ -2423,7 +2429,7 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
if (since_thrashing_reset_ms > THRASHING_RESET_INTERVAL_MS) {
|
if (since_thrashing_reset_ms > THRASHING_RESET_INTERVAL_MS) {
|
||||||
long windows_passed;
|
long windows_passed;
|
||||||
/* Calculate prev_thrash_growth if we crossed THRASHING_RESET_INTERVAL_MS */
|
/* Calculate prev_thrash_growth if we crossed THRASHING_RESET_INTERVAL_MS */
|
||||||
prev_thrash_growth = (vs.field.workingset_refault - init_ws_refault) * 100
|
prev_thrash_growth = (workingset_refault_file - init_ws_refault) * 100
|
||||||
/ (base_file_lru + 1);
|
/ (base_file_lru + 1);
|
||||||
windows_passed = (since_thrashing_reset_ms / THRASHING_RESET_INTERVAL_MS);
|
windows_passed = (since_thrashing_reset_ms / THRASHING_RESET_INTERVAL_MS);
|
||||||
/*
|
/*
|
||||||
|
|
@ -2437,12 +2443,12 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
||||||
|
|
||||||
/* Record file-backed pagecache size when crossing THRASHING_RESET_INTERVAL_MS */
|
/* Record file-backed pagecache size when crossing THRASHING_RESET_INTERVAL_MS */
|
||||||
base_file_lru = vs.field.nr_inactive_file + vs.field.nr_active_file;
|
base_file_lru = vs.field.nr_inactive_file + vs.field.nr_active_file;
|
||||||
init_ws_refault = vs.field.workingset_refault;
|
init_ws_refault = workingset_refault_file;
|
||||||
thrashing_reset_tm = curr_tm;
|
thrashing_reset_tm = curr_tm;
|
||||||
thrashing_limit = thrashing_limit_pct;
|
thrashing_limit = thrashing_limit_pct;
|
||||||
} else {
|
} else {
|
||||||
/* Calculate what % of the file-backed pagecache refaulted so far */
|
/* Calculate what % of the file-backed pagecache refaulted so far */
|
||||||
thrashing = (vs.field.workingset_refault - init_ws_refault) * 100 / (base_file_lru + 1);
|
thrashing = (workingset_refault_file - init_ws_refault) * 100 / (base_file_lru + 1);
|
||||||
}
|
}
|
||||||
/* Add previous cycle's decayed thrashing amount */
|
/* Add previous cycle's decayed thrashing amount */
|
||||||
thrashing += prev_thrash_growth;
|
thrashing += prev_thrash_growth;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue