lmkd: fix possible long stall state
If the first PSI event triggers a kill, lmkd won't resume polling immediately after the process has died. Instead, it will wait until the next PSI event to resume the polling which is too late when the device is under memory pressure. This happens if data communication with AMS happens after previous polling window expired, in which case paused handler gets reset and polling does not resume after the kill. Fix this by changing pause handler reset logic. Bug: 167562248 Test: memory pressure test Signed-off-by: Martin Liu <liumartin@google.com> Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: I10c65c85b718a656e3d8991bf09948b96da895cb
This commit is contained in:
parent
c3108416e7
commit
589b5752ee
12
lmkd.cpp
12
lmkd.cpp
|
|
@ -3120,6 +3120,8 @@ static bool polling_paused(struct polling_params *poll_params) {
|
||||||
static void resume_polling(struct polling_params *poll_params, struct timespec curr_tm) {
|
static void resume_polling(struct polling_params *poll_params, struct timespec curr_tm) {
|
||||||
poll_params->poll_start_tm = curr_tm;
|
poll_params->poll_start_tm = curr_tm;
|
||||||
poll_params->poll_handler = poll_params->paused_handler;
|
poll_params->poll_handler = poll_params->paused_handler;
|
||||||
|
poll_params->polling_interval_ms = PSI_POLL_PERIOD_SHORT_MS;
|
||||||
|
poll_params->paused_handler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void call_handler(struct event_handler_info* handler_info,
|
static void call_handler(struct event_handler_info* handler_info,
|
||||||
|
|
@ -3154,7 +3156,6 @@ static void call_handler(struct event_handler_info* handler_info,
|
||||||
if (get_time_diff_ms(&poll_params->poll_start_tm, &curr_tm) > PSI_WINDOW_SIZE_MS) {
|
if (get_time_diff_ms(&poll_params->poll_start_tm, &curr_tm) > PSI_WINDOW_SIZE_MS) {
|
||||||
/* Polled for the duration of PSI window, time to stop */
|
/* Polled for the duration of PSI window, time to stop */
|
||||||
poll_params->poll_handler = NULL;
|
poll_params->poll_handler = NULL;
|
||||||
poll_params->paused_handler = NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -3179,12 +3180,8 @@ static void mainloop(void) {
|
||||||
bool poll_now;
|
bool poll_now;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
||||||
if (poll_params.poll_handler == poll_params.paused_handler) {
|
if (poll_params.update == POLLING_RESUME) {
|
||||||
/*
|
/* Just transitioned into POLLING_RESUME, poll immediately. */
|
||||||
* Just transitioned into POLLING_RESUME. Reset paused_handler
|
|
||||||
* and poll immediately
|
|
||||||
*/
|
|
||||||
poll_params.paused_handler = NULL;
|
|
||||||
poll_now = true;
|
poll_now = true;
|
||||||
nevents = 0;
|
nevents = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -3215,6 +3212,7 @@ static void mainloop(void) {
|
||||||
stop_wait_for_proc_kill(false);
|
stop_wait_for_proc_kill(false);
|
||||||
if (polling_paused(&poll_params)) {
|
if (polling_paused(&poll_params)) {
|
||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &curr_tm);
|
||||||
|
poll_params.update = POLLING_RESUME;
|
||||||
resume_polling(&poll_params, curr_tm);
|
resume_polling(&poll_params, curr_tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue