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

spdk_top: set minimal time on refresh rate



Set minimal required time for data gathering thread
to give display thread time to redraw all windows.
This is useful when user-defined refresh rate is set
to 0. With minimal required time hardcoded here, we
avoid multiple data refresh calls during one
display refresh (because drawing on screen takes
more time).

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


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 65da9a26
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2206,7 +2206,9 @@ change_refresh_rate(void)
			stop_loop = true;
			break;
		case 10: /* Enter */
			pthread_mutex_lock(&g_thread_lock);
			g_sleep_time = refresh_rate;
			pthread_mutex_unlock(&g_thread_lock);
			stop_loop = true;
			break;
		}
@@ -2733,6 +2735,7 @@ static void *
data_thread_routine(void *arg)
{
	int rc;
	uint64_t refresh_rate;

	while (1) {
		pthread_mutex_lock(&g_thread_lock);
@@ -2740,6 +2743,13 @@ data_thread_routine(void *arg)
			pthread_mutex_unlock(&g_thread_lock);
			break;
		}

		if (g_sleep_time == 0) {
			/* Give display thread time to redraw all windows */
			refresh_rate = SPDK_SEC_TO_USEC / 100;
		} else {
			refresh_rate = g_sleep_time * SPDK_SEC_TO_USEC;
		}
		pthread_mutex_unlock(&g_thread_lock);

		/* Get data from RPC for each object type.
@@ -2762,7 +2772,7 @@ data_thread_routine(void *arg)
			print_bottom_message("ERROR occurred while getting scheduler data");
		}

		usleep(g_sleep_time * SPDK_SEC_TO_USEC);
		usleep(refresh_rate);
	}

	return NULL;