kernel: Swap RUNTIME_STATS implementation

Clean up RUNTIME_STATS to separate the API from the individual data
backends.  Use the SCHED_THREAD_USAGE tracking instead of the original
for execution_cycles.  Move the kconfig for that into the runtime
stats menu, since it's part of the family now.

Also remove a lot of needless #if's around the declarations.  Unused
structs and uncalled functions don't need to be explicitly hidden.  An
attempt to access a non-existent field (e.g. "execution_cycles" if
that isn't configured) provides all the build time validation we need.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-09-28 10:01:06 -07:00 committed by Anas Nashif
commit f169c5bc13
5 changed files with 31 additions and 111 deletions

View file

@ -169,29 +169,11 @@ struct _thread_userspace_local_data {
};
#endif
#ifdef CONFIG_THREAD_RUNTIME_STATS
struct k_thread_runtime_stats {
/* Thread execution cycles */
#ifdef CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS
timing_t execution_cycles;
#else
typedef struct k_thread_runtime_stats {
#ifdef CONFIG_SCHED_THREAD_USAGE
uint64_t execution_cycles;
#endif
};
typedef struct k_thread_runtime_stats k_thread_runtime_stats_t;
struct _thread_runtime_stats {
/* Timestamp when last switched in */
#ifdef CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS
timing_t last_switched_in;
#else
uint32_t last_switched_in;
#endif
k_thread_runtime_stats_t stats;
};
#endif
} k_thread_runtime_stats_t;
struct z_poller {
bool is_polling;
@ -289,11 +271,6 @@ struct k_thread {
uintptr_t tls;
#endif /* CONFIG_THREAD_LOCAL_STORAGE */
#ifdef CONFIG_THREAD_RUNTIME_STATS
/** Runtime statistics */
struct _thread_runtime_stats rt_stats;
#endif
#ifdef CONFIG_DEMAND_PAGING_THREAD_STATS
/** Paging statistics */
struct k_mem_paging_stats_t paging_stats;