From 887556e5219eb9e0a897547910ba55846aac6f4a Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Wed, 20 Apr 2022 14:36:30 +0000 Subject: [PATCH] spdk_top: fix CPU usage in threads and cores tabs spdk_top does not display these values correctly, because it is compared with the busy/idle data gathered from the start of SPDK instead of the last cycle. The patch fixes that by adding a subtraction of second to last cycle metrics from the very last one. Fixes #2461 Change-Id: I6976a005bc848076e0d7fc94c0f91f97180b932d Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12319 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Tomasz Zawadzki --- app/spdk_top/spdk_top.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 61d2f71f3..7bfd2ef13 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -1406,7 +1406,8 @@ draw_thread_tab_row(uint64_t current_row, uint8_t item_index) core_num = g_threads_info[current_row].core_num; if (core_num >= 0 && core_num < RPC_MAX_CORES) { get_cpu_usage_str(g_threads_info[current_row].busy - g_threads_info[current_row].last_busy, - g_cores_info[core_num].busy + g_cores_info[core_num].idle, + (g_cores_info[core_num].busy - g_cores_info[core_num].last_busy) + + (g_cores_info[core_num].idle - g_cores_info[core_num].last_idle), cpu_usage); } else { snprintf(cpu_usage, sizeof(cpu_usage), "n/a"); @@ -1674,7 +1675,8 @@ draw_core_tab_row(uint64_t current_row, uint8_t item_index) if (!col_desc[COL_CORES_CPU_USAGE].disabled) { get_cpu_usage_str(g_cores_info[current_row].busy - g_cores_info[current_row].last_busy, - g_cores_info[current_row].busy + g_cores_info[current_row].idle, + (g_cores_info[current_row].busy - g_cores_info[current_row].last_busy) + + (g_cores_info[current_row].idle - g_cores_info[current_row].last_idle), cpu_usage); print_max_len(g_tabs[CORES_TAB], TABS_DATA_START_ROW + item_index, col, col_desc[COL_CORES_CPU_USAGE].max_data_string, ALIGN_RIGHT, cpu_usage);