Commit 53add5e2 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

spdk_top: make threads pop-up window refresh itself and active tab



Adds refreshing of threads and cores tab when thread pop-up is active.

Adds refreshing of threads pop-up and moved thread_win allocation and
poller number checking inside while loop.

Dynamic refresing of core pop-up with thread pop-up active
will be added in future patches.

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


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 216a7c3d
Loading
Loading
Loading
Loading
+60 −35
Original line number Diff line number Diff line
@@ -2344,26 +2344,37 @@ get_single_thread_info(uint64_t thread_id, struct rpc_thread_info *thread_info)
}

static void
display_thread(uint64_t thread_id, uint8_t current_page)
display_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
{
	PANEL *thread_panel;
	WINDOW *thread_win;
	PANEL *thread_panel = NULL;
	WINDOW *thread_win = NULL;
	struct rpc_thread_info thread_info;
	uint64_t pollers_count;
	uint64_t pollers_count, last_pollers_count = 0;
	int c;
	bool stop_loop = false;
	long int time_last, time_dif;
	struct timespec time_now;

	clock_gettime(CLOCK_MONOTONIC, &time_now);
	time_last = time_now.tv_sec;

	memset(&thread_info, 0, sizeof(thread_info));
	pthread_mutex_lock(&g_thread_lock);

	while (!stop_loop) {
		pthread_mutex_lock(&g_thread_lock);
		if (get_single_thread_info(thread_id, &thread_info)) {
			pthread_mutex_unlock(&g_thread_lock);
			return;
		}

		pollers_count = thread_info.active_pollers_count +
				thread_info.timed_pollers_count +
				thread_info.paused_pollers_count;
		if (pollers_count != last_pollers_count) {
			if (thread_win != NULL) {
				assert(thread_panel != NULL);
				del_panel(thread_panel);
				delwin(thread_win);
			}

			thread_win = newwin(pollers_count + THREAD_WIN_HEIGHT, THREAD_WIN_WIDTH,
					    get_position_for_window(THREAD_WIN_HEIGHT + pollers_count, g_max_row),
@@ -2374,13 +2385,12 @@ display_thread(uint64_t thread_id, uint8_t current_page)
			top_panel(thread_panel);
			update_panels();
			doupdate();

			draw_thread_win_content(thread_win, &thread_info);

			refresh();
		}
		pthread_mutex_unlock(&g_thread_lock);

	while (!stop_loop) {
		c = wgetch(thread_win);
		c = getch();

		switch (c) {
		case 27: /* ESC */
@@ -2389,6 +2399,21 @@ display_thread(uint64_t thread_id, uint8_t current_page)
		default:
			break;
		}

		clock_gettime(CLOCK_MONOTONIC, &time_now);
		time_dif = time_now.tv_sec - time_last;

		if (time_dif >= g_sleep_time) {
			time_last = time_now.tv_sec;
			pthread_mutex_lock(&g_thread_lock);
			refresh_tab(active_tab, current_page);
			draw_thread_win_content(thread_win, &thread_info);
			wrefresh(thread_win);
			refresh();
			pthread_mutex_unlock(&g_thread_lock);
		}

		last_pollers_count = pollers_count;
	}

	del_panel(thread_panel);
@@ -2396,7 +2421,7 @@ display_thread(uint64_t thread_id, uint8_t current_page)
}

static void
show_thread(uint8_t current_page)
show_thread(uint8_t current_page, uint8_t active_tab)
{
	uint64_t thread_number = current_page * g_max_data_rows + g_selected_row;
	uint64_t thread_id;
@@ -2406,11 +2431,11 @@ show_thread(uint8_t current_page)
	thread_id = g_threads_info[thread_number].id;
	pthread_mutex_unlock(&g_thread_lock);

	display_thread(thread_id, current_page);
	display_thread(thread_id, current_page, active_tab);
}

static void
show_single_thread(uint64_t thread_id, uint8_t current_page)
show_single_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
{
	uint64_t i;

@@ -2418,7 +2443,7 @@ show_single_thread(uint64_t thread_id, uint8_t current_page)
	for (i = 0; i < g_last_threads_count; i++) {
		if (g_threads_info[i].id == thread_id) {
			pthread_mutex_unlock(&g_thread_lock);
			display_thread(thread_id, current_page);
			display_thread(thread_id, current_page, active_tab);
			return;
		}
	}
@@ -2426,7 +2451,7 @@ show_single_thread(uint64_t thread_id, uint8_t current_page)
}

static void
show_core(uint8_t current_page)
show_core(uint8_t current_page, uint8_t active_tab)
{
	PANEL *core_panel;
	WINDOW *core_win;
@@ -2537,7 +2562,7 @@ show_core(uint8_t current_page)
			pthread_mutex_unlock(&g_thread_lock);

			if (thread_id != 0) {
				show_single_thread(thread_id, current_page);
				show_single_thread(thread_id, current_page, active_tab);
			}
			break;
		case 27: /* ESC */
@@ -2908,9 +2933,9 @@ show_stats(pthread_t *data_thread)
			break;
		case 10: /* Enter */
			if (active_tab == THREADS_TAB) {
				show_thread(current_page);
				show_thread(current_page, active_tab);
			} else if (active_tab == CORES_TAB) {
				show_core(current_page);
				show_core(current_page, active_tab);
			} else if (active_tab == POLLERS_TAB) {
				show_poller(current_page);
			}