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: Krzysztof 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: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Krzysztof Karas 2021-07-26 15:00:30 +02:00 committed by Tomasz Zawadzki
parent 216a7c3d0b
commit 53add5e240

View File

@ -2344,43 +2344,53 @@ get_single_thread_info(uint64_t thread_id, struct rpc_thread_info *thread_info)
} }
static void 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; PANEL *thread_panel = NULL;
WINDOW *thread_win; WINDOW *thread_win = NULL;
struct rpc_thread_info thread_info; struct rpc_thread_info thread_info;
uint64_t pollers_count; uint64_t pollers_count, last_pollers_count = 0;
int c; int c;
bool stop_loop = false; 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)); memset(&thread_info, 0, sizeof(thread_info));
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;
thread_win = newwin(pollers_count + THREAD_WIN_HEIGHT, THREAD_WIN_WIDTH,
get_position_for_window(THREAD_WIN_HEIGHT + pollers_count, g_max_row),
get_position_for_window(THREAD_WIN_WIDTH, g_max_col));
keypad(thread_win, TRUE);
thread_panel = new_panel(thread_win);
top_panel(thread_panel);
update_panels();
doupdate();
draw_thread_win_content(thread_win, &thread_info);
pthread_mutex_unlock(&g_thread_lock);
while (!stop_loop) { while (!stop_loop) {
c = wgetch(thread_win); 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),
get_position_for_window(THREAD_WIN_WIDTH, g_max_col));
keypad(thread_win, TRUE);
thread_panel = new_panel(thread_win);
top_panel(thread_panel);
update_panels();
doupdate();
draw_thread_win_content(thread_win, &thread_info);
refresh();
}
pthread_mutex_unlock(&g_thread_lock);
c = getch();
switch (c) { switch (c) {
case 27: /* ESC */ case 27: /* ESC */
@ -2389,6 +2399,21 @@ display_thread(uint64_t thread_id, uint8_t current_page)
default: default:
break; 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); del_panel(thread_panel);
@ -2396,7 +2421,7 @@ display_thread(uint64_t thread_id, uint8_t current_page)
} }
static void 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_number = current_page * g_max_data_rows + g_selected_row;
uint64_t thread_id; uint64_t thread_id;
@ -2406,11 +2431,11 @@ show_thread(uint8_t current_page)
thread_id = g_threads_info[thread_number].id; thread_id = g_threads_info[thread_number].id;
pthread_mutex_unlock(&g_thread_lock); pthread_mutex_unlock(&g_thread_lock);
display_thread(thread_id, current_page); display_thread(thread_id, current_page, active_tab);
} }
static void 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; 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++) { for (i = 0; i < g_last_threads_count; i++) {
if (g_threads_info[i].id == thread_id) { if (g_threads_info[i].id == thread_id) {
pthread_mutex_unlock(&g_thread_lock); pthread_mutex_unlock(&g_thread_lock);
display_thread(thread_id, current_page); display_thread(thread_id, current_page, active_tab);
return; return;
} }
} }
@ -2426,7 +2451,7 @@ show_single_thread(uint64_t thread_id, uint8_t current_page)
} }
static void static void
show_core(uint8_t current_page) show_core(uint8_t current_page, uint8_t active_tab)
{ {
PANEL *core_panel; PANEL *core_panel;
WINDOW *core_win; WINDOW *core_win;
@ -2537,7 +2562,7 @@ show_core(uint8_t current_page)
pthread_mutex_unlock(&g_thread_lock); pthread_mutex_unlock(&g_thread_lock);
if (thread_id != 0) { if (thread_id != 0) {
show_single_thread(thread_id, current_page); show_single_thread(thread_id, current_page, active_tab);
} }
break; break;
case 27: /* ESC */ case 27: /* ESC */
@ -2908,9 +2933,9 @@ show_stats(pthread_t *data_thread)
break; break;
case 10: /* Enter */ case 10: /* Enter */
if (active_tab == THREADS_TAB) { if (active_tab == THREADS_TAB) {
show_thread(current_page); show_thread(current_page, active_tab);
} else if (active_tab == CORES_TAB) { } else if (active_tab == CORES_TAB) {
show_core(current_page); show_core(current_page, active_tab);
} else if (active_tab == POLLERS_TAB) { } else if (active_tab == POLLERS_TAB) {
show_poller(current_page); show_poller(current_page);
} }