Lines Matching refs:timer

162 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,  in lock_hrtimer_base()  argument
164 __acquires(&timer->base->lock) in lock_hrtimer_base()
169 base = READ_ONCE(timer->base); in lock_hrtimer_base()
172 if (likely(base == timer->base)) in lock_hrtimer_base()
195 static bool hrtimer_suitable_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base, in hrtimer_suitable_target() argument
217 expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); in hrtimer_suitable_target()
250 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, in switch_hrtimer_base() argument
272 if (unlikely(hrtimer_callback_running(timer))) in switch_hrtimer_base()
276 WRITE_ONCE(timer->base, &migration_base); in switch_hrtimer_base()
280 if (!hrtimer_suitable_target(timer, new_base, new_cpu_base, in switch_hrtimer_base()
285 WRITE_ONCE(timer->base, base); in switch_hrtimer_base()
288 WRITE_ONCE(timer->base, new_base); in switch_hrtimer_base()
290 if (!hrtimer_suitable_target(timer, new_base, new_cpu_base, this_cpu_base)) { in switch_hrtimer_base()
301 lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in lock_hrtimer_base() argument
302 __acquires(&timer->base->cpu_base->lock) in lock_hrtimer_base()
304 struct hrtimer_clock_base *base = timer->base; in lock_hrtimer_base()
378 struct hrtimer *timer = addr; in hrtimer_fixup_init() local
382 hrtimer_cancel(timer); in hrtimer_fixup_init()
383 debug_object_init(timer, &hrtimer_debug_descr); in hrtimer_fixup_init()
412 struct hrtimer *timer = addr; in hrtimer_fixup_free() local
416 hrtimer_cancel(timer); in hrtimer_fixup_free()
417 debug_object_free(timer, &hrtimer_debug_descr); in hrtimer_fixup_free()
432 static inline void debug_hrtimer_init(struct hrtimer *timer) in debug_hrtimer_init() argument
434 debug_object_init(timer, &hrtimer_debug_descr); in debug_hrtimer_init()
437 static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) in debug_hrtimer_init_on_stack() argument
439 debug_object_init_on_stack(timer, &hrtimer_debug_descr); in debug_hrtimer_init_on_stack()
442 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
445 debug_object_activate(timer, &hrtimer_debug_descr); in debug_hrtimer_activate()
448 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) in debug_hrtimer_deactivate() argument
450 debug_object_deactivate(timer, &hrtimer_debug_descr); in debug_hrtimer_deactivate()
453 void destroy_hrtimer_on_stack(struct hrtimer *timer) in destroy_hrtimer_on_stack() argument
455 debug_object_free(timer, &hrtimer_debug_descr); in destroy_hrtimer_on_stack()
461 static inline void debug_hrtimer_init(struct hrtimer *timer) { } in debug_hrtimer_init() argument
462 static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) { } in debug_hrtimer_init_on_stack() argument
463 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
465 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } in debug_hrtimer_deactivate() argument
468 static inline void debug_setup(struct hrtimer *timer, clockid_t clockid, enum hrtimer_mode mode) in debug_setup() argument
470 debug_hrtimer_init(timer); in debug_setup()
471 trace_hrtimer_setup(timer, clockid, mode); in debug_setup()
474 static inline void debug_setup_on_stack(struct hrtimer *timer, clockid_t clockid, in debug_setup_on_stack() argument
477 debug_hrtimer_init_on_stack(timer); in debug_setup_on_stack()
478 trace_hrtimer_setup(timer, clockid, mode); in debug_setup_on_stack()
481 static inline void debug_activate(struct hrtimer *timer, in debug_activate() argument
484 debug_hrtimer_activate(timer, mode); in debug_activate()
485 trace_hrtimer_start(timer, mode); in debug_activate()
488 static inline void debug_deactivate(struct hrtimer *timer) in debug_deactivate() argument
490 debug_hrtimer_deactivate(timer); in debug_deactivate()
491 trace_hrtimer_cancel(timer); in debug_deactivate()
521 struct hrtimer *timer; in __hrtimer_next_event_base() local
524 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
525 if (timer == exclude) { in __hrtimer_next_event_base()
531 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
533 expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in __hrtimer_next_event_base()
541 if (timer->is_soft) in __hrtimer_next_event_base()
542 cpu_base->softirq_next_timer = timer; in __hrtimer_next_event_base()
544 cpu_base->next_timer = timer; in __hrtimer_next_event_base()
810 static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram) in hrtimer_reprogram() argument
813 struct hrtimer_clock_base *base = timer->base; in hrtimer_reprogram()
814 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in hrtimer_reprogram()
816 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); in hrtimer_reprogram()
825 if (timer->is_soft) { in hrtimer_reprogram()
841 timer_cpu_base->softirq_next_timer = timer; in hrtimer_reprogram()
866 cpu_base->next_timer = timer; in hrtimer_reprogram()
868 __hrtimer_reprogram(cpu_base, timer, expires); in hrtimer_reprogram()
1017 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in unlock_hrtimer_base() argument
1018 __releases(&timer->base->cpu_base->lock) in unlock_hrtimer_base()
1020 raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags); in unlock_hrtimer_base()
1042 u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) in hrtimer_forward() argument
1047 delta = ktime_sub(now, hrtimer_get_expires(timer)); in hrtimer_forward()
1052 if (WARN_ON(timer->state & HRTIMER_STATE_ENQUEUED)) in hrtimer_forward()
1062 hrtimer_add_expires_ns(timer, incr * orun); in hrtimer_forward()
1063 if (hrtimer_get_expires_tv64(timer) > now) in hrtimer_forward()
1071 hrtimer_add_expires(timer, interval); in hrtimer_forward()
1085 static bool enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in enqueue_hrtimer() argument
1088 debug_activate(timer, mode); in enqueue_hrtimer()
1094 WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED); in enqueue_hrtimer()
1096 return timerqueue_add(&base->active, &timer->node); in enqueue_hrtimer()
1109 static void __remove_hrtimer(struct hrtimer *timer, in __remove_hrtimer() argument
1114 u8 state = timer->state; in __remove_hrtimer()
1117 WRITE_ONCE(timer->state, newstate); in __remove_hrtimer()
1121 if (!timerqueue_del(&base->active, &timer->node)) in __remove_hrtimer()
1132 if (reprogram && timer == cpu_base->next_timer) in __remove_hrtimer()
1140 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in remove_hrtimer() argument
1143 u8 state = timer->state; in remove_hrtimer()
1156 debug_deactivate(timer); in remove_hrtimer()
1170 __remove_hrtimer(timer, base, state, reprogram); in remove_hrtimer()
1176 static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim, in hrtimer_update_lowres() argument
1185 timer->is_rel = mode & HRTIMER_MODE_REL; in hrtimer_update_lowres()
1186 if (timer->is_rel) in hrtimer_update_lowres()
1217 static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in __hrtimer_start_range_ns() argument
1234 force_local &= base->cpu_base->next_timer == timer; in __hrtimer_start_range_ns()
1253 remove_hrtimer(timer, base, true, force_local); in __hrtimer_start_range_ns()
1258 tim = hrtimer_update_lowres(timer, tim, mode); in __hrtimer_start_range_ns()
1260 hrtimer_set_expires_range_ns(timer, tim, delta_ns); in __hrtimer_start_range_ns()
1264 new_base = switch_hrtimer_base(timer, base, in __hrtimer_start_range_ns()
1270 first = enqueue_hrtimer(timer, new_base, mode); in __hrtimer_start_range_ns()
1311 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in hrtimer_start_range_ns() argument
1323 WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); in hrtimer_start_range_ns()
1325 WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); in hrtimer_start_range_ns()
1327 base = lock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1329 if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) in hrtimer_start_range_ns()
1330 hrtimer_reprogram(timer, true); in hrtimer_start_range_ns()
1332 unlock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1347 int hrtimer_try_to_cancel(struct hrtimer *timer) in hrtimer_try_to_cancel() argument
1359 if (!hrtimer_active(timer)) in hrtimer_try_to_cancel()
1362 base = lock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1364 if (!hrtimer_callback_running(timer)) in hrtimer_try_to_cancel()
1365 ret = remove_hrtimer(timer, base, false, false); in hrtimer_try_to_cancel()
1367 unlock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1438 void hrtimer_cancel_wait_running(const struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
1441 struct hrtimer_clock_base *base = READ_ONCE(timer->base); in hrtimer_cancel_wait_running()
1447 if (!timer->is_soft || is_migration_base(base)) { in hrtimer_cancel_wait_running()
1483 int hrtimer_cancel(struct hrtimer *timer) in hrtimer_cancel() argument
1488 ret = hrtimer_try_to_cancel(timer); in hrtimer_cancel()
1491 hrtimer_cancel_wait_running(timer); in hrtimer_cancel()
1502 ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) in __hrtimer_get_remaining() argument
1507 lock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1509 rem = hrtimer_expires_remaining_adjusted(timer); in __hrtimer_get_remaining()
1511 rem = hrtimer_expires_remaining(timer); in __hrtimer_get_remaining()
1512 unlock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1591 static void __hrtimer_setup(struct hrtimer *timer, in __hrtimer_setup() argument
1608 memset(timer, 0, sizeof(struct hrtimer)); in __hrtimer_setup()
1622 timer->is_soft = softtimer; in __hrtimer_setup()
1623 timer->is_hard = !!(mode & HRTIMER_MODE_HARD); in __hrtimer_setup()
1624 timer->base = &cpu_base->clock_base[base]; in __hrtimer_setup()
1625 timerqueue_init(&timer->node); in __hrtimer_setup()
1628 ACCESS_PRIVATE(timer, function) = hrtimer_dummy_timeout; in __hrtimer_setup()
1630 ACCESS_PRIVATE(timer, function) = function; in __hrtimer_setup()
1646 void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *), in hrtimer_setup() argument
1649 debug_setup(timer, clock_id, mode); in hrtimer_setup()
1650 __hrtimer_setup(timer, function, clock_id, mode); in hrtimer_setup()
1664 void hrtimer_setup_on_stack(struct hrtimer *timer, in hrtimer_setup_on_stack() argument
1668 debug_setup_on_stack(timer, clock_id, mode); in hrtimer_setup_on_stack()
1669 __hrtimer_setup(timer, function, clock_id, mode); in hrtimer_setup_on_stack()
1680 bool hrtimer_active(const struct hrtimer *timer) in hrtimer_active() argument
1686 base = READ_ONCE(timer->base); in hrtimer_active()
1689 if (timer->state != HRTIMER_STATE_INACTIVE || in hrtimer_active()
1690 base->running == timer) in hrtimer_active()
1694 base != READ_ONCE(timer->base)); in hrtimer_active()
1720 struct hrtimer *timer, ktime_t *now, in __run_hrtimer() argument
1729 debug_deactivate(timer); in __run_hrtimer()
1730 base->running = timer; in __run_hrtimer()
1741 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); in __run_hrtimer()
1742 fn = ACCESS_PRIVATE(timer, function); in __run_hrtimer()
1750 timer->is_rel = false; in __run_hrtimer()
1758 trace_hrtimer_expire_entry(timer, now); in __run_hrtimer()
1759 expires_in_hardirq = lockdep_hrtimer_enter(timer); in __run_hrtimer()
1761 restart = fn(timer); in __run_hrtimer()
1764 trace_hrtimer_expire_exit(timer); in __run_hrtimer()
1777 !(timer->state & HRTIMER_STATE_ENQUEUED)) in __run_hrtimer()
1778 enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); in __run_hrtimer()
1789 WARN_ON_ONCE(base->running != timer); in __run_hrtimer()
1806 struct hrtimer *timer; in __hrtimer_run_queues() local
1808 timer = container_of(node, struct hrtimer, node); in __hrtimer_run_queues()
1822 if (basenow < hrtimer_get_softexpires_tv64(timer)) in __hrtimer_run_queues()
1825 __run_hrtimer(cpu_base, base, timer, &basenow, flags); in __hrtimer_run_queues()
1989 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) in hrtimer_wakeup() argument
1992 container_of(timer, struct hrtimer_sleeper, timer); in hrtimer_wakeup()
2020 if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) in hrtimer_sleeper_start_expires()
2023 hrtimer_start_expires(&sl->timer, mode); in hrtimer_sleeper_start_expires()
2054 __hrtimer_setup(&sl->timer, hrtimer_wakeup, clock_id, mode); in __hrtimer_setup_sleeper()
2067 debug_setup_on_stack(&sl->timer, clock_id, mode); in hrtimer_setup_sleeper_on_stack()
2102 hrtimer_cancel(&t->timer); in do_nanosleep()
2114 ktime_t rem = hrtimer_expires_remaining(&t->timer); in do_nanosleep()
2132 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); in hrtimer_nanosleep_restart()
2134 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep_restart()
2146 hrtimer_set_expires_range_ns(&t.timer, rqtp, current->timer_slack_ns); in hrtimer_nanosleep()
2158 restart->nanosleep.clockid = t.timer.base->clockid; in hrtimer_nanosleep()
2159 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); in hrtimer_nanosleep()
2162 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep()
2251 struct hrtimer *timer; in migrate_hrtimer_list() local
2255 timer = container_of(node, struct hrtimer, node); in migrate_hrtimer_list()
2256 BUG_ON(hrtimer_callback_running(timer)); in migrate_hrtimer_list()
2257 debug_deactivate(timer); in migrate_hrtimer_list()
2264 __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); in migrate_hrtimer_list()
2265 timer->base = new_base; in migrate_hrtimer_list()
2274 enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); in migrate_hrtimer_list()