From 69c5c6d5117ff9b045e1b74d40b29d86ad1fe550 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Thu, 11 Apr 2024 13:32:03 -0500 Subject: [PATCH] kernel: Remove duplicate execution_cycles write and improve docstring There is a duplicate write in `z_sched_thread_usage()` that can be removed. Also modified the docstrings to `k_thread_runtime_stats` to help better describe the differences between execution_cycles and total_cycles when getting stats for the CPU or a thread Signed-off-by: Eric Johnson --- include/zephyr/kernel/thread.h | 9 ++++----- kernel/usage.c | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/zephyr/kernel/thread.h b/include/zephyr/kernel/thread.h index cbbb35aa7d..fd8e4c02f2 100644 --- a/include/zephyr/kernel/thread.h +++ b/include/zephyr/kernel/thread.h @@ -206,13 +206,12 @@ struct _thread_userspace_local_data { typedef struct k_thread_runtime_stats { #ifdef CONFIG_SCHED_THREAD_USAGE - uint64_t execution_cycles; - uint64_t total_cycles; /* total # of non-idle cycles */ /* - * In the context of thread statistics, [execution_cycles] is the same - * as the total # of non-idle cycles. In the context of CPU statistics, - * it refers to the sum of non-idle + idle cycles. + * For CPU stats, execution_cycles is the sum of non-idle + idle cycles. + * For thread stats, execution_cycles = total_cycles. */ + uint64_t execution_cycles; /* total # of cycles (cpu: non-idle + idle) */ + uint64_t total_cycles; /* total # of non-idle cycles */ #endif /* CONFIG_SCHED_THREAD_USAGE */ #ifdef CONFIG_SCHED_THREAD_USAGE_ANALYSIS diff --git a/kernel/usage.c b/kernel/usage.c index 7ec5e30c8d..ad40e3ffd4 100644 --- a/kernel/usage.c +++ b/kernel/usage.c @@ -220,7 +220,6 @@ void z_sched_thread_usage(struct k_thread *thread, #ifdef CONFIG_SCHED_THREAD_USAGE_ALL stats->idle_cycles = 0; #endif /* CONFIG_SCHED_THREAD_USAGE_ALL */ - stats->execution_cycles = thread->base.usage.total; k_spin_unlock(&usage_lock, key); }