Commit ee4a8336 authored by Liu Xiaodong's avatar Liu Xiaodong Committed by Tomasz Zawadzki
Browse files

reactor: update tsc records in intr mode



In interrupt mode, reactor spends its valid cpu cycles
to process registered thread interrupt function. So we
can count idle_tsc and busy_tsc in it, and update
reactor's last_tsc in it.

Change-Id: I65f4ae7d3b1e5c7c5c06937d6855f5d1b5c0349f
Signed-off-by: default avatarLiu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6716


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 4825fce4
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -872,7 +872,7 @@ reactor_interrupt_run(struct spdk_reactor *reactor)

	spdk_fd_group_wait(reactor->fgrp, block_timeout);

	/* TODO: add tsc records and g_framework_context_switch_monitor_enabled */
	/* TODO: g_framework_context_switch_monitor_enabled */
}

static void
@@ -1076,8 +1076,27 @@ static int
thread_process_interrupts(void *arg)
{
	struct spdk_thread *thread = arg;
	struct spdk_reactor *reactor = spdk_reactor_get(spdk_env_get_current_core());
	uint64_t now;
	int rc;

	/* Update idle_tsc between the end of last intr_fn and the start of this intr_fn. */
	now = spdk_get_ticks();
	reactor->idle_tsc += now - reactor->tsc_last;
	reactor->tsc_last = now;

	rc = spdk_thread_poll(thread, 0, now);

	/* Update tsc between the start and the end of this intr_fn. */
	now = spdk_thread_get_last_tsc(thread);
	if (rc == 0) {
		reactor->idle_tsc += now - reactor->tsc_last;
	} else if (rc > 0) {
		reactor->busy_tsc += now - reactor->tsc_last;
	}
	reactor->tsc_last = now;

	return spdk_thread_poll(thread, 0, 0);
	return rc;
}

static void