diff --git a/kernel/Kconfig b/kernel/Kconfig index cc36bb8d753..0a008821e68 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -369,7 +369,7 @@ if THREAD_RUNTIME_STATS config THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS bool "Use timing functions to gather statistics" - select TIMING_FUNCTIONS + select TIMING_FUNCTIONS_NEED_AT_BOOT help Use timing functions to gather thread runtime statistics. diff --git a/kernel/init.c b/kernel/init.c index 4605836da5f..3448dde5584 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -33,6 +33,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(os, CONFIG_KERNEL_LOG_LEVEL); @@ -400,7 +401,7 @@ FUNC_NORETURN void z_cstart(void) __stack_chk_guard <<= 8; #endif /* CONFIG_STACK_CANARIES */ -#ifdef CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS +#ifdef CONFIG_TIMING_FUNCTIONS_NEED_AT_BOOT timing_init(); timing_start(); #endif diff --git a/subsys/timing/Kconfig b/subsys/timing/Kconfig index 8e4deff7440..fa359d18c34 100644 --- a/subsys/timing/Kconfig +++ b/subsys/timing/Kconfig @@ -7,3 +7,13 @@ config TIMING_FUNCTIONS help When enabled, timing related functions are compiled. This is useful for gathering timing on code execution. + +config TIMING_FUNCTIONS_NEED_AT_BOOT + bool + select TIMING_FUNCTIONS + help + Hidden option to indicate that timing functions need to be + initialized at boot. + + To be selected by kernel and other subsystems which need + to use timing functions.