kernel: thread: Add k_thread_runtime_stats_cpu_get()
Add k_thread_runtime_stats_cpu_get() to get runtime statistics of the specified core. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
This commit is contained in:
parent
b8a1a62048
commit
28215fc788
2 changed files with 30 additions and 0 deletions
|
@ -6193,6 +6193,15 @@ int k_thread_runtime_stats_get(k_tid_t thread,
|
|||
*/
|
||||
int k_thread_runtime_stats_all_get(k_thread_runtime_stats_t *stats);
|
||||
|
||||
/**
|
||||
* @brief Get the runtime statistics of all threads on specified cpu
|
||||
*
|
||||
* @param cpu The cpu number
|
||||
* @param stats Pointer to struct to copy statistics into.
|
||||
* @return -EINVAL if null pointers, otherwise 0
|
||||
*/
|
||||
int k_thread_runtime_stats_cpu_get(int cpu, k_thread_runtime_stats_t *stats);
|
||||
|
||||
/**
|
||||
* @brief Enable gathering of runtime statistics for specified thread
|
||||
*
|
||||
|
|
|
@ -998,6 +998,27 @@ int k_thread_runtime_stats_all_get(k_thread_runtime_stats_t *stats)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int k_thread_runtime_stats_cpu_get(int cpu, k_thread_runtime_stats_t *stats)
|
||||
{
|
||||
if (stats == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*stats = (k_thread_runtime_stats_t) {};
|
||||
|
||||
#ifdef CONFIG_SCHED_THREAD_USAGE_ALL
|
||||
#ifdef CONFIG_SMP
|
||||
z_sched_cpu_usage(cpu, stats);
|
||||
#else
|
||||
__ASSERT(cpu == 0, "cpu filter out of bounds");
|
||||
ARG_UNUSED(cpu);
|
||||
z_sched_cpu_usage(0, stats);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_THREAD_ABORT_NEED_CLEANUP
|
||||
/** Pointer to thread which needs to be cleaned up. */
|
||||
static struct k_thread *thread_to_cleanup;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue