lib/event: remove snapshot_stats

spdk_thread keeps track of tsc from its whole lifetime,
those can be requested with spdk_thread_get_stats() at any time.

spdk_lw_thread uses stats from above and keeps track of two points in time:
- current_stats reflecting stats at the time of gather_metrics stage
- last_stats reflecting stats from previous gather_metrics stage

1)
Before this patch current_stats were duplicated in snapshot_stats.
There is no need for that so now they are removed.

2)
Removed _spdk_lw_thread_get_current_stats() since it would be copying
current_stats to current_stats, thus not perform any action.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I5e5d4039cd0f7cc10ba150a3d915b90ec96589d7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7842
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Tomasz Zawadzki 2021-05-11 06:05:55 -04:00
parent 0598e484d7
commit e0d448e7f6
3 changed files with 5 additions and 23 deletions

View File

@ -67,7 +67,6 @@ struct spdk_lw_thread {
uint32_t new_lcore;
bool resched;
struct spdk_thread_stats current_stats;
struct spdk_thread_stats snapshot_stats;
struct spdk_thread_stats last_stats;
};
@ -355,15 +354,6 @@ static void __attribute__((constructor)) _spdk_scheduler_register_ ## scheduler
*/
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);
#ifdef __cplusplus
}
#endif

View File

@ -818,7 +818,6 @@ _reactors_scheduler_gather_metrics(void *arg1, void *arg2)
i = 0;
TAILQ_FOREACH(lw_thread, &reactor->threads, link) {
core_info->threads[i] = lw_thread;
_spdk_lw_thread_get_current_stats(lw_thread, &lw_thread->snapshot_stats);
i++;
}
}
@ -1481,13 +1480,6 @@ _spdk_lw_thread_set_core(struct spdk_lw_thread *thread, uint32_t 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;
}
static int
_governor_get_capabilities(uint32_t lcore_id, struct spdk_governor_capabilities *capabilities)
{

View File

@ -68,11 +68,11 @@ _get_thread_load(struct spdk_lw_thread *lw_thread)
{
uint64_t busy, idle;
busy = lw_thread->snapshot_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
idle = lw_thread->snapshot_stats.idle_tsc - lw_thread->last_stats.idle_tsc;
busy = lw_thread->current_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
idle = lw_thread->current_stats.idle_tsc - lw_thread->last_stats.idle_tsc;
lw_thread->last_stats.busy_tsc = lw_thread->snapshot_stats.busy_tsc;
lw_thread->last_stats.idle_tsc = lw_thread->snapshot_stats.idle_tsc;
lw_thread->last_stats.busy_tsc = lw_thread->current_stats.busy_tsc;
lw_thread->last_stats.idle_tsc = lw_thread->current_stats.idle_tsc;
if (busy == 0) {
/* No work was done, exit before possible division by 0. */
@ -161,7 +161,7 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
thread = spdk_thread_get_from_ctx(lw_thread);
cpumask = spdk_thread_get_cpumask(thread);
thread_busy = lw_thread->snapshot_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
thread_busy = lw_thread->current_stats.busy_tsc - lw_thread->last_stats.busy_tsc;
load = _get_thread_load(lw_thread);