subsys/profiling: kill timer in a single place

Currently, the timer is stopped:
- in the timer handler, when the buffer is full, or
- in work handler, when time's up

In any cases, the work handler is bounded to run to print
the message, so we can kill the timer there instead.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2024-08-16 12:49:59 +08:00 committed by Henrik Brix Andersen
commit e330971ec5

View file

@ -48,7 +48,6 @@ static void perf_tracer(struct k_timer *timer)
} else {
--perf_data_ptr->idx;
perf_data_ptr->buf_full = true;
k_timer_stop(timer);
k_work_reschedule(&perf_data_ptr->dwork, K_NO_WAIT);
}
}
@ -58,10 +57,10 @@ static void perf_dwork_handler(struct k_work *work)
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct perf_data_t *perf_data_ptr = CONTAINER_OF(dwork, struct perf_data_t, dwork);
k_timer_stop(&perf_data_ptr->timer);
if (perf_data_ptr->buf_full) {
shell_error(perf_data_ptr->sh, "Perf buf overflow!");
} else {
k_timer_stop(&perf_data_ptr->timer);
shell_print(perf_data_ptr->sh, "Perf done!");
}
}