kernel: Fix gathering of runtime thread stats
The function k_thread_runtime_stats_all_get() now populates the current_cycles field in the thread runtime stats structure. Resets the number of cycles in the CPU's current usage window once the idle thread is scheduled. Fixes the average_cycles calcuation. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
b18f93dbc4
commit
976e4087ec
2 changed files with 12 additions and 8 deletions
|
@ -1100,6 +1100,7 @@ int k_thread_runtime_stats_all_get(k_thread_runtime_stats_t *stats)
|
|||
stats->execution_cycles += tmp_stats.execution_cycles;
|
||||
stats->total_cycles += tmp_stats.total_cycles;
|
||||
#ifdef CONFIG_SCHED_THREAD_USAGE_ANALYSIS
|
||||
stats->current_cycles += tmp_stats.current_cycles;
|
||||
stats->peak_cycles += tmp_stats.peak_cycles;
|
||||
stats->average_cycles += tmp_stats.average_cycles;
|
||||
#endif
|
||||
|
|
|
@ -39,16 +39,19 @@ static void sched_cpu_update_usage(struct _cpu *cpu, uint32_t cycles)
|
|||
return;
|
||||
}
|
||||
|
||||
if (cpu->current != cpu->idle_thread) {
|
||||
cpu->usage.total += cycles;
|
||||
|
||||
#ifdef CONFIG_SCHED_THREAD_USAGE_ANALYSIS
|
||||
cpu->usage.current += cycles;
|
||||
|
||||
if (cpu->usage.longest < cpu->usage.current) {
|
||||
cpu->usage.longest = cpu->usage.current;
|
||||
}
|
||||
} else {
|
||||
cpu->usage.current = 0;
|
||||
cpu->usage.num_windows++;
|
||||
#endif
|
||||
|
||||
if (cpu->current != cpu->idle_thread) {
|
||||
cpu->usage.total += cycles;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue