Commit 0d8a4af8 authored by Maciej Szwed's avatar Maciej Szwed Committed by Tomasz Zawadzki
Browse files

event: Add lw_thread helper functions required for scheduler

parent 2a146cd9
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -248,6 +248,24 @@ static void __attribute__((constructor)) _spdk_scheduler_register_##name(void) \
	spdk_scheduler_list_add(scheduler); \
} \

/**
 * Set new CPU core index. Used for scheduling, assigns new CPU core index and marks it =
 * for rescheduling - does not actually change it. Can be used with SPDK_ENV_LCORE_ID_ANY
 *
 * \param thread thread to change core.
 * \param lcore new CPU core index.
 */
void _spdk_lw_thread_set_core(struct spdk_lw_thread *thread, uint32_t lcore);

/**
 * Get threads stats
 *
 * \param thread thread that stats regards to.
 * \param stats Output parameter for accumulated TSC counts while the thread was busy.
 */
void _spdk_lw_thread_get_current_stats(struct spdk_lw_thread *thread,
				       struct spdk_thread_stats *stats);

/**
 * \brief Register a new subsystem
 */
+16 −4
Original line number Diff line number Diff line
@@ -738,10 +738,7 @@ _reactor_request_thread_reschedule(struct spdk_thread *thread)

	lw_thread = spdk_thread_get_ctx(thread);

	assert(lw_thread != NULL);

	lw_thread->resched = true;
	lw_thread->lcore = SPDK_ENV_LCORE_ID_ANY;
	_spdk_lw_thread_set_core(lw_thread, SPDK_ENV_LCORE_ID_ANY);

	current_core = spdk_env_get_current_core();
	reactor = spdk_reactor_get(current_core);
@@ -942,4 +939,19 @@ reactor_interrupt_fini(struct spdk_reactor *reactor)
	reactor->fgrp = NULL;
}

void
_spdk_lw_thread_set_core(struct spdk_lw_thread *thread, uint32_t lcore)
{
	assert(thread != NULL);
	thread->lcore = lcore;
	thread->resched = true;
}

void
_spdk_lw_thread_get_current_stats(struct spdk_lw_thread *thread, struct spdk_thread_stats *stats)
{
	assert(thread != NULL);
	*stats = thread->current_stats;
}

SPDK_LOG_REGISTER_COMPONENT(reactor)