Lines Matching refs:timer
552 static inline unsigned int timer_get_idx(struct timer_list *timer) in timer_get_idx() argument
554 return (timer->flags & TIMER_ARRAYMASK) >> TIMER_ARRAYSHIFT; in timer_get_idx()
557 static inline void timer_set_idx(struct timer_list *timer, unsigned int idx) in timer_set_idx() argument
559 timer->flags = (timer->flags & ~TIMER_ARRAYMASK) | in timer_set_idx()
623 trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) in trigger_dyntick_cpu() argument
632 if (!is_timers_nohz_active() || timer->flags & TIMER_DEFERRABLE) in trigger_dyntick_cpu()
644 WARN_ON_ONCE(!(timer->flags & TIMER_PINNED || in trigger_dyntick_cpu()
655 static void enqueue_timer(struct timer_base *base, struct timer_list *timer, in enqueue_timer() argument
659 hlist_add_head(&timer->entry, base->vectors + idx); in enqueue_timer()
661 timer_set_idx(timer, idx); in enqueue_timer()
663 trace_timer_start(timer, bucket_expiry); in enqueue_timer()
678 trigger_dyntick_cpu(base, timer); in enqueue_timer()
682 static void internal_add_timer(struct timer_base *base, struct timer_list *timer) in internal_add_timer() argument
687 idx = calc_wheel_index(timer->expires, base->clk, &bucket_expiry); in internal_add_timer()
688 enqueue_timer(base, timer, idx, bucket_expiry); in internal_add_timer()
709 struct delayed_work, timer, work.func),
711 struct kthread_delayed_work, timer, work.func),
716 struct timer_list *timer = addr; in timer_debug_hint() local
720 if (timer_hints[i].function == timer->function) { in timer_debug_hint()
727 return timer->function; in timer_debug_hint()
732 struct timer_list *timer = addr; in timer_is_static_object() local
734 return (timer->entry.pprev == NULL && in timer_is_static_object()
735 timer->entry.next == TIMER_ENTRY_STATIC); in timer_is_static_object()
744 struct timer_list *timer = addr; in timer_fixup_init() local
748 del_timer_sync(timer); in timer_fixup_init()
749 debug_object_init(timer, &timer_debug_descr); in timer_fixup_init()
769 struct timer_list *timer = addr; in timer_fixup_activate() local
773 timer_setup(timer, stub_timer, 0); in timer_fixup_activate()
790 struct timer_list *timer = addr; in timer_fixup_free() local
794 del_timer_sync(timer); in timer_fixup_free()
795 debug_object_free(timer, &timer_debug_descr); in timer_fixup_free()
808 struct timer_list *timer = addr; in timer_fixup_assert_init() local
812 timer_setup(timer, stub_timer, 0); in timer_fixup_assert_init()
829 static inline void debug_timer_init(struct timer_list *timer) in debug_timer_init() argument
831 debug_object_init(timer, &timer_debug_descr); in debug_timer_init()
834 static inline void debug_timer_activate(struct timer_list *timer) in debug_timer_activate() argument
836 debug_object_activate(timer, &timer_debug_descr); in debug_timer_activate()
839 static inline void debug_timer_deactivate(struct timer_list *timer) in debug_timer_deactivate() argument
841 debug_object_deactivate(timer, &timer_debug_descr); in debug_timer_deactivate()
844 static inline void debug_timer_assert_init(struct timer_list *timer) in debug_timer_assert_init() argument
846 debug_object_assert_init(timer, &timer_debug_descr); in debug_timer_assert_init()
849 static void do_init_timer(struct timer_list *timer,
854 void init_timer_on_stack_key(struct timer_list *timer, in init_timer_on_stack_key() argument
859 debug_object_init_on_stack(timer, &timer_debug_descr); in init_timer_on_stack_key()
860 do_init_timer(timer, func, flags, name, key); in init_timer_on_stack_key()
864 void destroy_timer_on_stack(struct timer_list *timer) in destroy_timer_on_stack() argument
866 debug_object_free(timer, &timer_debug_descr); in destroy_timer_on_stack()
871 static inline void debug_timer_init(struct timer_list *timer) { } in debug_timer_init() argument
872 static inline void debug_timer_activate(struct timer_list *timer) { } in debug_timer_activate() argument
873 static inline void debug_timer_deactivate(struct timer_list *timer) { } in debug_timer_deactivate() argument
874 static inline void debug_timer_assert_init(struct timer_list *timer) { } in debug_timer_assert_init() argument
877 static inline void debug_init(struct timer_list *timer) in debug_init() argument
879 debug_timer_init(timer); in debug_init()
880 trace_timer_init(timer); in debug_init()
883 static inline void debug_deactivate(struct timer_list *timer) in debug_deactivate() argument
885 debug_timer_deactivate(timer); in debug_deactivate()
886 trace_timer_cancel(timer); in debug_deactivate()
889 static inline void debug_assert_init(struct timer_list *timer) in debug_assert_init() argument
891 debug_timer_assert_init(timer); in debug_assert_init()
894 static void do_init_timer(struct timer_list *timer, in do_init_timer() argument
899 timer->entry.pprev = NULL; in do_init_timer()
900 timer->function = func; in do_init_timer()
903 timer->flags = flags | raw_smp_processor_id(); in do_init_timer()
904 lockdep_init_map(&timer->lockdep_map, name, key, 0); in do_init_timer()
919 void init_timer_key(struct timer_list *timer, in init_timer_key() argument
923 debug_init(timer); in init_timer_key()
924 do_init_timer(timer, func, flags, name, key); in init_timer_key()
928 static inline void detach_timer(struct timer_list *timer, bool clear_pending) in detach_timer() argument
930 struct hlist_node *entry = &timer->entry; in detach_timer()
932 debug_deactivate(timer); in detach_timer()
940 static int detach_if_pending(struct timer_list *timer, struct timer_base *base, in detach_if_pending() argument
943 unsigned idx = timer_get_idx(timer); in detach_if_pending()
945 if (!timer_pending(timer)) in detach_if_pending()
948 if (hlist_is_singular_node(&timer->entry, base->vectors + idx)) { in detach_if_pending()
953 detach_timer(timer, clear_pending); in detach_if_pending()
1034 static struct timer_base *lock_timer_base(struct timer_list *timer, in lock_timer_base() argument
1036 __acquires(timer->base->lock) in lock_timer_base()
1047 tf = READ_ONCE(timer->flags); in lock_timer_base()
1052 if (timer->flags == tf) in lock_timer_base()
1065 __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int options) in __mod_timer() argument
1072 debug_assert_init(timer); in __mod_timer()
1079 if (!(options & MOD_TIMER_NOTPENDING) && timer_pending(timer)) { in __mod_timer()
1085 long diff = timer->expires - expires; in __mod_timer()
1098 base = lock_timer_base(timer, &flags); in __mod_timer()
1104 if (!timer->function) in __mod_timer()
1109 if (timer_pending(timer) && (options & MOD_TIMER_REDUCE) && in __mod_timer()
1110 time_before_eq(timer->expires, expires)) { in __mod_timer()
1123 if (idx == timer_get_idx(timer)) { in __mod_timer()
1125 timer->expires = expires; in __mod_timer()
1126 else if (time_after(timer->expires, expires)) in __mod_timer()
1127 timer->expires = expires; in __mod_timer()
1132 base = lock_timer_base(timer, &flags); in __mod_timer()
1138 if (!timer->function) in __mod_timer()
1144 ret = detach_if_pending(timer, base, false); in __mod_timer()
1148 new_base = get_timer_this_cpu_base(timer->flags); in __mod_timer()
1158 if (likely(base->running_timer != timer)) { in __mod_timer()
1160 timer->flags |= TIMER_MIGRATING; in __mod_timer()
1165 WRITE_ONCE(timer->flags, in __mod_timer()
1166 (timer->flags & ~TIMER_BASEMASK) | base->cpu); in __mod_timer()
1171 debug_timer_activate(timer); in __mod_timer()
1173 timer->expires = expires; in __mod_timer()
1181 enqueue_timer(base, timer, idx, bucket_expiry); in __mod_timer()
1183 internal_add_timer(base, timer); in __mod_timer()
1207 int mod_timer_pending(struct timer_list *timer, unsigned long expires) in mod_timer_pending() argument
1209 return __mod_timer(timer, expires, MOD_TIMER_PENDING_ONLY); in mod_timer_pending()
1240 int mod_timer(struct timer_list *timer, unsigned long expires) in mod_timer() argument
1242 return __mod_timer(timer, expires, 0); in mod_timer()
1266 int timer_reduce(struct timer_list *timer, unsigned long expires) in timer_reduce() argument
1268 return __mod_timer(timer, expires, MOD_TIMER_REDUCE); in timer_reduce()
1292 void add_timer(struct timer_list *timer) in add_timer() argument
1294 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer()
1296 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer()
1308 void add_timer_local(struct timer_list *timer) in add_timer_local() argument
1310 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_local()
1312 timer->flags |= TIMER_PINNED; in add_timer_local()
1313 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer_local()
1325 void add_timer_global(struct timer_list *timer) in add_timer_global() argument
1327 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_global()
1329 timer->flags &= ~TIMER_PINNED; in add_timer_global()
1330 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer_global()
1346 void add_timer_on(struct timer_list *timer, int cpu) in add_timer_on() argument
1351 debug_assert_init(timer); in add_timer_on()
1353 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_on()
1357 timer->flags |= TIMER_PINNED; in add_timer_on()
1359 new_base = get_timer_cpu_base(timer->flags, cpu); in add_timer_on()
1366 base = lock_timer_base(timer, &flags); in add_timer_on()
1371 if (!timer->function) in add_timer_on()
1375 timer->flags |= TIMER_MIGRATING; in add_timer_on()
1380 WRITE_ONCE(timer->flags, in add_timer_on()
1381 (timer->flags & ~TIMER_BASEMASK) | cpu); in add_timer_on()
1385 debug_timer_activate(timer); in add_timer_on()
1386 internal_add_timer(base, timer); in add_timer_on()
1407 static int __timer_delete(struct timer_list *timer, bool shutdown) in __timer_delete() argument
1413 debug_assert_init(timer); in __timer_delete()
1426 if (timer_pending(timer) || shutdown) { in __timer_delete()
1427 base = lock_timer_base(timer, &flags); in __timer_delete()
1428 ret = detach_if_pending(timer, base, true); in __timer_delete()
1430 timer->function = NULL; in __timer_delete()
1451 int timer_delete(struct timer_list *timer) in timer_delete() argument
1453 return __timer_delete(timer, false); in timer_delete()
1472 int timer_shutdown(struct timer_list *timer) in timer_shutdown() argument
1474 return __timer_delete(timer, true); in timer_shutdown()
1498 static int __try_to_del_timer_sync(struct timer_list *timer, bool shutdown) in __try_to_del_timer_sync() argument
1504 debug_assert_init(timer); in __try_to_del_timer_sync()
1506 base = lock_timer_base(timer, &flags); in __try_to_del_timer_sync()
1508 if (base->running_timer != timer) in __try_to_del_timer_sync()
1509 ret = detach_if_pending(timer, base, true); in __try_to_del_timer_sync()
1511 timer->function = NULL; in __try_to_del_timer_sync()
1534 int try_to_del_timer_sync(struct timer_list *timer) in try_to_del_timer_sync() argument
1536 return __try_to_del_timer_sync(timer, false); in try_to_del_timer_sync()
1585 static void del_timer_wait_running(struct timer_list *timer) in del_timer_wait_running() argument
1589 tf = READ_ONCE(timer->flags); in del_timer_wait_running()
1612 static inline void del_timer_wait_running(struct timer_list *timer) { } in del_timer_wait_running() argument
1637 static int __timer_delete_sync(struct timer_list *timer, bool shutdown) in __timer_delete_sync() argument
1649 lock_map_acquire(&timer->lockdep_map); in __timer_delete_sync()
1650 lock_map_release(&timer->lockdep_map); in __timer_delete_sync()
1657 WARN_ON(in_hardirq() && !(timer->flags & TIMER_IRQSAFE)); in __timer_delete_sync()
1663 if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE)) in __timer_delete_sync()
1667 ret = __try_to_del_timer_sync(timer, shutdown); in __timer_delete_sync()
1670 del_timer_wait_running(timer); in __timer_delete_sync()
1720 int timer_delete_sync(struct timer_list *timer) in timer_delete_sync() argument
1722 return __timer_delete_sync(timer, false); in timer_delete_sync()
1762 int timer_shutdown_sync(struct timer_list *timer) in timer_shutdown_sync() argument
1764 return __timer_delete_sync(timer, true); in timer_shutdown_sync()
1768 static void call_timer_fn(struct timer_list *timer, in call_timer_fn() argument
1784 lockdep_copy_map(&lockdep_map, &timer->lockdep_map); in call_timer_fn()
1793 trace_timer_expire_entry(timer, baseclk); in call_timer_fn()
1794 fn(timer); in call_timer_fn()
1795 trace_timer_expire_exit(timer); in call_timer_fn()
1822 struct timer_list *timer; in expire_timers() local
1825 timer = hlist_entry(head->first, struct timer_list, entry); in expire_timers()
1827 base->running_timer = timer; in expire_timers()
1828 detach_timer(timer, true); in expire_timers()
1830 fn = timer->function; in expire_timers()
1838 if (timer->flags & TIMER_IRQSAFE) { in expire_timers()
1840 call_timer_fn(timer, fn, baseclk); in expire_timers()
1845 call_timer_fn(timer, fn, baseclk); in expire_timers()
2534 struct timer_list timer; member
2540 struct process_timer *timeout = from_timer(timeout, t, timer); in process_timeout()
2578 struct process_timer timer; in schedule_timeout() local
2612 timer.task = current; in schedule_timeout()
2613 timer_setup_on_stack(&timer.timer, process_timeout, 0); in schedule_timeout()
2614 __mod_timer(&timer.timer, expire, MOD_TIMER_NOTPENDING); in schedule_timeout()
2616 del_timer_sync(&timer.timer); in schedule_timeout()
2619 destroy_timer_on_stack(&timer.timer); in schedule_timeout()
2667 struct timer_list *timer; in migrate_timer_list() local
2671 timer = hlist_entry(head->first, struct timer_list, entry); in migrate_timer_list()
2672 detach_timer(timer, false); in migrate_timer_list()
2673 timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu; in migrate_timer_list()
2674 internal_add_timer(new_base, timer); in migrate_timer_list()