Lines Matching full:timer

16  *  2000-10-05  Implemented scalable SMP per-CPU timer handling.
59 #include <trace/events/timer.h>
66 * The timer wheel has LVL_DEPTH array levels. Each level provides an array of
73 * The array level of a newly armed timer depends on the relative expiry
77 * Contrary to the original timer wheel implementation, which aims for 'exact'
79 * the timers into the lower array levels. The previous 'classic' timer wheel
84 * This is an optimization of the original timer wheel implementation for the
85 * majority of the timer wheel use cases: timeouts. The vast majority of
207 * struct timer_base - Per CPU timer base (number of base depends on config)
211 * currently running timer, the pointer is set to the
212 * timer, which expires at the moment. If no timer is
215 * timer expiry callback execution and when trying to
216 * delete a running timer and it wasn't successful in
219 * caller tries to delete the running timer. It also
221 * delete a timer preempted the softirq thread which
222 * is running the timer callback function.
224 * waiting for the end of the timer callback function
226 * @clk: clock of the timer base; is updated before enqueue
227 * of a timer; during expiry, it is 1 offset ahead of
230 * @next_expiry: expiry value of the first timer; it is updated when
231 * finding the next timer and during enqueue; the
233 * @cpu: Number of CPU the timer base belongs to
235 * required. Value is set true, when a timer was
242 * @timers_pending: Is set, when a timer is pending in the base. It is only
244 * @pending_map: bitmap of the timer wheel; each bit reflects a
246 * single timer is enqueued in the related bucket.
248 * of the timer wheel. The list contains all timers
369 * due to delays of the timer irq, long irq off times etc etc) then in round_jiffies_common()
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()
572 * The timer wheel has to guarantee that a timer does not fire in calc_index()
574 * - Timer is armed at the edge of a tick in calc_index()
623 trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) in trigger_dyntick_cpu() argument
628 * new deferrable timer is enqueued will wake up the remote CPU but in trigger_dyntick_cpu()
629 * nothing will be done with the deferrable timer base. Therefore skip in trigger_dyntick_cpu()
632 if (!is_timers_nohz_active() || timer->flags & TIMER_DEFERRABLE) in trigger_dyntick_cpu()
637 * timer is pinned. If it is a non pinned timer, it is only queued in trigger_dyntick_cpu()
638 * on the remote CPU, when timer was running during queueing. Then in trigger_dyntick_cpu()
644 WARN_ON_ONCE(!(timer->flags & TIMER_PINNED || in trigger_dyntick_cpu()
651 * Enqueue the timer into the hash bucket, mark it pending in
652 * the bitmap, store the index in the timer flags then wake up
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()
666 * Check whether this is the new first expiring timer. The in enqueue_timer()
667 * effective expiry time of the timer is required here in enqueue_timer()
668 * (bucket_expiry) instead of timer->expires. 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()
756 /* Stub timer callback for improperly used timers. */
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()
908 * init_timer_key - initialize a timer
909 * @timer: the timer to be initialized
910 * @func: timer callback function
911 * @flags: timer flags
912 * @name: name of the timer
913 * @key: lockdep class key of the fake lock used for tracking timer
916 * init_timer_key() must be done to a timer prior to calling *any* of the
917 * other timer functions.
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()
965 * If the timer is deferrable and NO_HZ_COMMON is set then we need in get_timer_cpu_base()
981 * If the timer is deferrable and NO_HZ_COMMON is set then we need in get_timer_this_cpu_base()
1031 * When a timer is migrating then the TIMER_MIGRATING flag is set and we need
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()
1076 * the timer is re-modified to have the same timeout or ends up in the in __mod_timer()
1079 if (!(options & MOD_TIMER_NOTPENDING) && timer_pending(timer)) { in __mod_timer()
1083 * timer with this expiry. in __mod_timer()
1085 long diff = timer->expires - expires; in __mod_timer()
1093 * We lock timer base and calculate the bucket index right in __mod_timer()
1094 * here. If the timer ends up in the same bucket, then we in __mod_timer()
1098 base = lock_timer_base(timer, &flags); in __mod_timer()
1100 * Has @timer been shutdown? This needs to be evaluated 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()
1120 * timer. If it matches set the expiry to the new value so a 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()
1134 * Has @timer been shutdown? This needs to be evaluated 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()
1152 * We are trying to schedule the timer on the new base. in __mod_timer()
1153 * However we can't change timer's base while it is running, in __mod_timer()
1154 * otherwise timer_delete_sync() can't detect that the timer's in __mod_timer()
1156 * timer is serialized wrt itself. 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()
1192 * mod_timer_pending - Modify a pending timer's timeout
1193 * @timer: The pending timer to be modified
1199 * If @timer->function == NULL then the start operation is silently
1203 * * %0 - The timer was inactive and not modified or was in
1205 * * %1 - The timer was active and requeued to expire at @expires
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()
1214 * mod_timer - Modify a timer's timeout
1215 * @timer: The timer to be modified
1218 * mod_timer(timer, expires) is equivalent to:
1220 * del_timer(timer); timer->expires = expires; add_timer(timer);
1223 * case that the timer is inactive, the del_timer() part is a NOP. The
1224 * timer is in any case activated with the new expiry time @expires.
1227 * same timer, then mod_timer() is the only safe way to modify the timeout,
1228 * since add_timer() cannot modify an already running timer.
1230 * If @timer->function == NULL then the start operation is silently
1234 * * %0 - The timer was inactive and started or was in shutdown
1236 * * %1 - The timer was active and requeued to expire at @expires or
1237 * the timer was active and not modified because @expires did
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()
1247 * timer_reduce - Modify a timer's timeout if it would reduce the timeout
1248 * @timer: The timer to be modified
1252 * modify an enqueued timer if that would reduce the expiration time. If
1253 * @timer is not enqueued it starts the timer.
1255 * If @timer->function == NULL then the start operation is silently
1259 * * %0 - The timer was inactive and started or was in shutdown
1261 * * %1 - The timer was active and requeued to expire at @expires or
1262 * the timer was active and not modified because @expires
1264 * timer would expire earlier than already scheduled
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()
1273 * add_timer - Start a timer
1274 * @timer: The timer to be started
1276 * Start @timer to expire at @timer->expires in the future. @timer->expires
1277 * is the absolute expiry time measured in 'jiffies'. When the timer expires
1278 * timer->function(timer) will be invoked from soft interrupt context.
1280 * The @timer->expires and @timer->function fields must be set prior
1283 * If @timer->function == NULL then the start operation is silently
1286 * If @timer->expires is already in the past @timer will be queued to
1287 * expire at the next timer tick.
1289 * This can only operate on an inactive timer. Attempts to invoke this on
1290 * an active timer are rejected with a warning.
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()
1301 * add_timer_local() - Start a timer on the local CPU
1302 * @timer: The timer to be started
1304 * Same as add_timer() except that the timer flag TIMER_PINNED is set.
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()
1318 * add_timer_global() - Start a timer without TIMER_PINNED flag set
1319 * @timer: The timer to be started
1321 * Same as add_timer() except that the timer flag TIMER_PINNED is unset.
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()
1335 * add_timer_on - Start a timer on a particular CPU
1336 * @timer: The timer to be started
1339 * Same as add_timer() except that it starts the timer on the given CPU and
1340 * the TIMER_PINNED flag is set. When timer shouldn't be a pinned timer in
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()
1356 /* Make sure timer flags have TIMER_PINNED flag set */ 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()
1362 * If @timer was on a different CPU, it should be migrated with the in add_timer_on()
1366 base = lock_timer_base(timer, &flags); in add_timer_on()
1368 * Has @timer been shutdown? This needs to be evaluated while 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()
1393 * __timer_delete - Internal function: Deactivate a timer
1394 * @timer: The timer to be deactivated
1395 * @shutdown: If true, this indicates that the timer is about to be
1398 * If @shutdown is true then @timer->function is set to NULL under the
1399 * timer base lock which prevents further rearming of the time. In that
1400 * case any attempt to rearm @timer after this function returns will be
1404 * * %0 - The timer was not pending
1405 * * %1 - The timer was pending and deactivated
1407 static int __timer_delete(struct timer_list *timer, bool shutdown) in __timer_delete() argument
1413 debug_assert_init(timer); in __timer_delete()
1417 * timer is pending or not to protect against a concurrent rearm in __timer_delete()
1420 * enqueued timer is dequeued and cannot end up with in __timer_delete()
1421 * timer->function == NULL in the expiry code. in __timer_delete()
1423 * If timer->function is currently executed, then this makes sure in __timer_delete()
1424 * that the callback cannot requeue the 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()
1438 * timer_delete - Deactivate a timer
1439 * @timer: The timer to be deactivated
1441 * The function only deactivates a pending timer, but contrary to
1442 * timer_delete_sync() it does not take into account whether the timer's
1444 * It neither prevents rearming of the timer. If @timer can be rearmed
1448 * * %0 - The timer was not pending
1449 * * %1 - The timer was pending and deactivated
1451 int timer_delete(struct timer_list *timer) in timer_delete() argument
1453 return __timer_delete(timer, false); in timer_delete()
1458 * timer_shutdown - Deactivate a timer and prevent rearming
1459 * @timer: The timer to be deactivated
1461 * The function does not wait for an eventually running timer callback on a
1462 * different CPU but it prevents rearming of the timer. Any attempt to arm
1463 * @timer after this function returns will be silently ignored.
1469 * * %0 - The timer was not pending
1470 * * %1 - The timer was pending
1472 int timer_shutdown(struct timer_list *timer) in timer_shutdown() argument
1474 return __timer_delete(timer, true); in timer_shutdown()
1479 * __try_to_del_timer_sync - Internal function: Try to deactivate a timer
1480 * @timer: Timer to deactivate
1481 * @shutdown: If true, this indicates that the timer is about to be
1484 * If @shutdown is true then @timer->function is set to NULL under the
1485 * timer base lock which prevents further rearming of the timer. Any
1486 * attempt to rearm @timer after this function returns will be silently
1489 * This function cannot guarantee that the timer cannot be rearmed
1494 * * %0 - The timer was not pending
1495 * * %1 - The timer was pending and deactivated
1496 * * %-1 - The timer callback function is running on a different CPU
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()
1519 * try_to_del_timer_sync - Try to deactivate a timer
1520 * @timer: Timer to deactivate
1522 * This function tries to deactivate a timer. On success the timer is not
1523 * queued and the timer callback function is not running on any CPU.
1525 * This function does not guarantee that the timer cannot be rearmed right
1530 * * %0 - The timer was not pending
1531 * * %1 - The timer was pending and deactivated
1532 * * %-1 - The timer callback function is running on a different CPU
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()
1560 * timer callback to finish. Drop expiry_lock and reacquire it. That allows
1577 * deletion of a timer failed because the timer callback function was
1582 * delete a timer preempted the softirq thread running the timer callback
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()
1595 * which is held by the softirq across the timer in del_timer_wait_running()
1597 * expire the next timer. In theory the timer could already in del_timer_wait_running()
1612 static inline void del_timer_wait_running(struct timer_list *timer) { } in del_timer_wait_running() argument
1616 * __timer_delete_sync - Internal function: Deactivate a timer and wait
1618 * @timer: The timer to be deactivated
1619 * @shutdown: If true, @timer->function will be set to NULL under the
1620 * timer base lock which prevents rearming of @timer
1622 * If @shutdown is not set the timer can be rearmed later. If the timer can
1626 * If @shutdown is set then @timer->function is set to NULL under timer
1627 * base lock which prevents rearming of the timer. Any attempt to rearm
1628 * a shutdown timer is silently ignored.
1630 * If the timer should be reused after shutdown it has to be initialized
1634 * * %0 - The timer was not pending
1635 * * %1 - The timer was pending and deactivated
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()
1679 * timer_delete_sync - Deactivate a timer and wait for the handler to finish.
1680 * @timer: The timer to be deactivated
1682 * Synchronization rules: Callers must prevent restarting of the timer,
1684 * interrupt contexts unless the timer is an irqsafe one. The caller must
1685 * not hold locks which would prevent completion of the timer's callback
1686 * function. The timer's handler must not call add_timer_on(). Upon exit
1687 * the timer is not queued and the handler is not running on any CPU.
1690 * interrupt context. Even if the lock has nothing to do with the timer in
1708 * This function cannot guarantee that the timer is not rearmed again by
1717 * * %0 - The timer was not pending
1718 * * %1 - The timer was pending and deactivated
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()
1727 * timer_shutdown_sync - Shutdown a timer and prevent rearming
1728 * @timer: The timer to be shutdown
1731 * - @timer is not queued
1732 * - The callback function of @timer is not running
1733 * - @timer cannot be enqueued again. Any attempt to rearm
1734 * @timer is silently ignored.
1739 * the timer is subject to a circular dependency problem.
1741 * A common pattern for this is a timer and a workqueue where the timer can
1742 * schedule work and work can arm the timer. On shutdown the workqueue must
1743 * be destroyed and the timer must be prevented from rearming. Unless the
1750 * timer_shutdown_sync(&mything->timer);
1755 * This obviously implies that the timer is not required to be functional
1759 * * %0 - The timer was not pending
1760 * * %1 - The timer was pending
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
1776 * It is permissible to free the timer from inside the in call_timer_fn()
1780 * timer->lockdep_map, make a copy and use that here. in call_timer_fn()
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()
1800 WARN_ONCE(1, "timer: %pS preempt leak: %08x -> %08x\n", 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()
1898 * Search the first expiring timer in the various clock levels. Caller must
1976 * Check, if the next hrtimer event is before the next timer wheel
1991 * If the next timer is already expired, return the tick base in cmp_next_hrtimer_event()
2000 * make sure that this tick really expires the timer to avoid in cmp_next_hrtimer_event()
2016 * unnecessary raise of the timer softirq when the next_expiry value in next_timer_interrupt()
2017 * will be reached even if there is no timer pending. in next_timer_interrupt()
2020 * easy comparable to find out which base holds the first pending timer. in next_timer_interrupt()
2061 * timer, it is possible that it will be missed completely. in fetch_next_timer_interrupt()
2094 * Stores the next pending local and global timer expiry values in the
2099 * Caller needs to make sure timer base locks are held (use
2121 * timer_unlock_remote_bases - unlock timer bases of cpu
2124 * Unlocks the remote timer bases.
2140 * timer_lock_remote_bases - lock timer bases of cpu
2143 * Locks the remote timer bases.
2161 * timer_base_is_idle() - Return whether timer base is set idle
2163 * Returns value of local timer base is_idle value.
2199 * If the CPU is the last going idle in timer migration hierarchy, make in timer_use_tmigr()
2223 * timer on !SMP systems. in timer_use_tmigr()
2258 * timer migration hierarchy related functions. The value for the next in __get_next_timer_interrupt()
2259 * global timer in @tevt struct equals then KTIME_MAX. This is also in __get_next_timer_interrupt()
2260 * true, when the timer base is idle. in __get_next_timer_interrupt()
2262 * The proper timer migration hierarchy function depends on the callsite in __get_next_timer_interrupt()
2263 * and whether timer base is idle or not. @nextevt will be updated when in __get_next_timer_interrupt()
2264 * this CPU needs to handle the first timer migration hierarchy in __get_next_timer_interrupt()
2286 * global timer into timer migration hierarchy. Therefore a new in __get_next_timer_interrupt()
2289 * If the base is marked idle then any timer add operation must in __get_next_timer_interrupt()
2309 * When timer base is not set idle, undo the effect of in __get_next_timer_interrupt()
2311 * timer base but inactive timer migration hierarchy. in __get_next_timer_interrupt()
2313 * When timer base was already marked idle, nothing will be in __get_next_timer_interrupt()
2327 * get_next_timer_interrupt() - return the time (clock mono) of the next timer
2331 * Returns the tick aligned clock monotonic time of the next pending timer or
2332 * KTIME_MAX if no timer is pending. If timer of global base was queued into
2333 * timer migration hierarchy, first global timer is not taken into account. If
2334 * it was the last CPU of timer migration hierarchy going idle, first global
2343 * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases
2349 * Returns the tick aligned clock monotonic time of the next pending timer or
2350 * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is
2362 * timer_clear_idle - Clear the idle state of the timer base
2369 * We do this unlocked. The worst outcome is a remote pinned timer in timer_clear_idle()
2387 * @base: the timer vector to be processed.
2404 * timer at this clk are that all matching timers have been in __run_timers()
2405 * dequeued or no timer has been queued since in __run_timers()
2443 * This function runs timers and the timer-tq in bottom half context.
2458 * Called by the local, per-CPU timer interrupt on SMP.
2481 * worst outcome is a superfluous raise of the timer softirq in run_local_timers()
2484 * 2. A new first pinned timer is enqueued by a remote CPU in run_local_timers()
2489 * is missed, then the timer would expire one jiffy late - in run_local_timers()
2509 * Called from the timer interrupt handler to charge one tick to the current
2516 /* Note: this timer irq context must be accounted for as well. */ in update_process_times()
2530 * Since schedule_timeout()'s timer is defined on the stack, it must store
2534 struct timer_list timer; member
2540 struct process_timer *timeout = from_timer(timeout, t, timer); in process_timeout()
2572 * Returns 0 when the timer has expired otherwise the remaining time in
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()
2618 /* Remove the timer from the object tracker */ 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()