Commit 65da9a26 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

spdk_top: add dynamic refreshing when core popup is active



Changes refreshing of cores tab to work from within cores pop-up
refresh function. This works the same way as refreshing of
THREADS and POLLERS pop-ups and tabs.

Added a handle for core window and core info to display_thread().
The purpose is to allow threads popup to refresh already active
cores popup. Otherwise, there are artifacts left where core popup
was displayed.

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


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 05c45b39
Loading
Loading
Loading
Loading
+29 −6
Original line number Diff line number Diff line
@@ -2400,7 +2400,8 @@ draw_core_win_content(WINDOW *core_win, struct rpc_core_info *core_info)
}

static void
display_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
display_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab,
	       WINDOW *core_popup, struct rpc_core_info *core_info)
{
	PANEL *thread_panel = NULL;
	WINDOW *thread_win = NULL;
@@ -2463,6 +2464,9 @@ display_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
			time_last = time_now.tv_sec;
			pthread_mutex_lock(&g_thread_lock);
			refresh_tab(active_tab, current_page);
			if (core_popup != NULL) {
				draw_core_win_content(core_popup, core_info);
			}
			draw_thread_win_content(thread_win, &thread_info);
			refresh();
			pthread_mutex_unlock(&g_thread_lock);
@@ -2486,11 +2490,12 @@ show_thread(uint8_t current_page, uint8_t active_tab)
	thread_id = g_threads_info[thread_number].id;
	pthread_mutex_unlock(&g_thread_lock);

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

static void
show_single_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
show_single_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab, WINDOW *core_popup,
		   struct rpc_core_info *core_info)
{
	uint64_t i;

@@ -2498,7 +2503,7 @@ show_single_thread(uint64_t thread_id, uint8_t current_page, uint8_t active_tab)
	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, active_tab);
			display_thread(thread_id, current_page, active_tab, core_popup, core_info);
			return;
		}
	}
@@ -2516,6 +2521,11 @@ show_core(uint8_t current_page, uint8_t active_tab)
	uint64_t thread_id = 0;
	uint16_t current_threads_row;
	int c;
	long int time_last, time_dif;
	struct timespec time_now;

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

	bool stop_loop = false;

@@ -2535,6 +2545,7 @@ show_core(uint8_t current_page, uint8_t active_tab)
	update_panels();
	doupdate();
	draw_core_win_content(core_win, core_info);
	refresh();

	current_threads_row = 0;

@@ -2552,7 +2563,7 @@ show_core(uint8_t current_page, uint8_t active_tab)

		wrefresh(core_win);

		c = wgetch(core_win);
		c = getch();
		switch (c) {
		case 10: /* ENTER */
			pthread_mutex_lock(&g_thread_lock);
@@ -2562,7 +2573,7 @@ show_core(uint8_t current_page, uint8_t active_tab)
			pthread_mutex_unlock(&g_thread_lock);

			if (thread_id != 0) {
				show_single_thread(thread_id, current_page, active_tab);
				show_single_thread(thread_id, current_page, active_tab, core_win, core_info);
			}
			break;
		case 27: /* ESC */
@@ -2583,6 +2594,18 @@ show_core(uint8_t current_page, uint8_t active_tab)
		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_core_win_content(core_win, core_info);
			refresh();
			pthread_mutex_unlock(&g_thread_lock);
		}
	}

	del_panel(core_panel);