From 317058e95a1add7006285a4d19082d281835dc62 Mon Sep 17 00:00:00 2001 From: Narate Taerat Date: Thu, 21 Nov 2024 22:34:20 -0600 Subject: [PATCH] Fix ovis_event thrstat calculation When `__thrstat_wait_start()` was called, the caller was going into INACTIVE state from ACTIVE state. Hence, the duration from `wait_end` to `now` was the active time and should be added to `proc_tot`. Likewise, when `__thrstat_wait_end()` was called, the caller just woke up. Hence, the duration from `wait_start` to `now` was an INACTIVE time and should be added to `wait_tot`. --- lib/src/ovis_event/ovis_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/ovis_event/ovis_event.c b/lib/src/ovis_event/ovis_event.c index 4304af086..77339e513 100644 --- a/lib/src/ovis_event/ovis_event.c +++ b/lib/src/ovis_event/ovis_event.c @@ -664,7 +664,7 @@ static void __thrstat_wait_start(ovis_event_thrstat_t stats) clock_gettime(CLOCK_REALTIME, &now); stats->wait_start = now; - stats->wait_tot += __timespec_diff_us(&stats->wait_end, &now); + stats->proc_tot += __timespec_diff_us(&stats->wait_end, &now); stats->waiting = 1; } @@ -673,7 +673,7 @@ static void __thrstat_wait_end(ovis_event_thrstat_t stats) struct timespec now; clock_gettime(CLOCK_REALTIME, &now); stats->wait_end = now; - stats->proc_tot += __timespec_diff_us(&stats->wait_start, &now); + stats->wait_tot += __timespec_diff_us(&stats->wait_start, &now); stats->waiting = 0; }