From ba95566de9edf682f9031cd4e84ed743843b9e5a Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Tue, 14 Mar 2023 09:40:16 +0100 Subject: [PATCH] spdk_top: move core_busy_period and core_idle_period Move these two variables below check for core_num boundary. This ensures core_num's value can be used as index for g_cores_info array. Change-Id: I118a4b3a3ec61c9ccd818f3f3bd2ff013d2d7b14 Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17175 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- app/spdk_top/spdk_top.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index a67427399..8b304b937 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -1384,9 +1384,9 @@ draw_thread_tab_row(uint64_t current_row, uint8_t item_index) if (!col_desc[COL_THREADS_CPU_USAGE].disabled) { core_num = g_threads_info[current_row].core_num; - uint64_t core_busy_period = g_cores_info[core_num].busy - g_cores_info[core_num].last_busy; - uint64_t core_idle_period = g_cores_info[core_num].idle - g_cores_info[core_num].last_idle; if (core_num >= 0 && core_num < RPC_MAX_CORES) { + uint64_t core_busy_period = g_cores_info[core_num].busy - g_cores_info[core_num].last_busy; + uint64_t core_idle_period = g_cores_info[core_num].idle - g_cores_info[core_num].last_idle; get_cpu_usage_str(busy_period, core_busy_period + core_idle_period, cpu_usage); } else { snprintf(cpu_usage, sizeof(cpu_usage), "n/a");