From 170d02da21006d8c0aff6919e7286e6a69a37d64 Mon Sep 17 00:00:00 2001 From: yushuailong Date: Sun, 6 Sep 2026 22:30:54 +0800 Subject: [PATCH] sched/critmonitor: Restore the target run start time. The context-switch merge assigned the current timestamp to run_time instead of run_start. This overwrote the accumulated runtime and left the next elapsed-time calculation with a stale start value when critical-monitor CPU load accounting was disabled. Store the timestamp in run_start under the thread runtime monitor configuration, matching the former resume path. Fixes: b2a69ba781 ("sched: merge nxsched_suspend/resume_critmon") Assisted-by: OpenAI Codex Signed-off-by: yushuailong --- sched/sched/sched_critmonitor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sched/sched/sched_critmonitor.c b/sched/sched/sched_critmonitor.c index 1de9146250a..7e12f367a29 100644 --- a/sched/sched/sched_critmonitor.c +++ b/sched/sched/sched_critmonitor.c @@ -377,12 +377,11 @@ void nxsched_switch_critmon(FAR struct tcb_s *from, FAR struct tcb_s *to) clock_t tick = elapsed * CLOCKS_PER_SEC / perf_getfreq(); nxsched_critmon_cpuload(from, current, tick); - to->run_start = current; #endif #if CONFIG_SCHED_CRITMONITOR_MAXTIME_THREAD >= 0 from->run_time += elapsed; - to->run_time = current; + to->run_start = current; if (elapsed > from->run_max) { from->run_max = elapsed;