1c0a31329SThomas Gleixner /* 2c0a31329SThomas Gleixner * include/linux/hrtimer.h 3c0a31329SThomas Gleixner * 4c0a31329SThomas Gleixner * hrtimers - High-resolution kernel timers 5c0a31329SThomas Gleixner * 6c0a31329SThomas Gleixner * Copyright(C) 2005, Thomas Gleixner <[email protected]> 7c0a31329SThomas Gleixner * Copyright(C) 2005, Red Hat, Inc., Ingo Molnar 8c0a31329SThomas Gleixner * 9c0a31329SThomas Gleixner * data type definitions, declarations, prototypes 10c0a31329SThomas Gleixner * 11c0a31329SThomas Gleixner * Started by: Thomas Gleixner and Ingo Molnar 12c0a31329SThomas Gleixner * 13c0a31329SThomas Gleixner * For licencing details see kernel-base/COPYING 14c0a31329SThomas Gleixner */ 15c0a31329SThomas Gleixner #ifndef _LINUX_HRTIMER_H 16c0a31329SThomas Gleixner #define _LINUX_HRTIMER_H 17c0a31329SThomas Gleixner 18c0a31329SThomas Gleixner #include <linux/rbtree.h> 19c0a31329SThomas Gleixner #include <linux/ktime.h> 20c0a31329SThomas Gleixner #include <linux/init.h> 21c0a31329SThomas Gleixner #include <linux/list.h> 22c0a31329SThomas Gleixner #include <linux/wait.h> 23c0a31329SThomas Gleixner 243c8aa39dSThomas Gleixner struct hrtimer_clock_base; 253c8aa39dSThomas Gleixner struct hrtimer_cpu_base; 263c8aa39dSThomas Gleixner 27c0a31329SThomas Gleixner /* 28c0a31329SThomas Gleixner * Mode arguments of xxx_hrtimer functions: 29c0a31329SThomas Gleixner */ 30c0a31329SThomas Gleixner enum hrtimer_mode { 31c9cb2e3dSThomas Gleixner HRTIMER_MODE_ABS, /* Time value is absolute */ 32c9cb2e3dSThomas Gleixner HRTIMER_MODE_REL, /* Time value is relative to now */ 33c0a31329SThomas Gleixner }; 34c0a31329SThomas Gleixner 35c9cb2e3dSThomas Gleixner /* 36c9cb2e3dSThomas Gleixner * Return values for the callback function 37c9cb2e3dSThomas Gleixner */ 38c0a31329SThomas Gleixner enum hrtimer_restart { 39c9cb2e3dSThomas Gleixner HRTIMER_NORESTART, /* Timer is not restarted */ 40c9cb2e3dSThomas Gleixner HRTIMER_RESTART, /* Timer must be restarted */ 41c0a31329SThomas Gleixner }; 42c0a31329SThomas Gleixner 43303e967fSThomas Gleixner /* 4454cdfdb4SThomas Gleixner * hrtimer callback modes: 4554cdfdb4SThomas Gleixner * 4654cdfdb4SThomas Gleixner * HRTIMER_CB_SOFTIRQ: Callback must run in softirq context 4754cdfdb4SThomas Gleixner * HRTIMER_CB_IRQSAFE: Callback may run in hardirq context 4854cdfdb4SThomas Gleixner * HRTIMER_CB_IRQSAFE_NO_RESTART: Callback may run in hardirq context and 4954cdfdb4SThomas Gleixner * does not restart the timer 508437fdc7SAndres Salomon * HRTIMER_CB_IRQSAFE_NO_SOFTIRQ: Callback must run in hardirq context 5154cdfdb4SThomas Gleixner * Special mode for tick emultation 5254cdfdb4SThomas Gleixner */ 5354cdfdb4SThomas Gleixner enum hrtimer_cb_mode { 5454cdfdb4SThomas Gleixner HRTIMER_CB_SOFTIRQ, 5554cdfdb4SThomas Gleixner HRTIMER_CB_IRQSAFE, 5654cdfdb4SThomas Gleixner HRTIMER_CB_IRQSAFE_NO_RESTART, 5754cdfdb4SThomas Gleixner HRTIMER_CB_IRQSAFE_NO_SOFTIRQ, 5854cdfdb4SThomas Gleixner }; 5954cdfdb4SThomas Gleixner 6054cdfdb4SThomas Gleixner /* 6154cdfdb4SThomas Gleixner * Values to track state of the timer 62303e967fSThomas Gleixner * 63303e967fSThomas Gleixner * Possible states: 64303e967fSThomas Gleixner * 65303e967fSThomas Gleixner * 0x00 inactive 66303e967fSThomas Gleixner * 0x01 enqueued into rbtree 67303e967fSThomas Gleixner * 0x02 callback function running 6854cdfdb4SThomas Gleixner * 0x04 callback pending (high resolution mode) 6954cdfdb4SThomas Gleixner * 7054cdfdb4SThomas Gleixner * Special case: 71303e967fSThomas Gleixner * 0x03 callback function running and enqueued 72303e967fSThomas Gleixner * (was requeued on another CPU) 73303e967fSThomas Gleixner * The "callback function running and enqueued" status is only possible on 74303e967fSThomas Gleixner * SMP. It happens for example when a posix timer expired and the callback 75303e967fSThomas Gleixner * queued a signal. Between dropping the lock which protects the posix timer 76303e967fSThomas Gleixner * and reacquiring the base lock of the hrtimer, another CPU can deliver the 77303e967fSThomas Gleixner * signal and rearm the timer. We have to preserve the callback running state, 78303e967fSThomas Gleixner * as otherwise the timer could be removed before the softirq code finishes the 79303e967fSThomas Gleixner * the handling of the timer. 80303e967fSThomas Gleixner * 81303e967fSThomas Gleixner * The HRTIMER_STATE_ENQUEUE bit is always or'ed to the current state to 82303e967fSThomas Gleixner * preserve the HRTIMER_STATE_CALLBACK bit in the above scenario. 83303e967fSThomas Gleixner * 84303e967fSThomas Gleixner * All state transitions are protected by cpu_base->lock. 85303e967fSThomas Gleixner */ 86303e967fSThomas Gleixner #define HRTIMER_STATE_INACTIVE 0x00 87303e967fSThomas Gleixner #define HRTIMER_STATE_ENQUEUED 0x01 88303e967fSThomas Gleixner #define HRTIMER_STATE_CALLBACK 0x02 8954cdfdb4SThomas Gleixner #define HRTIMER_STATE_PENDING 0x04 90303e967fSThomas Gleixner 91c0a31329SThomas Gleixner /** 92c0a31329SThomas Gleixner * struct hrtimer - the basic hrtimer structure 93c0a31329SThomas Gleixner * @node: red black tree node for time ordered insertion 94c0a31329SThomas Gleixner * @expires: the absolute expiry time in the hrtimers internal 95c0a31329SThomas Gleixner * representation. The time is related to the clock on 96c0a31329SThomas Gleixner * which the timer is based. 97c0a31329SThomas Gleixner * @function: timer expiry callback function 98c0a31329SThomas Gleixner * @base: pointer to the timer base (per cpu and per clock) 99303e967fSThomas Gleixner * @state: state information (See bit values above) 10054cdfdb4SThomas Gleixner * @cb_mode: high resolution timer feature to select the callback execution 10154cdfdb4SThomas Gleixner * mode 10254cdfdb4SThomas Gleixner * @cb_entry: list head to enqueue an expired timer into the callback list 10354cdfdb4SThomas Gleixner * @start_site: timer statistics field to store the site where the timer 10454cdfdb4SThomas Gleixner * was started 10554cdfdb4SThomas Gleixner * @start_comm: timer statistics field to store the name of the process which 10654cdfdb4SThomas Gleixner * started the timer 10754cdfdb4SThomas Gleixner * @start_pid: timer statistics field to store the pid of the task which 10854cdfdb4SThomas Gleixner * started the timer 109c0a31329SThomas Gleixner * 11054cdfdb4SThomas Gleixner * The hrtimer structure must be initialized by hrtimer_init() 111c0a31329SThomas Gleixner */ 112c0a31329SThomas Gleixner struct hrtimer { 113c0a31329SThomas Gleixner struct rb_node node; 114c0a31329SThomas Gleixner ktime_t expires; 115c9cb2e3dSThomas Gleixner enum hrtimer_restart (*function)(struct hrtimer *); 1163c8aa39dSThomas Gleixner struct hrtimer_clock_base *base; 117303e967fSThomas Gleixner unsigned long state; 11854cdfdb4SThomas Gleixner enum hrtimer_cb_mode cb_mode; 11954cdfdb4SThomas Gleixner struct list_head cb_entry; 12082f67cd9SIngo Molnar #ifdef CONFIG_TIMER_STATS 12182f67cd9SIngo Molnar void *start_site; 12282f67cd9SIngo Molnar char start_comm[16]; 12382f67cd9SIngo Molnar int start_pid; 12482f67cd9SIngo Molnar #endif 125c0a31329SThomas Gleixner }; 126c0a31329SThomas Gleixner 127c0a31329SThomas Gleixner /** 12800362e33SThomas Gleixner * struct hrtimer_sleeper - simple sleeper structure 12900362e33SThomas Gleixner * @timer: embedded timer structure 13000362e33SThomas Gleixner * @task: task to wake up 13100362e33SThomas Gleixner * 13200362e33SThomas Gleixner * task is set to NULL, when the timer expires. 13300362e33SThomas Gleixner */ 13400362e33SThomas Gleixner struct hrtimer_sleeper { 13500362e33SThomas Gleixner struct hrtimer timer; 13600362e33SThomas Gleixner struct task_struct *task; 13700362e33SThomas Gleixner }; 13800362e33SThomas Gleixner 13900362e33SThomas Gleixner /** 140d1d67174SAndres Salomon * struct hrtimer_clock_base - the timer base for a specific clock 14105fb6bf0SRandy Dunlap * @cpu_base: per cpu clock base 1423c8aa39dSThomas Gleixner * @index: clock type index for per_cpu support when moving a 1433c8aa39dSThomas Gleixner * timer to a base on another cpu. 144c0a31329SThomas Gleixner * @active: red black tree root node for the active timers 145288867ecSThomas Gleixner * @first: pointer to the timer node which expires first 146c0a31329SThomas Gleixner * @resolution: the resolution of the clock, in nanoseconds 147c0a31329SThomas Gleixner * @get_time: function to retrieve the current time of the clock 148a580290cSMartin Waitz * @get_softirq_time: function to retrieve the current time from the softirq 14992127c7aSThomas Gleixner * @softirq_time: the time when running the hrtimer queue in the softirq 15054cdfdb4SThomas Gleixner * @offset: offset of this clock to the monotonic base 15154cdfdb4SThomas Gleixner * @reprogram: function to reprogram the timer event 152c0a31329SThomas Gleixner */ 1533c8aa39dSThomas Gleixner struct hrtimer_clock_base { 1543c8aa39dSThomas Gleixner struct hrtimer_cpu_base *cpu_base; 155c0a31329SThomas Gleixner clockid_t index; 156c0a31329SThomas Gleixner struct rb_root active; 157288867ecSThomas Gleixner struct rb_node *first; 158e2787630SThomas Gleixner ktime_t resolution; 159c0a31329SThomas Gleixner ktime_t (*get_time)(void); 16092127c7aSThomas Gleixner ktime_t (*get_softirq_time)(void); 16192127c7aSThomas Gleixner ktime_t softirq_time; 16254cdfdb4SThomas Gleixner #ifdef CONFIG_HIGH_RES_TIMERS 16354cdfdb4SThomas Gleixner ktime_t offset; 16454cdfdb4SThomas Gleixner int (*reprogram)(struct hrtimer *t, 16554cdfdb4SThomas Gleixner struct hrtimer_clock_base *b, 16654cdfdb4SThomas Gleixner ktime_t n); 16754cdfdb4SThomas Gleixner #endif 1683c8aa39dSThomas Gleixner }; 1693c8aa39dSThomas Gleixner 1703c8aa39dSThomas Gleixner #define HRTIMER_MAX_CLOCK_BASES 2 1713c8aa39dSThomas Gleixner 1723c8aa39dSThomas Gleixner /* 1733c8aa39dSThomas Gleixner * struct hrtimer_cpu_base - the per cpu clock bases 1743c8aa39dSThomas Gleixner * @lock: lock protecting the base and associated clock bases 1753c8aa39dSThomas Gleixner * and timers 1763c8aa39dSThomas Gleixner * @lock_key: the lock_class_key for use with lockdep 1773c8aa39dSThomas Gleixner * @clock_base: array of clock bases for this cpu 1783c8aa39dSThomas Gleixner * @curr_timer: the timer which is executing a callback right now 17954cdfdb4SThomas Gleixner * @expires_next: absolute time of the next event which was scheduled 18054cdfdb4SThomas Gleixner * via clock_set_next_event() 18154cdfdb4SThomas Gleixner * @hres_active: State of high resolution mode 18254cdfdb4SThomas Gleixner * @check_clocks: Indictator, when set evaluate time source and clock 18354cdfdb4SThomas Gleixner * event devices whether high resolution mode can be 18454cdfdb4SThomas Gleixner * activated. 18554cdfdb4SThomas Gleixner * @cb_pending: Expired timers are moved from the rbtree to this 18654cdfdb4SThomas Gleixner * list in the timer interrupt. The list is processed 18754cdfdb4SThomas Gleixner * in the softirq. 18854cdfdb4SThomas Gleixner * @nr_events: Total number of timer interrupt events 1893c8aa39dSThomas Gleixner */ 1903c8aa39dSThomas Gleixner struct hrtimer_cpu_base { 1913c8aa39dSThomas Gleixner spinlock_t lock; 19254365524SIngo Molnar struct lock_class_key lock_key; 1933c8aa39dSThomas Gleixner struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 194d3d74453SPeter Zijlstra struct list_head cb_pending; 19554cdfdb4SThomas Gleixner #ifdef CONFIG_HIGH_RES_TIMERS 19654cdfdb4SThomas Gleixner ktime_t expires_next; 19754cdfdb4SThomas Gleixner int hres_active; 19854cdfdb4SThomas Gleixner unsigned long nr_events; 19954cdfdb4SThomas Gleixner #endif 200c0a31329SThomas Gleixner }; 201c0a31329SThomas Gleixner 20254cdfdb4SThomas Gleixner #ifdef CONFIG_HIGH_RES_TIMERS 20354cdfdb4SThomas Gleixner struct clock_event_device; 20454cdfdb4SThomas Gleixner 20554cdfdb4SThomas Gleixner extern void clock_was_set(void); 206995f054fSIngo Molnar extern void hres_timers_resume(void); 20754cdfdb4SThomas Gleixner extern void hrtimer_interrupt(struct clock_event_device *dev); 20854cdfdb4SThomas Gleixner 20954cdfdb4SThomas Gleixner /* 21054cdfdb4SThomas Gleixner * In high resolution mode the time reference must be read accurate 21154cdfdb4SThomas Gleixner */ 21254cdfdb4SThomas Gleixner static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer) 21354cdfdb4SThomas Gleixner { 21454cdfdb4SThomas Gleixner return timer->base->get_time(); 21554cdfdb4SThomas Gleixner } 21654cdfdb4SThomas Gleixner 2178f4d37ecSPeter Zijlstra static inline int hrtimer_is_hres_active(struct hrtimer *timer) 2188f4d37ecSPeter Zijlstra { 2198f4d37ecSPeter Zijlstra return timer->base->cpu_base->hres_active; 2208f4d37ecSPeter Zijlstra } 2218f4d37ecSPeter Zijlstra 22254cdfdb4SThomas Gleixner /* 22354cdfdb4SThomas Gleixner * The resolution of the clocks. The resolution value is returned in 22454cdfdb4SThomas Gleixner * the clock_getres() system call to give application programmers an 22554cdfdb4SThomas Gleixner * idea of the (in)accuracy of timers. Timer values are rounded up to 22654cdfdb4SThomas Gleixner * this resolution values. 22754cdfdb4SThomas Gleixner */ 228*151db1fcSTony Breeds # define HIGH_RES_NSEC 1 229*151db1fcSTony Breeds # define KTIME_HIGH_RES (ktime_t) { .tv64 = HIGH_RES_NSEC } 230*151db1fcSTony Breeds # define MONOTONIC_RES_NSEC HIGH_RES_NSEC 23154cdfdb4SThomas Gleixner # define KTIME_MONOTONIC_RES KTIME_HIGH_RES 23254cdfdb4SThomas Gleixner 23354cdfdb4SThomas Gleixner #else 23454cdfdb4SThomas Gleixner 235*151db1fcSTony Breeds # define MONOTONIC_RES_NSEC LOW_RES_NSEC 23654cdfdb4SThomas Gleixner # define KTIME_MONOTONIC_RES KTIME_LOW_RES 23754cdfdb4SThomas Gleixner 238becf8b5dSThomas Gleixner /* 239becf8b5dSThomas Gleixner * clock_was_set() is a NOP for non- high-resolution systems. The 240becf8b5dSThomas Gleixner * time-sorted order guarantees that a timer does not expire early and 241becf8b5dSThomas Gleixner * is expired in the next softirq when the clock was advanced. 242becf8b5dSThomas Gleixner */ 24354cdfdb4SThomas Gleixner static inline void clock_was_set(void) { } 24454cdfdb4SThomas Gleixner 245995f054fSIngo Molnar static inline void hres_timers_resume(void) { } 246995f054fSIngo Molnar 24754cdfdb4SThomas Gleixner /* 24854cdfdb4SThomas Gleixner * In non high resolution mode the time reference is taken from 24954cdfdb4SThomas Gleixner * the base softirq time variable. 25054cdfdb4SThomas Gleixner */ 25154cdfdb4SThomas Gleixner static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer) 25254cdfdb4SThomas Gleixner { 25354cdfdb4SThomas Gleixner return timer->base->softirq_time; 25454cdfdb4SThomas Gleixner } 25554cdfdb4SThomas Gleixner 2568f4d37ecSPeter Zijlstra static inline int hrtimer_is_hres_active(struct hrtimer *timer) 2578f4d37ecSPeter Zijlstra { 2588f4d37ecSPeter Zijlstra return 0; 2598f4d37ecSPeter Zijlstra } 26054cdfdb4SThomas Gleixner #endif 26154cdfdb4SThomas Gleixner 262d316c57fSThomas Gleixner extern ktime_t ktime_get(void); 263d316c57fSThomas Gleixner extern ktime_t ktime_get_real(void); 264becf8b5dSThomas Gleixner 265c0a31329SThomas Gleixner /* Exported timer functions: */ 266c0a31329SThomas Gleixner 267c0a31329SThomas Gleixner /* Initialize timers: */ 2687978672cSGeorge Anzinger extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, 2697978672cSGeorge Anzinger enum hrtimer_mode mode); 270c0a31329SThomas Gleixner 271c0a31329SThomas Gleixner /* Basic timer operations: */ 272c0a31329SThomas Gleixner extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 273c0a31329SThomas Gleixner const enum hrtimer_mode mode); 274c0a31329SThomas Gleixner extern int hrtimer_cancel(struct hrtimer *timer); 275c0a31329SThomas Gleixner extern int hrtimer_try_to_cancel(struct hrtimer *timer); 276c0a31329SThomas Gleixner 277c9cb2e3dSThomas Gleixner static inline int hrtimer_restart(struct hrtimer *timer) 278c9cb2e3dSThomas Gleixner { 279c9cb2e3dSThomas Gleixner return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); 280c9cb2e3dSThomas Gleixner } 281c0a31329SThomas Gleixner 282c0a31329SThomas Gleixner /* Query timers: */ 283c0a31329SThomas Gleixner extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer); 284c0a31329SThomas Gleixner extern int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp); 285c0a31329SThomas Gleixner 28669239749STony Lindgren extern ktime_t hrtimer_get_next_event(void); 28769239749STony Lindgren 288303e967fSThomas Gleixner /* 289303e967fSThomas Gleixner * A timer is active, when it is enqueued into the rbtree or the callback 290303e967fSThomas Gleixner * function is running. 291303e967fSThomas Gleixner */ 292c0a31329SThomas Gleixner static inline int hrtimer_active(const struct hrtimer *timer) 293c0a31329SThomas Gleixner { 294303e967fSThomas Gleixner return timer->state != HRTIMER_STATE_INACTIVE; 295c0a31329SThomas Gleixner } 296c0a31329SThomas Gleixner 29754cdfdb4SThomas Gleixner /* 29854cdfdb4SThomas Gleixner * Helper function to check, whether the timer is on one of the queues 29954cdfdb4SThomas Gleixner */ 30054cdfdb4SThomas Gleixner static inline int hrtimer_is_queued(struct hrtimer *timer) 30154cdfdb4SThomas Gleixner { 30254cdfdb4SThomas Gleixner return timer->state & 30354cdfdb4SThomas Gleixner (HRTIMER_STATE_ENQUEUED | HRTIMER_STATE_PENDING); 30454cdfdb4SThomas Gleixner } 30554cdfdb4SThomas Gleixner 306c0a31329SThomas Gleixner /* Forward a hrtimer so it expires after now: */ 3074d672e7aSDavide Libenzi extern u64 30844f21475SRoman Zippel hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval); 309c0a31329SThomas Gleixner 3105e05ad7dSDavide Libenzi /* Forward a hrtimer so it expires after the hrtimer's current now */ 3114d672e7aSDavide Libenzi static inline u64 hrtimer_forward_now(struct hrtimer *timer, 3125e05ad7dSDavide Libenzi ktime_t interval) 3135e05ad7dSDavide Libenzi { 3145e05ad7dSDavide Libenzi return hrtimer_forward(timer, timer->base->get_time(), interval); 3155e05ad7dSDavide Libenzi } 3165e05ad7dSDavide Libenzi 31710c94ec1SThomas Gleixner /* Precise sleep: */ 31810c94ec1SThomas Gleixner extern long hrtimer_nanosleep(struct timespec *rqtp, 31904c22714SAnton Blanchard struct timespec *rmtp, 32010c94ec1SThomas Gleixner const enum hrtimer_mode mode, 32110c94ec1SThomas Gleixner const clockid_t clockid); 3221711ef38SToyo Abe extern long hrtimer_nanosleep_restart(struct restart_block *restart_block); 32310c94ec1SThomas Gleixner 32400362e33SThomas Gleixner extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, 32500362e33SThomas Gleixner struct task_struct *tsk); 32600362e33SThomas Gleixner 327c0a31329SThomas Gleixner /* Soft interrupt function to run the hrtimer queues: */ 328c0a31329SThomas Gleixner extern void hrtimer_run_queues(void); 329d3d74453SPeter Zijlstra extern void hrtimer_run_pending(void); 330c0a31329SThomas Gleixner 331c0a31329SThomas Gleixner /* Bootup initialization: */ 332c0a31329SThomas Gleixner extern void __init hrtimers_init(void); 333c0a31329SThomas Gleixner 33479bf2bb3SThomas Gleixner #if BITS_PER_LONG < 64 3354d672e7aSDavide Libenzi extern u64 ktime_divns(const ktime_t kt, s64 div); 33679bf2bb3SThomas Gleixner #else /* BITS_PER_LONG < 64 */ 3374d672e7aSDavide Libenzi # define ktime_divns(kt, div) (u64)((kt).tv64 / (div)) 33879bf2bb3SThomas Gleixner #endif 33979bf2bb3SThomas Gleixner 34088ad0bf6SIngo Molnar /* Show pending timers: */ 34188ad0bf6SIngo Molnar extern void sysrq_timer_list_show(void); 34288ad0bf6SIngo Molnar 34382f67cd9SIngo Molnar /* 34482f67cd9SIngo Molnar * Timer-statistics info: 34582f67cd9SIngo Molnar */ 34682f67cd9SIngo Molnar #ifdef CONFIG_TIMER_STATS 34782f67cd9SIngo Molnar 34882f67cd9SIngo Molnar extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf, 349c5c061b8SVenki Pallipadi void *timerf, char *comm, 350c5c061b8SVenki Pallipadi unsigned int timer_flag); 35182f67cd9SIngo Molnar 35282f67cd9SIngo Molnar static inline void timer_stats_account_hrtimer(struct hrtimer *timer) 35382f67cd9SIngo Molnar { 35482f67cd9SIngo Molnar timer_stats_update_stats(timer, timer->start_pid, timer->start_site, 355c5c061b8SVenki Pallipadi timer->function, timer->start_comm, 0); 35682f67cd9SIngo Molnar } 35782f67cd9SIngo Molnar 35882f67cd9SIngo Molnar extern void __timer_stats_hrtimer_set_start_info(struct hrtimer *timer, 35982f67cd9SIngo Molnar void *addr); 36082f67cd9SIngo Molnar 36182f67cd9SIngo Molnar static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer) 36282f67cd9SIngo Molnar { 36382f67cd9SIngo Molnar __timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0)); 36482f67cd9SIngo Molnar } 36582f67cd9SIngo Molnar 36682f67cd9SIngo Molnar static inline void timer_stats_hrtimer_clear_start_info(struct hrtimer *timer) 36782f67cd9SIngo Molnar { 36882f67cd9SIngo Molnar timer->start_site = NULL; 36982f67cd9SIngo Molnar } 37082f67cd9SIngo Molnar #else 37182f67cd9SIngo Molnar static inline void timer_stats_account_hrtimer(struct hrtimer *timer) 37282f67cd9SIngo Molnar { 37382f67cd9SIngo Molnar } 37482f67cd9SIngo Molnar 37582f67cd9SIngo Molnar static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer) 37682f67cd9SIngo Molnar { 37782f67cd9SIngo Molnar } 37882f67cd9SIngo Molnar 37982f67cd9SIngo Molnar static inline void timer_stats_hrtimer_clear_start_info(struct hrtimer *timer) 38082f67cd9SIngo Molnar { 38182f67cd9SIngo Molnar } 38282f67cd9SIngo Molnar #endif 38382f67cd9SIngo Molnar 384c0a31329SThomas Gleixner #endif 385