Commit 0aced700 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

spdk_top: add menu to core details window for displaying thread details



Adds menu to core details pop-up window to allow selecting threads running on core.
Pressing ENTER on selected thread shows pop-up window with thread details.
Added function to display thread details in pop-up window to avoid code duplication.
Function is called when ENTER is pressed on a selected thread in THREADS tab and
inside cores pop-up window.

Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Change-Id: I62a6de15c4bb4b58da0a7436d74cd20e0544a2ae
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5548


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent bd3c084f
Loading
Loading
Loading
Loading
+50 −3
Original line number Diff line number Diff line
@@ -859,7 +859,7 @@ refresh_threads_tab(uint8_t current_page)
{
	struct col_desc *col_desc = g_col_desc[THREADS_TAB];
	uint64_t i, threads_count;
	uint16_t j;
	uint16_t j, k;
	uint16_t col;
	uint8_t max_pages, item_index;
	static uint8_t last_page = 0;
@@ -899,6 +899,11 @@ refresh_threads_tab(uint8_t current_page)

	qsort(thread_info, threads_count, sizeof(thread_info[0]), sort_threads);

	for (k = 0; k < threads_count; k++) {
		g_thread_history[thread_info[k]->id].busy = thread_info[k]->busy - thread_info[k]->last_busy;
		g_thread_history[thread_info[k]->id].idle = thread_info[k]->idle - thread_info[k]->last_idle;
	}

	for (i = current_page * g_max_data_rows;
	     i < spdk_min(threads_count, (uint64_t)((current_page + 1) * g_max_data_rows));
	     i++) {
@@ -952,7 +957,6 @@ refresh_threads_tab(uint8_t current_page)
			print_max_len(g_tabs[THREADS_TAB], TABS_DATA_START_ROW + item_index, col,
				      col_desc[5].max_data_string, ALIGN_RIGHT, idle_time);
			col += col_desc[5].max_data_string;
			thread_info[i]->last_idle = thread_info[i]->idle;
		}

		g_thread_history[thread_info[i]->id].busy = thread_info[i]->busy - thread_info[i]->last_busy;
@@ -964,7 +968,6 @@ refresh_threads_tab(uint8_t current_page)
			}
			print_max_len(g_tabs[THREADS_TAB], TABS_DATA_START_ROW + item_index, col,
				      col_desc[6].max_data_string, ALIGN_RIGHT, busy_time);
			thread_info[i]->last_busy = thread_info[i]->busy;
		}

		if (item_index == g_selected_row) {
@@ -972,6 +975,11 @@ refresh_threads_tab(uint8_t current_page)
		}
	}

	for (k = 0; k < threads_count; k++) {
		thread_info[k]->last_idle = thread_info[k]->idle;
		thread_info[k]->last_busy = thread_info[k]->busy;
	}

	g_max_selected_row = i - current_page * g_max_data_rows - 1;

	return max_pages;
@@ -2029,6 +2037,19 @@ show_thread(uint8_t current_page)
	free_data();
}

static void
show_single_thread(uint64_t thread_id)
{
	uint64_t i;

	for (i = 0; i < g_threads_stats.threads.threads_count; i++) {
		if (g_threads_stats.threads.thread_info[i].id == thread_id) {
			display_thread(&g_threads_stats.threads.thread_info[i]);
			break;
		}
	}
}

static void
show_core(uint8_t current_page)
{
@@ -2037,6 +2058,7 @@ show_core(uint8_t current_page)
	uint64_t core_number = current_page * g_max_data_rows + g_selected_row;
	struct rpc_core_info *core_info[g_cores_stats.cores.cores_count];
	uint64_t threads_count, i, j;
	uint16_t current_threads_row;
	int c;
	char core_win_title[25];
	bool stop_loop = false;
@@ -2097,13 +2119,38 @@ show_core(uint8_t current_page)
	refresh();
	wrefresh(core_win);

	current_threads_row = 0;

	while (!stop_loop) {
		for (j = 0; j < core_info[core_number]->threads.threads_count; j++) {
			if (j != current_threads_row) {
				mvwprintw(core_win, j + 8, 1, core_info[core_number]->threads.thread[j].name);
			} else {
				print_left(core_win, j + 8, 1, CORE_WIN_WIDTH - 2,
					   core_info[core_number]->threads.thread[j].name, COLOR_PAIR(2));
			}
		}

		wrefresh(core_win);

		c = wgetch(core_win);
		switch (c) {
		case 10: /* ENTER */
			show_single_thread(core_info[core_number]->threads.thread[current_threads_row].id);
			break;
		case 27: /* ESC */
			stop_loop = true;
			break;
		case KEY_UP:
			if (current_threads_row != 0) {
				current_threads_row--;
			}
			break;
		case KEY_DOWN:
			if (current_threads_row != core_info[core_number]->threads.threads_count - 1) {
				current_threads_row++;
			}
			break;
		default:
			break;
		}