diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index d54f70cbf..542e26620 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -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 */ diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 9227c7d21..73a001931 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -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)