Commit 80a13be9 authored by Maciej Szwed's avatar Maciej Szwed Committed by Tomasz Zawadzki
Browse files

event: Save thread stats to last_stats field in spdk_lw_thread structure



This field will be used in upcoming patches
by scheduler to keep a history of threads
statistics. Base on those scheduler will
be able to calculate how busy a thread is.

Also we have to save the value of this field
while rescheduling thread.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: Iffbd1f946e1d159ec7277a39bc30161e71722456
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5972


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
parent aa22321a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ struct spdk_lw_thread {
	bool				resched;
	struct spdk_thread_stats	current_stats;
	struct spdk_thread_stats	snapshot_stats;
	struct spdk_thread_stats	last_stats;
};

struct spdk_reactor {
+3 −0
Original line number Diff line number Diff line
@@ -910,6 +910,7 @@ _reactor_schedule_thread(struct spdk_thread *thread)
{
	uint32_t core;
	struct spdk_lw_thread *lw_thread;
	struct spdk_thread_stats last_stats;
	struct spdk_event *evt = NULL;
	struct spdk_cpuset *cpumask;
	uint32_t i;
@@ -919,7 +920,9 @@ _reactor_schedule_thread(struct spdk_thread *thread)
	lw_thread = spdk_thread_get_ctx(thread);
	assert(lw_thread != NULL);
	core = lw_thread->lcore;
	last_stats = lw_thread->last_stats;
	memset(lw_thread, 0, sizeof(*lw_thread));
	lw_thread->last_stats = last_stats;

	pthread_mutex_lock(&g_scheduler_mtx);
	if (core == SPDK_ENV_LCORE_ID_ANY) {