Lines Matching full:timer

21 #include <linux/timer.h>
28 * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered
29 * when starting the timer)
30 * HRTIMER_MODE_SOFT - Timer callback function will be executed in
32 * HRTIMER_MODE_HARD - Timer callback function will be executed in
59 * Values to track state of the timer
66 * The callback state is not part of the timer->state because clearing it would
67 * mean touching the timer after the callback, this makes it impossible to free
68 * the timer from the callback function.
72 * timer->base->cpu_base->running == timer
75 * status. It happens for example when a posix timer expired and the callback
76 * queued a signal. Between dropping the lock which protects the posix timer
78 * signal and rearm the timer.
87 * @timer: embedded timer structure
90 * task is set to NULL, when the timer expires.
93 struct hrtimer timer; member
97 static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) in hrtimer_set_expires() argument
99 timer->node.expires = time; in hrtimer_set_expires()
100 timer->_softexpires = time; in hrtimer_set_expires()
103 static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta) in hrtimer_set_expires_range() argument
105 timer->_softexpires = time; in hrtimer_set_expires_range()
106 timer->node.expires = ktime_add_safe(time, delta); in hrtimer_set_expires_range()
109 static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, u64 delta) in hrtimer_set_expires_range_ns() argument
111 timer->_softexpires = time; in hrtimer_set_expires_range_ns()
112 timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta)); in hrtimer_set_expires_range_ns()
115 static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) in hrtimer_set_expires_tv64() argument
117 timer->node.expires = tv64; in hrtimer_set_expires_tv64()
118 timer->_softexpires = tv64; in hrtimer_set_expires_tv64()
121 static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) in hrtimer_add_expires() argument
123 timer->node.expires = ktime_add_safe(timer->node.expires, time); in hrtimer_add_expires()
124 timer->_softexpires = ktime_add_safe(timer->_softexpires, time); in hrtimer_add_expires()
127 static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns) in hrtimer_add_expires_ns() argument
129 timer->node.expires = ktime_add_ns(timer->node.expires, ns); in hrtimer_add_expires_ns()
130 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns); in hrtimer_add_expires_ns()
133 static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) in hrtimer_get_expires() argument
135 return timer->node.expires; in hrtimer_get_expires()
138 static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) in hrtimer_get_softexpires() argument
140 return timer->_softexpires; in hrtimer_get_softexpires()
143 static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) in hrtimer_get_expires_tv64() argument
145 return timer->node.expires; in hrtimer_get_expires_tv64()
147 static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) in hrtimer_get_softexpires_tv64() argument
149 return timer->_softexpires; in hrtimer_get_softexpires_tv64()
152 static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) in hrtimer_get_expires_ns() argument
154 return ktime_to_ns(timer->node.expires); in hrtimer_get_expires_ns()
157 static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) in hrtimer_expires_remaining() argument
159 return ktime_sub(timer->node.expires, timer->base->get_time()); in hrtimer_expires_remaining()
162 static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer) in hrtimer_cb_get_time() argument
164 return timer->base->get_time(); in hrtimer_cb_get_time()
167 static inline int hrtimer_is_hres_active(struct hrtimer *timer) in hrtimer_is_hres_active() argument
170 timer->base->cpu_base->hres_active : 0; in hrtimer_is_hres_active()
187 __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now) in __hrtimer_expires_remaining_adjusted() argument
189 ktime_t rem = ktime_sub(timer->node.expires, now); in __hrtimer_expires_remaining_adjusted()
195 if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel) in __hrtimer_expires_remaining_adjusted()
201 hrtimer_expires_remaining_adjusted(const struct hrtimer *timer) in hrtimer_expires_remaining_adjusted() argument
203 return __hrtimer_expires_remaining_adjusted(timer, in hrtimer_expires_remaining_adjusted()
204 timer->base->get_time()); in hrtimer_expires_remaining_adjusted()
218 void hrtimer_cancel_wait_running(const struct hrtimer *timer);
220 static inline void hrtimer_cancel_wait_running(struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
226 /* Exported timer functions: */
229 extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
235 extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
241 extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
243 static inline void hrtimer_init_on_stack(struct hrtimer *timer, in hrtimer_init_on_stack() argument
247 hrtimer_init(timer, which_clock, mode); in hrtimer_init_on_stack()
257 static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { } in destroy_hrtimer_on_stack() argument
260 /* Basic timer operations: */
261 extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
266 * @timer: the timer to be added
268 * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or
272 static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim, in hrtimer_start() argument
275 hrtimer_start_range_ns(timer, tim, 0, mode); in hrtimer_start()
278 extern int hrtimer_cancel(struct hrtimer *timer);
279 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
281 static inline void hrtimer_start_expires(struct hrtimer *timer, in hrtimer_start_expires() argument
286 soft = hrtimer_get_softexpires(timer); in hrtimer_start_expires()
287 hard = hrtimer_get_expires(timer); in hrtimer_start_expires()
289 hrtimer_start_range_ns(timer, soft, delta, mode); in hrtimer_start_expires()
295 static inline void hrtimer_restart(struct hrtimer *timer) in hrtimer_restart() argument
297 hrtimer_start_expires(timer, HRTIMER_MODE_ABS); in hrtimer_restart()
301 extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust);
304 * hrtimer_get_remaining - get remaining time for the timer
305 * @timer: the timer to read
307 static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer) in hrtimer_get_remaining() argument
309 return __hrtimer_get_remaining(timer, false); in hrtimer_get_remaining()
315 extern bool hrtimer_active(const struct hrtimer *timer);
318 * hrtimer_is_queued - check, whether the timer is on one of the queues
319 * @timer: Timer to check
321 * Returns: True if the timer is queued, false otherwise
325 static inline bool hrtimer_is_queued(struct hrtimer *timer) in hrtimer_is_queued() argument
327 /* The READ_ONCE pairs with the update functions of timer->state */ in hrtimer_is_queued()
328 return !!(READ_ONCE(timer->state) & HRTIMER_STATE_ENQUEUED); in hrtimer_is_queued()
332 * Helper function to check, whether the timer is running the callback
335 static inline int hrtimer_callback_running(struct hrtimer *timer) in hrtimer_callback_running() argument
337 return timer->base->running == timer; in hrtimer_callback_running()
342 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
345 * hrtimer_forward_now() - forward the timer expiry so it expires after now
346 * @timer: hrtimer to forward
349 * It is a variant of hrtimer_forward(). The timer will expire after the current
352 static inline u64 hrtimer_forward_now(struct hrtimer *timer, in hrtimer_forward_now() argument
355 return hrtimer_forward(timer, timer->base->get_time(), interval); in hrtimer_forward_now()