* [PATCH] cobalt: Avoid reading time twice via xnstat_exectime_update
@ 2021-03-15 16:02 Jan Kiszka
0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2021-03-15 16:02 UTC (permalink / raw)
To: Xenomai
From: Jan Kiszka <jan.kiszka@siemens.com>
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 <jan.kiszka@siemens.com>
---
include/cobalt/kernel/stat.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/cobalt/kernel/stat.h b/include/cobalt/kernel/stat.h
index b08567b41c..3c059a54ff 100644
--- a/include/cobalt/kernel/stat.h
+++ b/include/cobalt/kernel/stat.h
@@ -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(); \
--
2.26.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-15 16:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 16:02 [PATCH] cobalt: Avoid reading time twice via xnstat_exectime_update Jan Kiszka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.