Lines Matching refs:timer

166 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,  in lock_hrtimer_base()  argument
168 __acquires(&timer->base->lock) in lock_hrtimer_base()
173 base = READ_ONCE(timer->base); in lock_hrtimer_base()
176 if (likely(base == timer->base)) in lock_hrtimer_base()
195 hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base) in hrtimer_check_target() argument
199 expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); in hrtimer_check_target()
227 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, in switch_hrtimer_base() argument
249 if (unlikely(hrtimer_callback_running(timer))) in switch_hrtimer_base()
253 WRITE_ONCE(timer->base, &migration_base); in switch_hrtimer_base()
258 hrtimer_check_target(timer, new_base)) { in switch_hrtimer_base()
262 WRITE_ONCE(timer->base, base); in switch_hrtimer_base()
265 WRITE_ONCE(timer->base, new_base); in switch_hrtimer_base()
268 hrtimer_check_target(timer, new_base)) { in switch_hrtimer_base()
284 lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in lock_hrtimer_base() argument
285 __acquires(&timer->base->cpu_base->lock) in lock_hrtimer_base()
287 struct hrtimer_clock_base *base = timer->base; in lock_hrtimer_base()
361 struct hrtimer *timer = addr; in hrtimer_fixup_init() local
365 hrtimer_cancel(timer); in hrtimer_fixup_init()
366 debug_object_init(timer, &hrtimer_debug_descr); in hrtimer_fixup_init()
395 struct hrtimer *timer = addr; in hrtimer_fixup_free() local
399 hrtimer_cancel(timer); in hrtimer_fixup_free()
400 debug_object_free(timer, &hrtimer_debug_descr); in hrtimer_fixup_free()
415 static inline void debug_hrtimer_init(struct hrtimer *timer) in debug_hrtimer_init() argument
417 debug_object_init(timer, &hrtimer_debug_descr); in debug_hrtimer_init()
420 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
423 debug_object_activate(timer, &hrtimer_debug_descr); in debug_hrtimer_activate()
426 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) in debug_hrtimer_deactivate() argument
428 debug_object_deactivate(timer, &hrtimer_debug_descr); in debug_hrtimer_deactivate()
431 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
434 void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init_on_stack() argument
437 debug_object_init_on_stack(timer, &hrtimer_debug_descr); in hrtimer_init_on_stack()
438 __hrtimer_init(timer, clock_id, mode); in hrtimer_init_on_stack()
448 debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr); in hrtimer_init_sleeper_on_stack()
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_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
464 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } in debug_hrtimer_deactivate() argument
468 debug_init(struct hrtimer *timer, clockid_t clockid, in debug_init() argument
471 debug_hrtimer_init(timer); in debug_init()
472 trace_hrtimer_init(timer, clockid, mode); in debug_init()
475 static inline void debug_activate(struct hrtimer *timer, in debug_activate() argument
478 debug_hrtimer_activate(timer, mode); in debug_activate()
479 trace_hrtimer_start(timer, mode); in debug_activate()
482 static inline void debug_deactivate(struct hrtimer *timer) in debug_deactivate() argument
484 debug_hrtimer_deactivate(timer); in debug_deactivate()
485 trace_hrtimer_cancel(timer); in debug_deactivate()
515 struct hrtimer *timer; in __hrtimer_next_event_base() local
518 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
519 if (timer == exclude) { in __hrtimer_next_event_base()
525 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
527 expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in __hrtimer_next_event_base()
535 if (timer->is_soft) in __hrtimer_next_event_base()
536 cpu_base->softirq_next_timer = timer; in __hrtimer_next_event_base()
538 cpu_base->next_timer = timer; in __hrtimer_next_event_base()
811 static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram) in hrtimer_reprogram() argument
814 struct hrtimer_clock_base *base = timer->base; in hrtimer_reprogram()
815 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in hrtimer_reprogram()
817 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); in hrtimer_reprogram()
826 if (timer->is_soft) { in hrtimer_reprogram()
842 timer_cpu_base->softirq_next_timer = timer; in hrtimer_reprogram()
867 cpu_base->next_timer = timer; in hrtimer_reprogram()
869 __hrtimer_reprogram(cpu_base, timer, expires); in hrtimer_reprogram()
1018 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in unlock_hrtimer_base() argument
1019 __releases(&timer->base->cpu_base->lock) in unlock_hrtimer_base()
1021 raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags); in unlock_hrtimer_base()
1041 u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) in hrtimer_forward() argument
1046 delta = ktime_sub(now, hrtimer_get_expires(timer)); in hrtimer_forward()
1051 if (WARN_ON(timer->state & HRTIMER_STATE_ENQUEUED)) in hrtimer_forward()
1061 hrtimer_add_expires_ns(timer, incr * orun); in hrtimer_forward()
1062 if (hrtimer_get_expires_tv64(timer) > now) in hrtimer_forward()
1070 hrtimer_add_expires(timer, interval); in hrtimer_forward()
1084 static int enqueue_hrtimer(struct hrtimer *timer, 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
1233 force_local &= base->cpu_base->next_timer == timer; in __hrtimer_start_range_ns()
1246 remove_hrtimer(timer, base, true, force_local); in __hrtimer_start_range_ns()
1251 tim = hrtimer_update_lowres(timer, tim, mode); in __hrtimer_start_range_ns()
1253 hrtimer_set_expires_range_ns(timer, tim, delta_ns); in __hrtimer_start_range_ns()
1257 new_base = switch_hrtimer_base(timer, base, in __hrtimer_start_range_ns()
1263 first = enqueue_hrtimer(timer, new_base, mode); in __hrtimer_start_range_ns()
1285 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in hrtimer_start_range_ns() argument
1291 if (WARN_ON_ONCE(!timer->function)) in hrtimer_start_range_ns()
1299 WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); in hrtimer_start_range_ns()
1301 WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); in hrtimer_start_range_ns()
1303 base = lock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1305 if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) in hrtimer_start_range_ns()
1306 hrtimer_reprogram(timer, true); in hrtimer_start_range_ns()
1308 unlock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1323 int hrtimer_try_to_cancel(struct hrtimer *timer) in hrtimer_try_to_cancel() argument
1335 if (!hrtimer_active(timer)) in hrtimer_try_to_cancel()
1338 base = lock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1340 if (!hrtimer_callback_running(timer)) in hrtimer_try_to_cancel()
1341 ret = remove_hrtimer(timer, base, false, false); in hrtimer_try_to_cancel()
1343 unlock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1400 void hrtimer_cancel_wait_running(const struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
1403 struct hrtimer_clock_base *base = READ_ONCE(timer->base); in hrtimer_cancel_wait_running()
1409 if (!timer->is_soft || is_migration_base(base)) { in hrtimer_cancel_wait_running()
1445 int hrtimer_cancel(struct hrtimer *timer) in hrtimer_cancel() argument
1450 ret = hrtimer_try_to_cancel(timer); in hrtimer_cancel()
1453 hrtimer_cancel_wait_running(timer); in hrtimer_cancel()
1464 ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) in __hrtimer_get_remaining() argument
1469 lock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1471 rem = hrtimer_expires_remaining_adjusted(timer); in __hrtimer_get_remaining()
1473 rem = hrtimer_expires_remaining(timer); in __hrtimer_get_remaining()
1474 unlock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1548 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in __hrtimer_init() argument
1564 memset(timer, 0, sizeof(struct hrtimer)); in __hrtimer_init()
1578 timer->is_soft = softtimer; in __hrtimer_init()
1579 timer->is_hard = !!(mode & HRTIMER_MODE_HARD); in __hrtimer_init()
1580 timer->base = &cpu_base->clock_base[base]; in __hrtimer_init()
1581 timerqueue_init(&timer->node); in __hrtimer_init()
1596 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init() argument
1599 debug_init(timer, clock_id, mode); in hrtimer_init()
1600 __hrtimer_init(timer, clock_id, mode); in hrtimer_init()
1611 bool hrtimer_active(const struct hrtimer *timer) in hrtimer_active() argument
1617 base = READ_ONCE(timer->base); in hrtimer_active()
1620 if (timer->state != HRTIMER_STATE_INACTIVE || in hrtimer_active()
1621 base->running == timer) in hrtimer_active()
1625 base != READ_ONCE(timer->base)); in hrtimer_active()
1651 struct hrtimer *timer, ktime_t *now, in __run_hrtimer() argument
1660 debug_deactivate(timer); in __run_hrtimer()
1661 base->running = timer; in __run_hrtimer()
1672 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); in __run_hrtimer()
1673 fn = timer->function; in __run_hrtimer()
1681 timer->is_rel = false; in __run_hrtimer()
1689 trace_hrtimer_expire_entry(timer, now); in __run_hrtimer()
1690 expires_in_hardirq = lockdep_hrtimer_enter(timer); in __run_hrtimer()
1692 restart = fn(timer); in __run_hrtimer()
1695 trace_hrtimer_expire_exit(timer); in __run_hrtimer()
1708 !(timer->state & HRTIMER_STATE_ENQUEUED)) in __run_hrtimer()
1709 enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); in __run_hrtimer()
1720 WARN_ON_ONCE(base->running != timer); in __run_hrtimer()
1737 struct hrtimer *timer; in __hrtimer_run_queues() local
1739 timer = container_of(node, struct hrtimer, node); in __hrtimer_run_queues()
1753 if (basenow < hrtimer_get_softexpires_tv64(timer)) in __hrtimer_run_queues()
1756 __run_hrtimer(cpu_base, base, timer, &basenow, flags); in __hrtimer_run_queues()
1938 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) in hrtimer_wakeup() argument
1941 container_of(timer, struct hrtimer_sleeper, timer); in hrtimer_wakeup()
1969 if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) in hrtimer_sleeper_start_expires()
1972 hrtimer_start_expires(&sl->timer, mode); in hrtimer_sleeper_start_expires()
2003 __hrtimer_init(&sl->timer, clock_id, mode); in __hrtimer_init_sleeper()
2004 sl->timer.function = hrtimer_wakeup; in __hrtimer_init_sleeper()
2017 debug_init(&sl->timer, clock_id, mode); in hrtimer_init_sleeper()
2053 hrtimer_cancel(&t->timer); in do_nanosleep()
2065 ktime_t rem = hrtimer_expires_remaining(&t->timer); in do_nanosleep()
2084 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); in hrtimer_nanosleep_restart()
2086 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep_restart()
2103 hrtimer_set_expires_range_ns(&t.timer, rqtp, slack); in hrtimer_nanosleep()
2115 restart->nanosleep.clockid = t.timer.base->clockid; in hrtimer_nanosleep()
2116 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); in hrtimer_nanosleep()
2119 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep()
2200 struct hrtimer *timer; in migrate_hrtimer_list() local
2204 timer = container_of(node, struct hrtimer, node); in migrate_hrtimer_list()
2205 BUG_ON(hrtimer_callback_running(timer)); in migrate_hrtimer_list()
2206 debug_deactivate(timer); in migrate_hrtimer_list()
2213 __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); in migrate_hrtimer_list()
2214 timer->base = new_base; in migrate_hrtimer_list()
2223 enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); in migrate_hrtimer_list()
2310 hrtimer_set_expires_range_ns(&t.timer, *expires, delta); in schedule_hrtimeout_range_clock()
2316 hrtimer_cancel(&t.timer); in schedule_hrtimeout_range_clock()
2317 destroy_hrtimer_on_stack(&t.timer); in schedule_hrtimeout_range_clock()