Commit e6531062 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/event: accumulate idle_tsc when reactor has no threads



Before this patch idle_tsc was sum of all idle tsc of all
threads running on a reactor.

There are cases when no threads are present on the reactor,
and _reactor_run() spins doing nothing.

To give more accurate representation of the reactors state,
the idle_tsc now adds time spent doing idle spinning.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: If797b2a03507d17b07367d56d5f6c40cefbbbd49
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7900


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent a5ad0f80
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -908,7 +908,9 @@ _reactor_run(struct spdk_reactor *reactor)
	 * tsc_last gets outdated. Update it to track
	 * thread execution time correctly. */
	if (spdk_unlikely(TAILQ_EMPTY(&reactor->threads))) {
		reactor->tsc_last = spdk_get_ticks();
		now = spdk_get_ticks();
		reactor->idle_tsc += now - reactor->tsc_last;
		reactor->tsc_last = now;
		return;
	}

+2 −2
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ test_reactor_stats(void)
	 * Then,
	 * - elapsed TSC of thread1 should be 2100 (= 2000+ 100).
	 * - busy TSC of reactor should be 600 (= 500 + 100).
	 * - idle TSC of reactor should be 500 (= 500 + 0).
	 * - idle TSC of reactor should be 500 (= 500 + 900).
	 */

	MOCK_SET(spdk_env_get_current_core, 0);
@@ -494,7 +494,7 @@ test_reactor_stats(void)
	CU_ASSERT(stats.idle_tsc == 0);

	CU_ASSERT(reactor->busy_tsc == 600);
	CU_ASSERT(reactor->idle_tsc == 500);
	CU_ASSERT(reactor->idle_tsc == 1400);

	/* 2000 + 100 = 2100 ticks elapsed */
	CU_ASSERT(reactor->tsc_last == 2100);