Skip to contentSkip to conversation

cobalt: Avoid reading time twice via xnstat_exectime_update

PATCH New Jan Kiszka 1 participant 1 message Mar 15, 2021

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 cobalt: Avoid reading time twice via xnstat_exectime_update

From: Jan Kiszka <[email protected]>

This macro may unroll to instantiating 'date' twice. If that is a call to some get-time function, as via xnstat_exectime_switch, we needlessly do that twice.

---
 include/cobalt/kernel/stat.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/cobalt/kernel/stat.h +3 -2
index b08567b41c..3c059a54ff 100644
@@ -44,9 +44,10 @@ typedef struct xnstat_exectime {
 /* Accumulate exectime of the current account until the given date. */
 #define xnstat_exectime_update(sched, date) \
 do { \
+	xnticks_t __date = date; \
 	(sched)->current_account->total += \
-		date - (sched)->last_account_switch; \
-	(sched)->last_account_switch = date; \
+		__date - (sched)->last_account_switch; \
+	(sched)->last_account_switch = __date; \
 	/* All changes must be committed before changing the current_account \
 	   reference in sched (required for xnintr_sync_stat_references) */ \
 	smp_wmb(); \
Signature · 1 line
2.26.2