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: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: If797b2a03507d17b07367d56d5f6c40cefbbbd49 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7900 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
a5ad0f8051
commit
e65310624b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user