kernel: extend thread runtime stats
When the new Kconfig option CONFIG_SCHED_THREAD_USAGE_ANALYSIS is enabled, additional timing stats are collected during context switches. This extra information allows a developer to obtain the the current, longest, average and total lengths of the time that a thread has been scheduled to execute. A developer can in turn use this information to tune their app and/or alter their scheduling policies. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
5deaffb2ee
commit
572f1db56a
4 changed files with 122 additions and 21 deletions
26
include/kernel/stats.h
Normal file
26
include/kernel/stats.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_KERNEL_STATS_H_
|
||||
#define ZEPHYR_INCLUDE_KERNEL_STATS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* [k_cycle_stats] is used to track internal statistics about both thread
|
||||
* and CPU usage.
|
||||
*/
|
||||
|
||||
struct k_cycle_stats {
|
||||
uint64_t total; /* total usage in cycles */
|
||||
#ifdef CONFIG_SCHED_THREAD_USAGE_ANALYSIS
|
||||
uint64_t current; /* # of cycles in current usage window */
|
||||
uint64_t longest; /* # of cycles in longest usage window */
|
||||
uint32_t num_windows; /* # of usage windows */
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue