Lines Matching refs:timer

165 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,  in lock_hrtimer_base()  argument
167 __acquires(&timer->base->lock) in lock_hrtimer_base()
172 base = READ_ONCE(timer->base); in lock_hrtimer_base()
175 if (likely(base == timer->base)) in lock_hrtimer_base()
194 hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base) in hrtimer_check_target() argument
198 expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); in hrtimer_check_target()
226 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, in switch_hrtimer_base() argument
248 if (unlikely(hrtimer_callback_running(timer))) in switch_hrtimer_base()
252 WRITE_ONCE(timer->base, &migration_base); in switch_hrtimer_base()
257 hrtimer_check_target(timer, new_base)) { in switch_hrtimer_base()
261 WRITE_ONCE(timer->base, base); in switch_hrtimer_base()
264 WRITE_ONCE(timer->base, new_base); in switch_hrtimer_base()
267 hrtimer_check_target(timer, new_base)) { in switch_hrtimer_base()
283 lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in lock_hrtimer_base() argument
284 __acquires(&timer->base->cpu_base->lock) in lock_hrtimer_base()
286 struct hrtimer_clock_base *base = timer->base; in lock_hrtimer_base()
360 struct hrtimer *timer = addr; in hrtimer_fixup_init() local
364 hrtimer_cancel(timer); in hrtimer_fixup_init()
365 debug_object_init(timer, &hrtimer_debug_descr); in hrtimer_fixup_init()
394 struct hrtimer *timer = addr; in hrtimer_fixup_free() local
398 hrtimer_cancel(timer); in hrtimer_fixup_free()
399 debug_object_free(timer, &hrtimer_debug_descr); in hrtimer_fixup_free()
414 static inline void debug_hrtimer_init(struct hrtimer *timer) in debug_hrtimer_init() argument
416 debug_object_init(timer, &hrtimer_debug_descr); in debug_hrtimer_init()
419 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
422 debug_object_activate(timer, &hrtimer_debug_descr); in debug_hrtimer_activate()
425 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) in debug_hrtimer_deactivate() argument
427 debug_object_deactivate(timer, &hrtimer_debug_descr); in debug_hrtimer_deactivate()
430 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
433 void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init_on_stack() argument
436 debug_object_init_on_stack(timer, &hrtimer_debug_descr); in hrtimer_init_on_stack()
437 __hrtimer_init(timer, clock_id, mode); in hrtimer_init_on_stack()
447 debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr); in hrtimer_init_sleeper_on_stack()
452 void destroy_hrtimer_on_stack(struct hrtimer *timer) in destroy_hrtimer_on_stack() argument
454 debug_object_free(timer, &hrtimer_debug_descr); in destroy_hrtimer_on_stack()
460 static inline void debug_hrtimer_init(struct hrtimer *timer) { } in debug_hrtimer_init() argument
461 static inline void debug_hrtimer_activate(struct hrtimer *timer, in debug_hrtimer_activate() argument
463 static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } in debug_hrtimer_deactivate() argument
467 debug_init(struct hrtimer *timer, clockid_t clockid, in debug_init() argument
470 debug_hrtimer_init(timer); in debug_init()
471 trace_hrtimer_init(timer, clockid, mode); in debug_init()
474 static inline void debug_activate(struct hrtimer *timer, in debug_activate() argument
477 debug_hrtimer_activate(timer, mode); in debug_activate()
478 trace_hrtimer_start(timer, mode); in debug_activate()
481 static inline void debug_deactivate(struct hrtimer *timer) in debug_deactivate() argument
483 debug_hrtimer_deactivate(timer); in debug_deactivate()
484 trace_hrtimer_cancel(timer); in debug_deactivate()
514 struct hrtimer *timer; in __hrtimer_next_event_base() local
517 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
518 if (timer == exclude) { in __hrtimer_next_event_base()
524 timer = container_of(next, struct hrtimer, node); in __hrtimer_next_event_base()
526 expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in __hrtimer_next_event_base()
534 if (timer->is_soft) in __hrtimer_next_event_base()
535 cpu_base->softirq_next_timer = timer; in __hrtimer_next_event_base()
537 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()
1040 u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) in hrtimer_forward() argument
1045 delta = ktime_sub(now, hrtimer_get_expires(timer)); in hrtimer_forward()
1050 if (WARN_ON(timer->state & HRTIMER_STATE_ENQUEUED)) in hrtimer_forward()
1060 hrtimer_add_expires_ns(timer, incr * orun); in hrtimer_forward()
1061 if (hrtimer_get_expires_tv64(timer) > now) in hrtimer_forward()
1069 hrtimer_add_expires(timer, interval); in hrtimer_forward()
1083 static int enqueue_hrtimer(struct hrtimer *timer, in enqueue_hrtimer() argument
1087 debug_activate(timer, mode); in enqueue_hrtimer()
1093 WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED); in enqueue_hrtimer()
1095 return timerqueue_add(&base->active, &timer->node); in enqueue_hrtimer()
1108 static void __remove_hrtimer(struct hrtimer *timer, in __remove_hrtimer() argument
1113 u8 state = timer->state; in __remove_hrtimer()
1116 WRITE_ONCE(timer->state, newstate); in __remove_hrtimer()
1120 if (!timerqueue_del(&base->active, &timer->node)) in __remove_hrtimer()
1131 if (reprogram && timer == cpu_base->next_timer) in __remove_hrtimer()
1139 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in remove_hrtimer() argument
1142 u8 state = timer->state; in remove_hrtimer()
1155 debug_deactivate(timer); in remove_hrtimer()
1169 __remove_hrtimer(timer, base, state, reprogram); in remove_hrtimer()
1175 static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim, in hrtimer_update_lowres() argument
1184 timer->is_rel = mode & HRTIMER_MODE_REL; in hrtimer_update_lowres()
1185 if (timer->is_rel) in hrtimer_update_lowres()
1216 static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in __hrtimer_start_range_ns() argument
1232 force_local &= base->cpu_base->next_timer == timer; in __hrtimer_start_range_ns()
1245 remove_hrtimer(timer, base, true, force_local); in __hrtimer_start_range_ns()
1250 tim = hrtimer_update_lowres(timer, tim, mode); in __hrtimer_start_range_ns()
1252 hrtimer_set_expires_range_ns(timer, tim, delta_ns); in __hrtimer_start_range_ns()
1256 new_base = switch_hrtimer_base(timer, base, in __hrtimer_start_range_ns()
1262 first = enqueue_hrtimer(timer, new_base, mode); in __hrtimer_start_range_ns()
1284 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in hrtimer_start_range_ns() argument
1296 WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); in hrtimer_start_range_ns()
1298 WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); in hrtimer_start_range_ns()
1300 base = lock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1302 if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) in hrtimer_start_range_ns()
1303 hrtimer_reprogram(timer, true); in hrtimer_start_range_ns()
1305 unlock_hrtimer_base(timer, &flags); in hrtimer_start_range_ns()
1320 int hrtimer_try_to_cancel(struct hrtimer *timer) in hrtimer_try_to_cancel() argument
1332 if (!hrtimer_active(timer)) in hrtimer_try_to_cancel()
1335 base = lock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1337 if (!hrtimer_callback_running(timer)) in hrtimer_try_to_cancel()
1338 ret = remove_hrtimer(timer, base, false, false); in hrtimer_try_to_cancel()
1340 unlock_hrtimer_base(timer, &flags); in hrtimer_try_to_cancel()
1397 void hrtimer_cancel_wait_running(const struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
1400 struct hrtimer_clock_base *base = READ_ONCE(timer->base); in hrtimer_cancel_wait_running()
1406 if (!timer->is_soft || is_migration_base(base)) { in hrtimer_cancel_wait_running()
1442 int hrtimer_cancel(struct hrtimer *timer) in hrtimer_cancel() argument
1447 ret = hrtimer_try_to_cancel(timer); in hrtimer_cancel()
1450 hrtimer_cancel_wait_running(timer); in hrtimer_cancel()
1461 ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) in __hrtimer_get_remaining() argument
1466 lock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1468 rem = hrtimer_expires_remaining_adjusted(timer); in __hrtimer_get_remaining()
1470 rem = hrtimer_expires_remaining(timer); in __hrtimer_get_remaining()
1471 unlock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1545 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in __hrtimer_init() argument
1561 memset(timer, 0, sizeof(struct hrtimer)); in __hrtimer_init()
1575 timer->is_soft = softtimer; in __hrtimer_init()
1576 timer->is_hard = !!(mode & HRTIMER_MODE_HARD); in __hrtimer_init()
1577 timer->base = &cpu_base->clock_base[base]; in __hrtimer_init()
1578 timerqueue_init(&timer->node); in __hrtimer_init()
1593 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init() argument
1596 debug_init(timer, clock_id, mode); in hrtimer_init()
1597 __hrtimer_init(timer, clock_id, mode); in hrtimer_init()
1608 bool hrtimer_active(const struct hrtimer *timer) in hrtimer_active() argument
1614 base = READ_ONCE(timer->base); in hrtimer_active()
1617 if (timer->state != HRTIMER_STATE_INACTIVE || in hrtimer_active()
1618 base->running == timer) in hrtimer_active()
1622 base != READ_ONCE(timer->base)); in hrtimer_active()
1648 struct hrtimer *timer, ktime_t *now, in __run_hrtimer() argument
1657 debug_deactivate(timer); in __run_hrtimer()
1658 base->running = timer; in __run_hrtimer()
1669 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); in __run_hrtimer()
1670 fn = timer->function; in __run_hrtimer()
1678 timer->is_rel = false; in __run_hrtimer()
1686 trace_hrtimer_expire_entry(timer, now); in __run_hrtimer()
1687 expires_in_hardirq = lockdep_hrtimer_enter(timer); in __run_hrtimer()
1689 restart = fn(timer); in __run_hrtimer()
1692 trace_hrtimer_expire_exit(timer); in __run_hrtimer()
1705 !(timer->state & HRTIMER_STATE_ENQUEUED)) in __run_hrtimer()
1706 enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); in __run_hrtimer()
1717 WARN_ON_ONCE(base->running != timer); in __run_hrtimer()
1734 struct hrtimer *timer; in __hrtimer_run_queues() local
1736 timer = container_of(node, struct hrtimer, node); in __hrtimer_run_queues()
1750 if (basenow < hrtimer_get_softexpires_tv64(timer)) in __hrtimer_run_queues()
1753 __run_hrtimer(cpu_base, base, timer, &basenow, flags); in __hrtimer_run_queues()
1935 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) in hrtimer_wakeup() argument
1938 container_of(timer, struct hrtimer_sleeper, timer); in hrtimer_wakeup()
1966 if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) in hrtimer_sleeper_start_expires()
1969 hrtimer_start_expires(&sl->timer, mode); in hrtimer_sleeper_start_expires()
2000 __hrtimer_init(&sl->timer, clock_id, mode); in __hrtimer_init_sleeper()
2001 sl->timer.function = hrtimer_wakeup; in __hrtimer_init_sleeper()
2014 debug_init(&sl->timer, clock_id, mode); in hrtimer_init_sleeper()
2050 hrtimer_cancel(&t->timer); in do_nanosleep()
2062 ktime_t rem = hrtimer_expires_remaining(&t->timer); in do_nanosleep()
2081 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); in hrtimer_nanosleep_restart()
2083 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep_restart()
2100 hrtimer_set_expires_range_ns(&t.timer, rqtp, slack); in hrtimer_nanosleep()
2112 restart->nanosleep.clockid = t.timer.base->clockid; in hrtimer_nanosleep()
2113 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); in hrtimer_nanosleep()
2116 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep()
2197 struct hrtimer *timer; in migrate_hrtimer_list() local
2201 timer = container_of(node, struct hrtimer, node); in migrate_hrtimer_list()
2202 BUG_ON(hrtimer_callback_running(timer)); in migrate_hrtimer_list()
2203 debug_deactivate(timer); in migrate_hrtimer_list()
2210 __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); in migrate_hrtimer_list()
2211 timer->base = new_base; in migrate_hrtimer_list()
2220 enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); in migrate_hrtimer_list()
2307 hrtimer_set_expires_range_ns(&t.timer, *expires, delta); in schedule_hrtimeout_range_clock()
2313 hrtimer_cancel(&t.timer); in schedule_hrtimeout_range_clock()
2314 destroy_hrtimer_on_stack(&t.timer); in schedule_hrtimeout_range_clock()