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()
806 static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram) in hrtimer_reprogram() argument
809 struct hrtimer_clock_base *base = timer->base; in hrtimer_reprogram()
810 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); in hrtimer_reprogram()
812 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); in hrtimer_reprogram()
821 if (timer->is_soft) { in hrtimer_reprogram()
837 timer_cpu_base->softirq_next_timer = timer; in hrtimer_reprogram()
862 cpu_base->next_timer = timer; in hrtimer_reprogram()
864 __hrtimer_reprogram(cpu_base, timer, expires); in hrtimer_reprogram()
1013 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) in unlock_hrtimer_base() argument
1014 __releases(&timer->base->cpu_base->lock) in unlock_hrtimer_base()
1016 raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags); in unlock_hrtimer_base()
1038 u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval) in hrtimer_forward() argument
1043 delta = ktime_sub(now, hrtimer_get_expires(timer)); in hrtimer_forward()
1048 if (WARN_ON(timer->state & HRTIMER_STATE_ENQUEUED)) in hrtimer_forward()
1058 hrtimer_add_expires_ns(timer, incr * orun); in hrtimer_forward()
1059 if (hrtimer_get_expires_tv64(timer) > now) in hrtimer_forward()
1067 hrtimer_add_expires(timer, interval); in hrtimer_forward()
1081 static int enqueue_hrtimer(struct hrtimer *timer, in enqueue_hrtimer() argument
1085 debug_activate(timer, mode); in enqueue_hrtimer()
1091 WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED); in enqueue_hrtimer()
1093 return timerqueue_add(&base->active, &timer->node); in enqueue_hrtimer()
1106 static void __remove_hrtimer(struct hrtimer *timer, in __remove_hrtimer() argument
1111 u8 state = timer->state; in __remove_hrtimer()
1114 WRITE_ONCE(timer->state, newstate); in __remove_hrtimer()
1118 if (!timerqueue_del(&base->active, &timer->node)) in __remove_hrtimer()
1129 if (reprogram && timer == cpu_base->next_timer) in __remove_hrtimer()
1137 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, in remove_hrtimer() argument
1140 u8 state = timer->state; in remove_hrtimer()
1153 debug_deactivate(timer); in remove_hrtimer()
1167 __remove_hrtimer(timer, base, state, reprogram); in remove_hrtimer()
1173 static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim, in hrtimer_update_lowres() argument
1182 timer->is_rel = mode & HRTIMER_MODE_REL; in hrtimer_update_lowres()
1183 if (timer->is_rel) in hrtimer_update_lowres()
1214 static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in __hrtimer_start_range_ns() argument
1230 force_local &= base->cpu_base->next_timer == timer; in __hrtimer_start_range_ns()
1243 remove_hrtimer(timer, base, true, force_local); in __hrtimer_start_range_ns()
1248 tim = hrtimer_update_lowres(timer, tim, mode); in __hrtimer_start_range_ns()
1250 hrtimer_set_expires_range_ns(timer, tim, delta_ns); in __hrtimer_start_range_ns()
1254 new_base = switch_hrtimer_base(timer, base, in __hrtimer_start_range_ns()
1260 first = enqueue_hrtimer(timer, new_base, mode); in __hrtimer_start_range_ns()
1282 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, in hrtimer_start_range_ns() argument
1288 if (WARN_ON_ONCE(!timer->function)) in hrtimer_start_range_ns()
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()
1399 void hrtimer_cancel_wait_running(const struct hrtimer *timer) in hrtimer_cancel_wait_running() argument
1402 struct hrtimer_clock_base *base = READ_ONCE(timer->base); in hrtimer_cancel_wait_running()
1408 if (!timer->is_soft || is_migration_base(base)) { in hrtimer_cancel_wait_running()
1444 int hrtimer_cancel(struct hrtimer *timer) in hrtimer_cancel() argument
1449 ret = hrtimer_try_to_cancel(timer); in hrtimer_cancel()
1452 hrtimer_cancel_wait_running(timer); in hrtimer_cancel()
1463 ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) in __hrtimer_get_remaining() argument
1468 lock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1470 rem = hrtimer_expires_remaining_adjusted(timer); in __hrtimer_get_remaining()
1472 rem = hrtimer_expires_remaining(timer); in __hrtimer_get_remaining()
1473 unlock_hrtimer_base(timer, &flags); in __hrtimer_get_remaining()
1547 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in __hrtimer_init() argument
1563 memset(timer, 0, sizeof(struct hrtimer)); in __hrtimer_init()
1577 timer->is_soft = softtimer; in __hrtimer_init()
1578 timer->is_hard = !!(mode & HRTIMER_MODE_HARD); in __hrtimer_init()
1579 timer->base = &cpu_base->clock_base[base]; in __hrtimer_init()
1580 timerqueue_init(&timer->node); in __hrtimer_init()
1595 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, in hrtimer_init() argument
1598 debug_init(timer, clock_id, mode); in hrtimer_init()
1599 __hrtimer_init(timer, clock_id, mode); in hrtimer_init()
1610 bool hrtimer_active(const struct hrtimer *timer) in hrtimer_active() argument
1616 base = READ_ONCE(timer->base); in hrtimer_active()
1619 if (timer->state != HRTIMER_STATE_INACTIVE || in hrtimer_active()
1620 base->running == timer) in hrtimer_active()
1624 base != READ_ONCE(timer->base)); in hrtimer_active()
1650 struct hrtimer *timer, ktime_t *now, in __run_hrtimer() argument
1659 debug_deactivate(timer); in __run_hrtimer()
1660 base->running = timer; in __run_hrtimer()
1671 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); in __run_hrtimer()
1672 fn = timer->function; in __run_hrtimer()
1680 timer->is_rel = false; in __run_hrtimer()
1688 trace_hrtimer_expire_entry(timer, now); in __run_hrtimer()
1689 expires_in_hardirq = lockdep_hrtimer_enter(timer); in __run_hrtimer()
1691 restart = fn(timer); in __run_hrtimer()
1694 trace_hrtimer_expire_exit(timer); in __run_hrtimer()
1707 !(timer->state & HRTIMER_STATE_ENQUEUED)) in __run_hrtimer()
1708 enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); in __run_hrtimer()
1719 WARN_ON_ONCE(base->running != timer); in __run_hrtimer()
1736 struct hrtimer *timer; in __hrtimer_run_queues() local
1738 timer = container_of(node, struct hrtimer, node); in __hrtimer_run_queues()
1752 if (basenow < hrtimer_get_softexpires_tv64(timer)) in __hrtimer_run_queues()
1755 __run_hrtimer(cpu_base, base, timer, &basenow, flags); in __hrtimer_run_queues()
1919 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) in hrtimer_wakeup() argument
1922 container_of(timer, struct hrtimer_sleeper, timer); in hrtimer_wakeup()
1950 if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) in hrtimer_sleeper_start_expires()
1953 hrtimer_start_expires(&sl->timer, mode); in hrtimer_sleeper_start_expires()
1984 __hrtimer_init(&sl->timer, clock_id, mode); in __hrtimer_init_sleeper()
1985 sl->timer.function = hrtimer_wakeup; in __hrtimer_init_sleeper()
1998 debug_init(&sl->timer, clock_id, mode); in hrtimer_init_sleeper()
2034 hrtimer_cancel(&t->timer); in do_nanosleep()
2046 ktime_t rem = hrtimer_expires_remaining(&t->timer); in do_nanosleep()
2065 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); in hrtimer_nanosleep_restart()
2067 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep_restart()
2079 hrtimer_set_expires_range_ns(&t.timer, rqtp, current->timer_slack_ns); in hrtimer_nanosleep()
2091 restart->nanosleep.clockid = t.timer.base->clockid; in hrtimer_nanosleep()
2092 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); in hrtimer_nanosleep()
2095 destroy_hrtimer_on_stack(&t.timer); in hrtimer_nanosleep()
2176 struct hrtimer *timer; in migrate_hrtimer_list() local
2180 timer = container_of(node, struct hrtimer, node); in migrate_hrtimer_list()
2181 BUG_ON(hrtimer_callback_running(timer)); in migrate_hrtimer_list()
2182 debug_deactivate(timer); in migrate_hrtimer_list()
2189 __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); in migrate_hrtimer_list()
2190 timer->base = new_base; in migrate_hrtimer_list()
2199 enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); in migrate_hrtimer_list()
2277 hrtimer_set_expires_range_ns(&t.timer, *expires, delta); in schedule_hrtimeout_range_clock()
2283 hrtimer_cancel(&t.timer); in schedule_hrtimeout_range_clock()
2284 destroy_hrtimer_on_stack(&t.timer); in schedule_hrtimeout_range_clock()