From 11f8f6697fb5e19d94c1133a1aaf97ad6ea154cc Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Tue, 18 Jan 2022 10:17:14 -0500 Subject: [PATCH] kernel: Update CPU runtime stats of non-idle time Updates sched_cpu_update_usage() such that the CPU runtime stats only update the its non-idle time when the current thread is not the idle thread. This is necessary as otherwise the CPUs idle-time will be double counted in k_thread_runtime_stats.execution_cycles. Signed-off-by: Peter Mitsis --- kernel/usage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/usage.c b/kernel/usage.c index c5da1de8b7b..2d8be207f39 100644 --- a/kernel/usage.c +++ b/kernel/usage.c @@ -47,7 +47,9 @@ static void sched_cpu_update_usage(struct _cpu *cpu, uint32_t cycles) } #endif - cpu->usage.total += cycles; + if (cpu->current != cpu->idle_thread) { + cpu->usage.total += cycles; + } } #else #define sched_cpu_update_usage(cpu, cycles) do { } while (0)