Lines Matching refs:timer
172 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer, in lock_hrtimer_base() argument
174 __acquires(&timer->base->lock) in lock_hrtimer_base()
179 base = READ_ONCE(timer->base); in lock_hrtimer_base()
182 if (likely(base == timer->base)) in lock_hrtimer_base()
205 static bool hrtimer_suitable_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base, in hrtimer_suitable_target() argument
227 expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); in hrtimer_suitable_target()
260 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, in switch_hrtimer_base() argument
282 if (unlikely(hrtimer_callback_running(timer))) in switch_hrtimer_base()
286 WRITE_ONCE(timer->base, &migration_base); in switch_hrtimer_base()
290 if (!hrtimer_suitable_target(timer, new_base, new_cpu_base, in switch_hrtimer_base()
295 WRITE_ONCE(timer->base, base); in switch_hrtimer_base()
298 WRITE_ONCE(timer->base, new_base); in switch_hrtimer_base()
300 if (!hrtimer_suitable_target(timer, new_base, new_cpu_base, this_cpu_base)) { in switch_hrtimer_base()
311 lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in lock_hrtimer_base() argument
312 __acquires(&timer->base->cpu_base->lock) in lock_hrtimer_base()
314 struct hrtimer_clock_base *base = timer->base; in lock_hrtimer_base()
388 struct hrtimer *timer = addr; in hrtimer_fixup_init() local
392 hrtimer_cancel(timer); in hrtimer_fixup_init()
393 debug_object_init(timer, &hrtimer_debug_descr); in hrtimer_fixup_init()
422 struct hrtimer *timer = addr; in hrtimer_fixup_free() local
426 hrtimer_cancel(timer); in hrtimer_fixup_free()
427 debug_object_free(timer, &hrtimer_debug_descr); in hrtimer_fixup_free()
442 static inline void debug_hrtimer_init(struct hrtimer *timer) in debug_hrtimer_init() argument
444 debug_object_init(timer, &hrtimer_debug_descr); in debug_hrtimer_init()
447 static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) in debug_hrtimer_init_on_stack() argument
449 debug_object_init_on_stack(timer, &hrtimer_debug_descr); in debug_hrtimer_init_on_stack()
452 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
455 debug_object_activate(timer, &hrtimer_debug_descr); in debug_hrtimer_activate()
458 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) in debug_hrtimer_deactivate() argument
460 debug_object_deactivate(timer, &hrtimer_debug_descr); in debug_hrtimer_deactivate()
463 void destroy_hrtimer_on_stack(struct hrtimer *timer) in destroy_hrtimer_on_stack() argument
465 debug_object_free(timer, &hrtimer_debug_descr); in destroy_hrtimer_on_stack()
471 static inline void debug_hrtimer_init(struct hrtimer *timer) { } in debug_hrtimer_init() argument
472 static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) { } in debug_hrtimer_init_on_stack() argument
473 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
475 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } in debug_hrtimer_deactivate() argument
479 debug_init(struct hrtimer *timer, clockid_t clockid, in debug_init() argument
482 debug_hrtimer_init(timer); in debug_init()
483 trace_hrtimer_init(timer, clockid, mode); in debug_init()
486 static inline void debug_init_on_stack(struct hrtimer *timer, clockid_t clockid, in debug_init_on_stack() argument
489 debug_hrtimer_init_on_stack(timer); in debug_init_on_stack()
490 trace_hrtimer_init(timer, clockid, mode); in debug_init_on_stack()
493 static inline void debug_activate(struct hrtimer *timer, in debug_activate() argument
496 debug_hrtimer_activate(timer, mode); in debug_activate()
497 trace_hrtimer_start(timer, mode); in debug_activate()
500 static inline void debug_deactivate(struct hrtimer *timer) in debug_deactivate() argument
502 debug_hrtimer_deactivate(timer); in debug_deactivate()
503 trace_hrtimer_cancel(timer); in debug_deactivate()
533 struct hrtimer *timer; in __hrtimer_next_event_base() local
536 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
537 if (timer == exclude) { in __hrtimer_next_event_base()
543 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
545 expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in __hrtimer_next_event_base()
553 if (timer->is_soft) in __hrtimer_next_event_base()
554 cpu_base->softirq_next_timer = timer; in __hrtimer_next_event_base()
556 cpu_base->next_timer = timer; in __hrtimer_next_event_base()
822 static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram) in hrtimer_reprogram() argument
825 struct hrtimer_clock_base *base = timer->base; in hrtimer_reprogram()
826 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in hrtimer_reprogram()
828 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); in hrtimer_reprogram()
837 if (timer->is_soft) { in hrtimer_reprogram()
853 timer_cpu_base->softirq_next_timer = timer; in hrtimer_reprogram()
878 cpu_base->next_timer = timer; in hrtimer_reprogram()
880 __hrtimer_reprogram(cpu_base, timer, expires); in hrtimer_reprogram()
1029 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in unlock_hrtimer_base() argument
1030 __releases(&timer->base->cpu_base->lock) in unlock_hrtimer_base()
1032 raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags); in unlock_hrtimer_base()
1054 u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) in hrtimer_forward() argument
1059 delta = ktime_sub(now, hrtimer_get_expires(timer)); in hrtimer_forward()
1064 if (WARN_ON(timer->state & HRTIMER_STATE_ENQUEUED)) in hrtimer_forward()
1074 hrtimer_add_expires_ns(timer, incr * orun); in hrtimer_forward()
1075 if (hrtimer_get_expires_tv64(timer) > now) in hrtimer_forward()
1083 hrtimer_add_expires(timer, interval); in hrtimer_forward()
1097 static bool enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in enqueue_hrtimer() argument
1100 debug_activate(timer, mode); in enqueue_hrtimer()
1106 WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED); in enqueue_hrtimer()
1108 return timerqueue_add(&base->active, &timer->node); in enqueue_hrtimer()
1121 static void __remove_hrtimer(struct hrtimer *timer, in __remove_hrtimer() argument
1126 u8 state = timer->state; in __remove_hrtimer()
1129 WRITE_ONCE(timer->state, newstate); in __remove_hrtimer()
1133 if (!timerqueue_del(&base->active, &timer->node)) in __remove_hrtimer()
1144 if (reprogram && timer == cpu_base->next_timer) in __remove_hrtimer()
1152 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in remove_hrtimer() argument
1155 u8 state = timer->state; in remove_hrtimer()
1168 debug_deactivate(timer); in remove_hrtimer()
1182 __remove_hrtimer(timer, base, state, reprogram); in remove_hrtimer()
1188 static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim, in hrtimer_update_lowres() argument
1197 timer->is_rel = mode & HRTIMER_MODE_REL; in hrtimer_update_lowres()
1198 if (timer->is_rel) in hrtimer_update_lowres()
1229 static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in __hrtimer_start_range_ns() argument
1246 force_local &= base->cpu_base->next_timer == timer; in __hrtimer_start_range_ns()
1265 remove_hrtimer(timer, base, true, force_local); in __hrtimer_start_range_ns()
1270 tim = hrtimer_update_lowres(timer, tim, mode); in __hrtimer_start_range_ns()
1272 hrtimer_set_expires_range_ns(timer, tim, delta_ns); in __hrtimer_start_range_ns()
1276 new_base = switch_hrtimer_base(timer, base, in __hrtimer_start_range_ns()
1282 first = enqueue_hrtimer(timer, new_base, mode); in __hrtimer_start_range_ns()
1323 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in hrtimer_start_range_ns() argument
1329 if (WARN_ON_ONCE(!timer->function)) in hrtimer_start_range_ns()
1337 WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); in hrtimer_start_range_ns()
1339 WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); in hrtimer_start_range_ns()
1341 base = lock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1343 if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) in hrtimer_start_range_ns()
1344 hrtimer_reprogram(timer, true); in hrtimer_start_range_ns()
1346 unlock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1361 int hrtimer_try_to_cancel(struct hrtimer *timer) in hrtimer_try_to_cancel() argument
1373 if (!hrtimer_active(timer)) in hrtimer_try_to_cancel()
1376 base = lock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1378 if (!hrtimer_callback_running(timer)) in hrtimer_try_to_cancel()
1379 ret = remove_hrtimer(timer, base, false, false); in hrtimer_try_to_cancel()
1381 unlock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1452 void hrtimer_cancel_wait_running(const struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
1455 struct hrtimer_clock_base *base = READ_ONCE(timer->base); in hrtimer_cancel_wait_running()
1461 if (!timer->is_soft || is_migration_base(base)) { in hrtimer_cancel_wait_running()
1497 int hrtimer_cancel(struct hrtimer *timer) in hrtimer_cancel() argument
1502 ret = hrtimer_try_to_cancel(timer); in hrtimer_cancel()
1505 hrtimer_cancel_wait_running(timer); in hrtimer_cancel()
1516 ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) in __hrtimer_get_remaining() argument
1521 lock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1523 rem = hrtimer_expires_remaining_adjusted(timer); in __hrtimer_get_remaining()
1525 rem = hrtimer_expires_remaining(timer); in __hrtimer_get_remaining()
1526 unlock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1605 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in __hrtimer_init() argument
1621 memset(timer, 0, sizeof(struct hrtimer)); in __hrtimer_init()
1635 timer->is_soft = softtimer; in __hrtimer_init()
1636 timer->is_hard = !!(mode & HRTIMER_MODE_HARD); in __hrtimer_init()
1637 timer->base = &cpu_base->clock_base[base]; in __hrtimer_init()
1638 timerqueue_init(&timer->node); in __hrtimer_init()
1641 static void __hrtimer_setup(struct hrtimer *timer, in __hrtimer_setup() argument
1645 __hrtimer_init(timer, clock_id, mode); in __hrtimer_setup()
1648 timer->function = hrtimer_dummy_timeout; in __hrtimer_setup()
1650 timer->function = function; in __hrtimer_setup()
1665 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init() argument
1668 debug_init(timer, clock_id, mode); in hrtimer_init()
1669 __hrtimer_init(timer, clock_id, mode); in hrtimer_init()
1686 void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *), in hrtimer_setup() argument
1689 debug_init(timer, clock_id, mode); in hrtimer_setup()
1690 __hrtimer_setup(timer, function, clock_id, mode); in hrtimer_setup()
1704 void hrtimer_setup_on_stack(struct hrtimer *timer, in hrtimer_setup_on_stack() argument
1708 debug_init_on_stack(timer, clock_id, mode); in hrtimer_setup_on_stack()
1709 __hrtimer_setup(timer, function, clock_id, mode); in hrtimer_setup_on_stack()
1720 bool hrtimer_active(const struct hrtimer *timer) in hrtimer_active() argument
1726 base = READ_ONCE(timer->base); in hrtimer_active()
1729 if (timer->state != HRTIMER_STATE_INACTIVE || in hrtimer_active()
1730 base->running == timer) in hrtimer_active()
1734 base != READ_ONCE(timer->base)); in hrtimer_active()
1760 struct hrtimer *timer, ktime_t *now, in __run_hrtimer() argument
1769 debug_deactivate(timer); in __run_hrtimer()
1770 base->running = timer; in __run_hrtimer()
1781 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); in __run_hrtimer()
1782 fn = timer->function; in __run_hrtimer()
1790 timer->is_rel = false; in __run_hrtimer()
1798 trace_hrtimer_expire_entry(timer, now); in __run_hrtimer()
1799 expires_in_hardirq = lockdep_hrtimer_enter(timer); in __run_hrtimer()
1801 restart = fn(timer); in __run_hrtimer()
1804 trace_hrtimer_expire_exit(timer); in __run_hrtimer()
1817 !(timer->state & HRTIMER_STATE_ENQUEUED)) in __run_hrtimer()
1818 enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); in __run_hrtimer()
1829 WARN_ON_ONCE(base->running != timer); in __run_hrtimer()
1846 struct hrtimer *timer; in __hrtimer_run_queues() local
1848 timer = container_of(node, struct hrtimer, node); in __hrtimer_run_queues()
1862 if (basenow < hrtimer_get_softexpires_tv64(timer)) in __hrtimer_run_queues()
1865 __run_hrtimer(cpu_base, base, timer, &basenow, flags); in __hrtimer_run_queues()
2029 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) in hrtimer_wakeup() argument
2032 container_of(timer, struct hrtimer_sleeper, timer); in hrtimer_wakeup()
2060 if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) in hrtimer_sleeper_start_expires()
2063 hrtimer_start_expires(&sl->timer, mode); in hrtimer_sleeper_start_expires()
2094 __hrtimer_init(&sl->timer, clock_id, mode); in __hrtimer_init_sleeper()
2095 sl->timer.function = hrtimer_wakeup; in __hrtimer_init_sleeper()
2108 debug_init_on_stack(&sl->timer, clock_id, mode); in hrtimer_setup_sleeper_on_stack()
2143 hrtimer_cancel(&t->timer); in do_nanosleep()
2155 ktime_t rem = hrtimer_expires_remaining(&t->timer); in do_nanosleep()
2173 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); in hrtimer_nanosleep_restart()
2175 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep_restart()
2187 hrtimer_set_expires_range_ns(&t.timer, rqtp, current->timer_slack_ns); in hrtimer_nanosleep()
2199 restart->nanosleep.clockid = t.timer.base->clockid; in hrtimer_nanosleep()
2200 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); in hrtimer_nanosleep()
2203 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep()
2292 struct hrtimer *timer; in migrate_hrtimer_list() local
2296 timer = container_of(node, struct hrtimer, node); in migrate_hrtimer_list()
2297 BUG_ON(hrtimer_callback_running(timer)); in migrate_hrtimer_list()
2298 debug_deactivate(timer); in migrate_hrtimer_list()
2305 __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); in migrate_hrtimer_list()
2306 timer->base = new_base; in migrate_hrtimer_list()
2315 enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); in migrate_hrtimer_list()