lmkd: avoid division by zero because of file_base_lru
It seems we have chance that file_base_lru is zero. Avoid it by adding 1. Bug: 167660459 Bug: 163134367 Test: boot Signed-off-by: Martin Liu <liumartin@google.com> Merged-In: If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7 Change-Id: If19dbbaafe6cd28a9d5b7f8a002f3cd33daab5e7
This commit is contained in:
parent
94d99a7bc8
commit
91bf598282
5
lmkd.cpp
5
lmkd.cpp
|
|
@ -2399,7 +2399,8 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
|||
if (since_thrashing_reset_ms > THRASHING_RESET_INTERVAL_MS) {
|
||||
long windows_passed;
|
||||
/* Calculate prev_thrash_growth if we crossed THRASHING_RESET_INTERVAL_MS */
|
||||
prev_thrash_growth = (vs.field.workingset_refault - init_ws_refault) * 100 / base_file_lru;
|
||||
prev_thrash_growth = (vs.field.workingset_refault - init_ws_refault) * 100
|
||||
/ (base_file_lru + 1);
|
||||
windows_passed = (since_thrashing_reset_ms / THRASHING_RESET_INTERVAL_MS);
|
||||
/*
|
||||
* Decay prev_thrashing unless over-the-limit thrashing was registered in the window we
|
||||
|
|
@ -2417,7 +2418,7 @@ static void mp_event_psi(int data, uint32_t events, struct polling_params *poll_
|
|||
thrashing_limit = thrashing_limit_pct;
|
||||
} else {
|
||||
/* Calculate what % of the file-backed pagecache refaulted so far */
|
||||
thrashing = (vs.field.workingset_refault - init_ws_refault) * 100 / base_file_lru;
|
||||
thrashing = (vs.field.workingset_refault - init_ws_refault) * 100 / (base_file_lru + 1);
|
||||
}
|
||||
/* Add previous cycle's decayed thrashing amount */
|
||||
thrashing += prev_thrash_growth;
|
||||
|
|
|
|||
Loading…
Reference in New Issue