Commit 887556e5 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

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: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12319


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent bf5aca32
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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);