cobalt: Avoid reading time twice via xnstat_exectime_update
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.
Signed-off-by Jan Kiszka <[email protected]>
--- include/cobalt/kernel/stat.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/cobalt/kernel/stat.h +3 -2
@@ -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