aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hrtimer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hrtimer.h')
-rw-r--r--include/linux/hrtimer.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 76dd4f0da5ca..2ead22dd74a0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -87,7 +87,8 @@ enum hrtimer_restart {
87 * @function: timer expiry callback function 87 * @function: timer expiry callback function
88 * @base: pointer to the timer base (per cpu and per clock) 88 * @base: pointer to the timer base (per cpu and per clock)
89 * @state: state information (See bit values above) 89 * @state: state information (See bit values above)
90 * @start_pid: timer statistics field to store the pid of the task which 90 * @is_rel: Set if the timer was armed relative
91 * @start_pid: timer statistics field to store the pid of the task which
91 * started the timer 92 * started the timer
92 * @start_site: timer statistics field to store the site where the timer 93 * @start_site: timer statistics field to store the site where the timer
93 * was started 94 * was started
@@ -101,7 +102,8 @@ struct hrtimer {
101 ktime_t _softexpires; 102 ktime_t _softexpires;
102 enum hrtimer_restart (*function)(struct hrtimer *); 103 enum hrtimer_restart (*function)(struct hrtimer *);
103 struct hrtimer_clock_base *base; 104 struct hrtimer_clock_base *base;
104 unsigned long state; 105 u8 state;
106 u8 is_rel;
105#ifdef CONFIG_TIMER_STATS 107#ifdef CONFIG_TIMER_STATS
106 int start_pid; 108 int start_pid;
107 void *start_site; 109 void *start_site;
@@ -321,6 +323,27 @@ static inline void clock_was_set_delayed(void) { }
321 323
322#endif 324#endif
323 325
326static inline ktime_t
327__hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
328{
329 ktime_t rem = ktime_sub(timer->node.expires, now);
330
331 /*
332 * Adjust relative timers for the extra we added in
333 * hrtimer_start_range_ns() to prevent short timeouts.
334 */
335 if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel)
336 rem.tv64 -= hrtimer_resolution;
337 return rem;
338}
339
340static inline ktime_t
341hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
342{
343 return __hrtimer_expires_remaining_adjusted(timer,
344 timer->base->get_time());
345}
346
324extern void clock_was_set(void); 347extern void clock_was_set(void);
325#ifdef CONFIG_TIMERFD 348#ifdef CONFIG_TIMERFD
326extern void timerfd_clock_was_set(void); 349extern void timerfd_clock_was_set(void);
@@ -390,7 +413,12 @@ static inline void hrtimer_restart(struct hrtimer *timer)
390} 413}
391 414
392/* Query timers: */ 415/* Query timers: */
393extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer); 416extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust);
417
418static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
419{
420 return __hrtimer_get_remaining(timer, false);
421}
394 422
395extern u64 hrtimer_get_next_event(void); 423extern u64 hrtimer_get_next_event(void);
396 424