21 #ifndef _XENO_NUCLEUS_STAT_H
22 #define _XENO_NUCLEUS_STAT_H
24 #include <nucleus/types.h>
26 #ifdef CONFIG_XENO_OPT_STATS
28 typedef struct xnstat_exectime {
38 #define xnstat_exectime_now() xnarch_get_cpu_tsc()
41 #define xnstat_exectime_update(sched, date) \
43 (sched)->current_account->total += \
44 date - (sched)->last_account_switch; \
45 (sched)->last_account_switch = date; \
48 xnarch_memory_barrier(); \
52 #define xnstat_exectime_set_current(sched, new_account) \
54 xnstat_exectime_t *__prev; \
55 __prev = xnarch_atomic_xchg(&(sched)->current_account, (new_account)); \
60 #define xnstat_exectime_get_current(sched) ((sched)->current_account)
64 #define xnstat_exectime_finalize(sched, new_account) \
66 (sched)->last_account_switch = xnarch_get_cpu_tsc(); \
67 (sched)->current_account = (new_account); \
71 #define xnstat_exectime_get_start(account) ((account)->start)
72 #define xnstat_exectime_get_total(account) ((account)->total)
75 #define xnstat_exectime_get_last_switch(sched) ((sched)->last_account_switch)
79 #define xnstat_exectime_reset_stats(stat) \
82 (stat)->start = xnarch_get_cpu_tsc(); \
86 typedef struct xnstat_counter {
87 unsigned long counter;
90 static inline unsigned long xnstat_counter_inc(xnstat_counter_t *c)
95 static inline unsigned long xnstat_counter_get(xnstat_counter_t *c)
100 static inline void xnstat_counter_set(xnstat_counter_t *c,
unsigned long value)
106 typedef struct xnstat_exectime {
112 #define xnstat_exectime_now() ({ 0; })
113 #define xnstat_exectime_update(sched, date) do { } while (0)
114 #define xnstat_exectime_set_current(sched, new_account) ({ (void)sched; NULL; })
115 #define xnstat_exectime_get_current(sched) ({ (void)sched; NULL; })
116 #define xnstat_exectime_finalize(sched, new_account) do { } while (0)
117 #define xnstat_exectime_get_start(account) ({ 0; })
118 #define xnstat_exectime_get_total(account) ({ 0; })
119 #define xnstat_exectime_get_last_switch(sched) ({ 0; })
120 #define xnstat_exectime_reset_stats(account) do { } while (0)
122 typedef struct xnstat_counter {
128 #define xnstat_counter_inc(c) ({ do { } while(0); 0; })
129 #define xnstat_counter_get(c) ({ 0; })
130 #define xnstat_counter_set(c, value) do { } while (0)
135 #define xnstat_exectime_switch(sched, new_account) \
137 xnstat_exectime_update(sched, xnstat_exectime_now()); \
138 xnstat_exectime_set_current(sched, new_account); \
143 #define xnstat_exectime_lazy_switch(sched, new_account, date) \
145 xnstat_exectime_update(sched, date); \
146 xnstat_exectime_set_current(sched, new_account); \