Lines Matching full:timer
21 #include <linux/timer.h>
32 * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered
33 * when starting the timer)
34 * HRTIMER_MODE_SOFT - Timer callback function will be executed in
36 * HRTIMER_MODE_HARD - Timer callback function will be executed in
66 HRTIMER_NORESTART, /* Timer is not restarted */
67 HRTIMER_RESTART, /* Timer must be restarted */
71 * Values to track state of the timer
78 * The callback state is not part of the timer->state because clearing it would
79 * mean touching the timer after the callback, this makes it impossible to free
80 * the timer from the callback function.
84 * timer->base->cpu_base->running == timer
87 * status. It happens for example when a posix timer expired and the callback
88 * queued a signal. Between dropping the lock which protects the posix timer
90 * signal and rearm the timer.
102 * which the timer is based. Is setup by adding
106 * The time which was given as expiry time when the timer
108 * @function: timer expiry callback function
109 * @base: pointer to the timer base (per cpu and per clock)
111 * @is_rel: Set if the timer was armed relative
131 * @timer: embedded timer structure
134 * task is set to NULL, when the timer expires.
137 struct hrtimer timer; member
148 * struct hrtimer_clock_base - the timer base for a specific clock
151 * timer to a base on another cpu.
200 * @timer_waiters: A hrtimer_cancel() invocation waits for the timer
205 * @next_timer: Pointer to the first expiring timer
207 * @softirq_next_timer: Pointer to the first expiring softirq based timer
240 static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) in hrtimer_set_expires() argument
242 timer->node.expires = time; in hrtimer_set_expires()
243 timer->_softexpires = time; in hrtimer_set_expires()
246 static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta) in hrtimer_set_expires_range() argument
248 timer->_softexpires = time; in hrtimer_set_expires_range()
249 timer->node.expires = ktime_add_safe(time, delta); in hrtimer_set_expires_range()
252 static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, u64 delta) in hrtimer_set_expires_range_ns() argument
254 timer->_softexpires = time; in hrtimer_set_expires_range_ns()
255 timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta)); in hrtimer_set_expires_range_ns()
258 static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) in hrtimer_set_expires_tv64() argument
260 timer->node.expires = tv64; in hrtimer_set_expires_tv64()
261 timer->_softexpires = tv64; in hrtimer_set_expires_tv64()
264 static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) in hrtimer_add_expires() argument
266 timer->node.expires = ktime_add_safe(timer->node.expires, time); in hrtimer_add_expires()
267 timer->_softexpires = ktime_add_safe(timer->_softexpires, time); in hrtimer_add_expires()
270 static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns) in hrtimer_add_expires_ns() argument
272 timer->node.expires = ktime_add_ns(timer->node.expires, ns); in hrtimer_add_expires_ns()
273 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns); in hrtimer_add_expires_ns()
276 static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) in hrtimer_get_expires() argument
278 return timer->node.expires; in hrtimer_get_expires()
281 static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) in hrtimer_get_softexpires() argument
283 return timer->_softexpires; in hrtimer_get_softexpires()
286 static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) in hrtimer_get_expires_tv64() argument
288 return timer->node.expires; in hrtimer_get_expires_tv64()
290 static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) in hrtimer_get_softexpires_tv64() argument
292 return timer->_softexpires; in hrtimer_get_softexpires_tv64()
295 static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) in hrtimer_get_expires_ns() argument
297 return ktime_to_ns(timer->node.expires); in hrtimer_get_expires_ns()
300 static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) in hrtimer_expires_remaining() argument
302 return ktime_sub(timer->node.expires, timer->base->get_time()); in hrtimer_expires_remaining()
305 static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer) in hrtimer_cb_get_time() argument
307 return timer->base->get_time(); in hrtimer_cb_get_time()
310 static inline int hrtimer_is_hres_active(struct hrtimer *timer) in hrtimer_is_hres_active() argument
313 timer->base->cpu_base->hres_active : 0; in hrtimer_is_hres_active()
330 __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now) in __hrtimer_expires_remaining_adjusted() argument
332 ktime_t rem = ktime_sub(timer->node.expires, now); in __hrtimer_expires_remaining_adjusted()
338 if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel) in __hrtimer_expires_remaining_adjusted()
344 hrtimer_expires_remaining_adjusted(const struct hrtimer *timer) in hrtimer_expires_remaining_adjusted() argument
346 return __hrtimer_expires_remaining_adjusted(timer, in hrtimer_expires_remaining_adjusted()
347 timer->base->get_time()); in hrtimer_expires_remaining_adjusted()
361 void hrtimer_cancel_wait_running(const struct hrtimer *timer);
363 static inline void hrtimer_cancel_wait_running(struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
369 /* Exported timer functions: */
372 extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
378 extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
384 extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
386 static inline void hrtimer_init_on_stack(struct hrtimer *timer, in hrtimer_init_on_stack() argument
390 hrtimer_init(timer, which_clock, mode); in hrtimer_init_on_stack()
400 static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { } in destroy_hrtimer_on_stack() argument
403 /* Basic timer operations: */
404 extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
409 * @timer: the timer to be added
411 * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or
415 static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim, in hrtimer_start() argument
418 hrtimer_start_range_ns(timer, tim, 0, mode); in hrtimer_start()
421 extern int hrtimer_cancel(struct hrtimer *timer);
422 extern int hrtimer_try_to_cancel(struct hrtimer *timer);
424 static inline void hrtimer_start_expires(struct hrtimer *timer, in hrtimer_start_expires() argument
429 soft = hrtimer_get_softexpires(timer); in hrtimer_start_expires()
430 hard = hrtimer_get_expires(timer); in hrtimer_start_expires()
432 hrtimer_start_range_ns(timer, soft, delta, mode); in hrtimer_start_expires()
438 static inline void hrtimer_restart(struct hrtimer *timer) in hrtimer_restart() argument
440 hrtimer_start_expires(timer, HRTIMER_MODE_ABS); in hrtimer_restart()
444 extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust);
447 * hrtimer_get_remaining - get remaining time for the timer
448 * @timer: the timer to read
450 static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer) in hrtimer_get_remaining() argument
452 return __hrtimer_get_remaining(timer, false); in hrtimer_get_remaining()
458 extern bool hrtimer_active(const struct hrtimer *timer);
461 * hrtimer_is_queued - check, whether the timer is on one of the queues
462 * @timer: Timer to check
464 * Returns: True if the timer is queued, false otherwise
468 static inline bool hrtimer_is_queued(struct hrtimer *timer) in hrtimer_is_queued() argument
470 /* The READ_ONCE pairs with the update functions of timer->state */ in hrtimer_is_queued()
471 return !!(READ_ONCE(timer->state) & HRTIMER_STATE_ENQUEUED); in hrtimer_is_queued()
475 * Helper function to check, whether the timer is running the callback
478 static inline int hrtimer_callback_running(struct hrtimer *timer) in hrtimer_callback_running() argument
480 return timer->base->running == timer; in hrtimer_callback_running()
485 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
488 * hrtimer_forward_now - forward the timer expiry so it expires after now
489 * @timer: hrtimer to forward
492 * Forward the timer expiry so it will expire after the current time
495 * Can be safely called from the callback function of @timer. If
496 * called from other contexts @timer must neither be enqueued nor
500 * Note: This only updates the timer expiry value and does not requeue
501 * the timer.
503 static inline u64 hrtimer_forward_now(struct hrtimer *timer, in hrtimer_forward_now() argument
506 return hrtimer_forward(timer, timer->base->get_time(), interval); in hrtimer_forward_now()