Lines Matching +full:local +full:- +full:timer +full:- +full:stop

1 // SPDX-License-Identifier: GPL-2.0
7 * 1997-01-28 Modified by Finn Arne Gangstad to make timers scale better.
9 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
11 * 1998-12-24 Fixed a xtime SMP race (we need the xtime_lock rw spinlock to
14 * 1999-03-10 Improved NTP compatibility by Ulrich Windl
15 * 2002-05-31 Move sys_sysinfo here and make its locking sane, Robert Love
16 * 2000-10-05 Implemented scalable SMP per-CPU timer handling.
33 #include <linux/posix-timers.h>
54 #include "tick-internal.h"
58 #include <trace/events/timer.h>
65 * The timer wheel has LVL_DEPTH array levels. Each level provides an array of
72 * The array level of a newly armed timer depends on the relative expiry
76 * Contrary to the original timer wheel implementation, which aims for 'exact'
78 * the timers into the lower array levels. The previous 'classic' timer wheel
83 * This is an optimization of the original timer wheel implementation for the
84 * majority of the timer wheel use cases: timeouts. The vast majority of
106 * 0 0 1 ms 0 ms - 63 ms
107 * 1 64 8 ms 64 ms - 511 ms
108 * 2 128 64 ms 512 ms - 4095 ms (512ms - ~4s)
109 * 3 192 512 ms 4096 ms - 32767 ms (~4s - ~32s)
110 * 4 256 4096 ms (~4s) 32768 ms - 262143 ms (~32s - ~4m)
111 * 5 320 32768 ms (~32s) 262144 ms - 2097151 ms (~4m - ~34m)
112 * 6 384 262144 ms (~4m) 2097152 ms - 16777215 ms (~34m - ~4h)
113 * 7 448 2097152 ms (~34m) 16777216 ms - 134217727 ms (~4h - ~1d)
114 * 8 512 16777216 ms (~4h) 134217728 ms - 1073741822 ms (~1d - ~12d)
118 * 0 0 3 ms 0 ms - 210 ms
119 * 1 64 26 ms 213 ms - 1703 ms (213ms - ~1s)
120 * 2 128 213 ms 1706 ms - 13650 ms (~1s - ~13s)
121 * 3 192 1706 ms (~1s) 13653 ms - 109223 ms (~13s - ~1m)
122 * 4 256 13653 ms (~13s) 109226 ms - 873810 ms (~1m - ~14m)
123 * 5 320 109226 ms (~1m) 873813 ms - 6990503 ms (~14m - ~1h)
124 * 6 384 873813 ms (~14m) 6990506 ms - 55924050 ms (~1h - ~15h)
125 * 7 448 6990506 ms (~1h) 55924053 ms - 447392423 ms (~15h - ~5d)
126 * 8 512 55924053 ms (~15h) 447392426 ms - 3579139406 ms (~5d - ~41d)
130 * 0 0 4 ms 0 ms - 255 ms
131 * 1 64 32 ms 256 ms - 2047 ms (256ms - ~2s)
132 * 2 128 256 ms 2048 ms - 16383 ms (~2s - ~16s)
133 * 3 192 2048 ms (~2s) 16384 ms - 131071 ms (~16s - ~2m)
134 * 4 256 16384 ms (~16s) 131072 ms - 1048575 ms (~2m - ~17m)
135 * 5 320 131072 ms (~2m) 1048576 ms - 8388607 ms (~17m - ~2h)
136 * 6 384 1048576 ms (~17m) 8388608 ms - 67108863 ms (~2h - ~18h)
137 * 7 448 8388608 ms (~2h) 67108864 ms - 536870911 ms (~18h - ~6d)
138 * 8 512 67108864 ms (~18h) 536870912 ms - 4294967288 ms (~6d - ~49d)
142 * 0 0 10 ms 0 ms - 630 ms
143 * 1 64 80 ms 640 ms - 5110 ms (640ms - ~5s)
144 * 2 128 640 ms 5120 ms - 40950 ms (~5s - ~40s)
145 * 3 192 5120 ms (~5s) 40960 ms - 327670 ms (~40s - ~5m)
146 * 4 256 40960 ms (~40s) 327680 ms - 2621430 ms (~5m - ~43m)
147 * 5 320 327680 ms (~5m) 2621440 ms - 20971510 ms (~43m - ~5h)
148 * 6 384 2621440 ms (~43m) 20971520 ms - 167772150 ms (~5h - ~1d)
149 * 7 448 20971520 ms (~5h) 167772160 ms - 1342177270 ms (~1d - ~15d)
155 #define LVL_CLK_MASK (LVL_CLK_DIV - 1)
164 #define LVL_START(n) ((LVL_SIZE - 1) << (((n) - 1) * LVL_CLK_SHIFT))
169 #define LVL_MASK (LVL_SIZE - 1)
181 #define WHEEL_TIMEOUT_MAX (WHEEL_TIMEOUT_CUTOFF - LVL_GRAN(LVL_DEPTH - 1))
206 * struct timer_base - Per CPU timer base (number of base depends on config)
210 * currently running timer, the pointer is set to the
211 * timer, which expires at the moment. If no timer is
214 * timer expiry callback execution and when trying to
215 * delete a running timer and it wasn't successful in
218 * caller tries to delete the running timer. It also
220 * delete a timer preempted the softirq thread which
221 * is running the timer callback function.
223 * waiting for the end of the timer callback function
225 * @clk: clock of the timer base; is updated before enqueue
226 * of a timer; during expiry, it is 1 offset ahead of
229 * @next_expiry: expiry value of the first timer; it is updated when
230 * finding the next timer and during enqueue; the
232 * @cpu: Number of CPU the timer base belongs to
234 * required. Value is set true, when a timer was
241 * @timers_pending: Is set, when a timer is pending in the base. It is only
243 * @pending_map: bitmap of the timer wheel; each bit reflects a
245 * single timer is enqueued in the related bucket.
247 * of the timer wheel. The list contains all timers
368 * due to delays of the timer irq, long irq off times etc etc) then in round_jiffies_common()
374 j = j - rem; in round_jiffies_common()
376 j = j - rem + HZ; in round_jiffies_common()
379 j -= cpu * 3; in round_jiffies_common()
389 * __round_jiffies_relative - function to round jiffies to a full second
413 return round_jiffies_common(j + j0, cpu, false) - j0; in __round_jiffies_relative()
418 * round_jiffies - function to round jiffies to a full second
439 * round_jiffies_relative - function to round jiffies to a full second
460 * __round_jiffies_up_relative - function to round jiffies up to a full second
474 return round_jiffies_common(j + j0, cpu, true) - j0; in __round_jiffies_up_relative()
479 * round_jiffies_up - function to round jiffies up to a full second
494 * round_jiffies_up_relative - function to round jiffies up to a full second
509 static inline unsigned int timer_get_idx(struct timer_list *timer) in timer_get_idx() argument
511 return (timer->flags & TIMER_ARRAYMASK) >> TIMER_ARRAYSHIFT; in timer_get_idx()
514 static inline void timer_set_idx(struct timer_list *timer, unsigned int idx) in timer_set_idx() argument
516 timer->flags = (timer->flags & ~TIMER_ARRAYMASK) | in timer_set_idx()
529 * The timer wheel has to guarantee that a timer does not fire in calc_index()
531 * - Timer is armed at the edge of a tick in calc_index()
532 * - Truncation of the expiry time in the outer wheel levels in calc_index()
544 unsigned long delta = expires - clk; in calc_wheel_index()
574 idx = calc_index(expires, LVL_DEPTH - 1, bucket_expiry); in calc_wheel_index()
580 trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) in trigger_dyntick_cpu() argument
585 * new deferrable timer is enqueued will wake up the remote CPU but in trigger_dyntick_cpu()
586 * nothing will be done with the deferrable timer base. Therefore skip in trigger_dyntick_cpu()
589 if (!is_timers_nohz_active() || timer->flags & TIMER_DEFERRABLE) in trigger_dyntick_cpu()
594 * timer is pinned. If it is a non pinned timer, it is only queued in trigger_dyntick_cpu()
595 * on the remote CPU, when timer was running during queueing. Then in trigger_dyntick_cpu()
597 * on the way to idle then it can't set base->is_idle as we hold in trigger_dyntick_cpu()
600 if (base->is_idle) { in trigger_dyntick_cpu()
601 WARN_ON_ONCE(!(timer->flags & TIMER_PINNED || in trigger_dyntick_cpu()
602 tick_nohz_full_cpu(base->cpu))); in trigger_dyntick_cpu()
603 wake_up_nohz_cpu(base->cpu); in trigger_dyntick_cpu()
608 * Enqueue the timer into the hash bucket, mark it pending in
609 * the bitmap, store the index in the timer flags then wake up
612 static void enqueue_timer(struct timer_base *base, struct timer_list *timer, in enqueue_timer() argument
616 hlist_add_head(&timer->entry, base->vectors + idx); in enqueue_timer()
617 __set_bit(idx, base->pending_map); in enqueue_timer()
618 timer_set_idx(timer, idx); in enqueue_timer()
620 trace_timer_start(timer, bucket_expiry); in enqueue_timer()
623 * Check whether this is the new first expiring timer. The in enqueue_timer()
624 * effective expiry time of the timer is required here in enqueue_timer()
625 * (bucket_expiry) instead of timer->expires. in enqueue_timer()
627 if (time_before(bucket_expiry, base->next_expiry)) { in enqueue_timer()
632 WRITE_ONCE(base->next_expiry, bucket_expiry); in enqueue_timer()
633 base->timers_pending = true; in enqueue_timer()
634 base->next_expiry_recalc = false; in enqueue_timer()
635 trigger_dyntick_cpu(base, timer); in enqueue_timer()
639 static void internal_add_timer(struct timer_base *base, struct timer_list *timer) in internal_add_timer() argument
644 idx = calc_wheel_index(timer->expires, base->clk, &bucket_expiry); in internal_add_timer()
645 enqueue_timer(base, timer, idx, bucket_expiry); in internal_add_timer()
660 .offset = offsetof(container, hintfn) - \
666 struct delayed_work, timer, work.func),
668 struct kthread_delayed_work, timer, work.func),
673 struct timer_list *timer = addr; in timer_debug_hint() local
677 if (timer_hints[i].function == timer->function) { in timer_debug_hint()
684 return timer->function; in timer_debug_hint()
689 struct timer_list *timer = addr; in timer_is_static_object() local
691 return (timer->entry.pprev == NULL && in timer_is_static_object()
692 timer->entry.next == TIMER_ENTRY_STATIC); in timer_is_static_object()
697 * - an active object is initialized
701 struct timer_list *timer = addr; in timer_fixup_init() local
705 timer_delete_sync(timer); in timer_fixup_init()
706 debug_object_init(timer, &timer_debug_descr); in timer_fixup_init()
713 /* Stub timer callback for improperly used timers. */
721 * - an active object is activated
722 * - an unknown non-static object is activated
726 struct timer_list *timer = addr; in timer_fixup_activate() local
730 timer_setup(timer, stub_timer, 0); in timer_fixup_activate()
743 * - an active object is freed
747 struct timer_list *timer = addr; in timer_fixup_free() local
751 timer_delete_sync(timer); in timer_fixup_free()
752 debug_object_free(timer, &timer_debug_descr); in timer_fixup_free()
761 * - an untracked/uninit-ed object is found
765 struct timer_list *timer = addr; in timer_fixup_assert_init() local
769 timer_setup(timer, stub_timer, 0); in timer_fixup_assert_init()
786 static inline void debug_timer_init(struct timer_list *timer) in debug_timer_init() argument
788 debug_object_init(timer, &timer_debug_descr); in debug_timer_init()
791 static inline void debug_timer_activate(struct timer_list *timer) in debug_timer_activate() argument
793 debug_object_activate(timer, &timer_debug_descr); in debug_timer_activate()
796 static inline void debug_timer_deactivate(struct timer_list *timer) in debug_timer_deactivate() argument
798 debug_object_deactivate(timer, &timer_debug_descr); in debug_timer_deactivate()
801 static inline void debug_timer_assert_init(struct timer_list *timer) in debug_timer_assert_init() argument
803 debug_object_assert_init(timer, &timer_debug_descr); in debug_timer_assert_init()
806 static void do_init_timer(struct timer_list *timer,
811 void timer_init_key_on_stack(struct timer_list *timer, in timer_init_key_on_stack() argument
816 debug_object_init_on_stack(timer, &timer_debug_descr); in timer_init_key_on_stack()
817 do_init_timer(timer, func, flags, name, key); in timer_init_key_on_stack()
821 void timer_destroy_on_stack(struct timer_list *timer) in timer_destroy_on_stack() argument
823 debug_object_free(timer, &timer_debug_descr); in timer_destroy_on_stack()
828 static inline void debug_timer_init(struct timer_list *timer) { } in debug_timer_init() argument
829 static inline void debug_timer_activate(struct timer_list *timer) { } in debug_timer_activate() argument
830 static inline void debug_timer_deactivate(struct timer_list *timer) { } in debug_timer_deactivate() argument
831 static inline void debug_timer_assert_init(struct timer_list *timer) { } in debug_timer_assert_init() argument
834 static inline void debug_init(struct timer_list *timer) in debug_init() argument
836 debug_timer_init(timer); in debug_init()
837 trace_timer_init(timer); in debug_init()
840 static inline void debug_deactivate(struct timer_list *timer) in debug_deactivate() argument
842 debug_timer_deactivate(timer); in debug_deactivate()
843 trace_timer_cancel(timer); in debug_deactivate()
846 static inline void debug_assert_init(struct timer_list *timer) in debug_assert_init() argument
848 debug_timer_assert_init(timer); in debug_assert_init()
851 static void do_init_timer(struct timer_list *timer, in do_init_timer() argument
856 timer->entry.pprev = NULL; in do_init_timer()
857 timer->function = func; in do_init_timer()
860 timer->flags = flags | raw_smp_processor_id(); in do_init_timer()
861 lockdep_init_map(&timer->lockdep_map, name, key, 0); in do_init_timer()
865 * timer_init_key - initialize a timer
866 * @timer: the timer to be initialized
867 * @func: timer callback function
868 * @flags: timer flags
869 * @name: name of the timer
870 * @key: lockdep class key of the fake lock used for tracking timer
873 * timer_init_key() must be done to a timer prior to calling *any* of the
874 * other timer functions.
876 void timer_init_key(struct timer_list *timer, in timer_init_key() argument
880 debug_init(timer); in timer_init_key()
881 do_init_timer(timer, func, flags, name, key); in timer_init_key()
885 static inline void detach_timer(struct timer_list *timer, bool clear_pending) in detach_timer() argument
887 struct hlist_node *entry = &timer->entry; in detach_timer()
889 debug_deactivate(timer); in detach_timer()
893 entry->pprev = NULL; in detach_timer()
894 entry->next = LIST_POISON2; in detach_timer()
897 static int detach_if_pending(struct timer_list *timer, struct timer_base *base, in detach_if_pending() argument
900 unsigned idx = timer_get_idx(timer); in detach_if_pending()
902 if (!timer_pending(timer)) in detach_if_pending()
905 if (hlist_is_singular_node(&timer->entry, base->vectors + idx)) { in detach_if_pending()
906 __clear_bit(idx, base->pending_map); in detach_if_pending()
907 base->next_expiry_recalc = true; in detach_if_pending()
910 detach_timer(timer, clear_pending); in detach_if_pending()
919 * If the timer is deferrable and NO_HZ_COMMON is set then we need in get_timer_cpu_base()
933 * If the timer is deferrable and NO_HZ_COMMON is set then we need in get_timer_this_cpu_base()
952 * @basej is past base->clk otherwise we might rewind base->clk. in __forward_timer_base()
954 if (time_before_eq(basej, base->clk)) in __forward_timer_base()
961 if (time_after(base->next_expiry, basej)) { in __forward_timer_base()
962 base->clk = basej; in __forward_timer_base()
964 if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) in __forward_timer_base()
966 base->clk = base->next_expiry; in __forward_timer_base()
982 * be found in the base->vectors array.
984 * When a timer is migrating then the TIMER_MIGRATING flag is set and we need
987 static struct timer_base *lock_timer_base(struct timer_list *timer, in lock_timer_base() argument
989 __acquires(timer->base->lock) in lock_timer_base()
997 * might re-read @tf between the check for TIMER_MIGRATING in lock_timer_base()
1000 tf = READ_ONCE(timer->flags); in lock_timer_base()
1004 raw_spin_lock_irqsave(&base->lock, *flags); in lock_timer_base()
1005 if (timer->flags == tf) in lock_timer_base()
1007 raw_spin_unlock_irqrestore(&base->lock, *flags); in lock_timer_base()
1018 __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int options) in __mod_timer() argument
1025 debug_assert_init(timer); in __mod_timer()
1028 * This is a common optimization triggered by the networking code - if in __mod_timer()
1029 * the timer is re-modified to have the same timeout or ends up in the in __mod_timer()
1032 if (!(options & MOD_TIMER_NOTPENDING) && timer_pending(timer)) { in __mod_timer()
1036 * timer with this expiry. in __mod_timer()
1038 long diff = timer->expires - expires; in __mod_timer()
1046 * We lock timer base and calculate the bucket index right in __mod_timer()
1047 * here. If the timer ends up in the same bucket, then we in __mod_timer()
1051 base = lock_timer_base(timer, &flags); in __mod_timer()
1053 * Has @timer been shutdown? This needs to be evaluated in __mod_timer()
1057 if (!timer->function) in __mod_timer()
1062 if (timer_pending(timer) && (options & MOD_TIMER_REDUCE) && in __mod_timer()
1063 time_before_eq(timer->expires, expires)) { in __mod_timer()
1068 clk = base->clk; in __mod_timer()
1073 * timer. If it matches set the expiry to the new value so a in __mod_timer()
1076 if (idx == timer_get_idx(timer)) { in __mod_timer()
1078 timer->expires = expires; in __mod_timer()
1079 else if (time_after(timer->expires, expires)) in __mod_timer()
1080 timer->expires = expires; in __mod_timer()
1085 base = lock_timer_base(timer, &flags); in __mod_timer()
1087 * Has @timer been shutdown? This needs to be evaluated in __mod_timer()
1091 if (!timer->function) in __mod_timer()
1097 ret = detach_if_pending(timer, base, false); in __mod_timer()
1101 new_base = get_timer_this_cpu_base(timer->flags); in __mod_timer()
1105 * We are trying to schedule the timer on the new base. in __mod_timer()
1106 * However we can't change timer's base while it is running, in __mod_timer()
1107 * otherwise timer_delete_sync() can't detect that the timer's in __mod_timer()
1109 * timer is serialized wrt itself. in __mod_timer()
1111 if (likely(base->running_timer != timer)) { in __mod_timer()
1113 timer->flags |= TIMER_MIGRATING; in __mod_timer()
1115 raw_spin_unlock(&base->lock); in __mod_timer()
1117 raw_spin_lock(&base->lock); in __mod_timer()
1118 WRITE_ONCE(timer->flags, in __mod_timer()
1119 (timer->flags & ~TIMER_BASEMASK) | base->cpu); in __mod_timer()
1124 debug_timer_activate(timer); in __mod_timer()
1126 timer->expires = expires; in __mod_timer()
1133 if (idx != UINT_MAX && clk == base->clk) in __mod_timer()
1134 enqueue_timer(base, timer, idx, bucket_expiry); in __mod_timer()
1136 internal_add_timer(base, timer); in __mod_timer()
1139 raw_spin_unlock_irqrestore(&base->lock, flags); in __mod_timer()
1145 * mod_timer_pending - Modify a pending timer's timeout
1146 * @timer: The pending timer to be modified
1152 * If @timer->function == NULL then the start operation is silently
1156 * * %0 - The timer was inactive and not modified or was in
1158 * * %1 - The timer was active and requeued to expire at @expires
1160 int mod_timer_pending(struct timer_list *timer, unsigned long expires) in mod_timer_pending() argument
1162 return __mod_timer(timer, expires, MOD_TIMER_PENDING_ONLY); in mod_timer_pending()
1167 * mod_timer - Modify a timer's timeout
1168 * @timer: The timer to be modified
1171 * mod_timer(timer, expires) is equivalent to:
1173 * timer_delete(timer); timer->expires = expires; add_timer(timer);
1176 * case that the timer is inactive, the timer_delete() part is a NOP. The
1177 * timer is in any case activated with the new expiry time @expires.
1180 * same timer, then mod_timer() is the only safe way to modify the timeout,
1181 * since add_timer() cannot modify an already running timer.
1183 * If @timer->function == NULL then the start operation is silently
1187 * * %0 - The timer was inactive and started or was in shutdown
1189 * * %1 - The timer was active and requeued to expire at @expires or
1190 * the timer was active and not modified because @expires did
1193 int mod_timer(struct timer_list *timer, unsigned long expires) in mod_timer() argument
1195 return __mod_timer(timer, expires, 0); in mod_timer()
1200 * timer_reduce - Modify a timer's timeout if it would reduce the timeout
1201 * @timer: The timer to be modified
1205 * modify an enqueued timer if that would reduce the expiration time. If
1206 * @timer is not enqueued it starts the timer.
1208 * If @timer->function == NULL then the start operation is silently
1212 * * %0 - The timer was inactive and started or was in shutdown
1214 * * %1 - The timer was active and requeued to expire at @expires or
1215 * the timer was active and not modified because @expires
1217 * timer would expire earlier than already scheduled
1219 int timer_reduce(struct timer_list *timer, unsigned long expires) in timer_reduce() argument
1221 return __mod_timer(timer, expires, MOD_TIMER_REDUCE); in timer_reduce()
1226 * add_timer - Start a timer
1227 * @timer: The timer to be started
1229 * Start @timer to expire at @timer->expires in the future. @timer->expires
1230 * is the absolute expiry time measured in 'jiffies'. When the timer expires
1231 * timer->function(timer) will be invoked from soft interrupt context.
1233 * The @timer->expires and @timer->function fields must be set prior
1236 * If @timer->function == NULL then the start operation is silently
1239 * If @timer->expires is already in the past @timer will be queued to
1240 * expire at the next timer tick.
1242 * This can only operate on an inactive timer. Attempts to invoke this on
1243 * an active timer are rejected with a warning.
1245 void add_timer(struct timer_list *timer) in add_timer() argument
1247 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer()
1249 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer()
1254 * add_timer_local() - Start a timer on the local CPU
1255 * @timer: The timer to be started
1257 * Same as add_timer() except that the timer flag TIMER_PINNED is set.
1261 void add_timer_local(struct timer_list *timer) in add_timer_local() argument
1263 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_local()
1265 timer->flags |= TIMER_PINNED; in add_timer_local()
1266 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer_local()
1271 * add_timer_global() - Start a timer without TIMER_PINNED flag set
1272 * @timer: The timer to be started
1274 * Same as add_timer() except that the timer flag TIMER_PINNED is unset.
1278 void add_timer_global(struct timer_list *timer) in add_timer_global() argument
1280 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_global()
1282 timer->flags &= ~TIMER_PINNED; in add_timer_global()
1283 __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); in add_timer_global()
1288 * add_timer_on - Start a timer on a particular CPU
1289 * @timer: The timer to be started
1292 * Same as add_timer() except that it starts the timer on the given CPU and
1293 * the TIMER_PINNED flag is set. When timer shouldn't be a pinned timer in
1299 void add_timer_on(struct timer_list *timer, int cpu) in add_timer_on() argument
1304 debug_assert_init(timer); in add_timer_on()
1306 if (WARN_ON_ONCE(timer_pending(timer))) in add_timer_on()
1309 /* Make sure timer flags have TIMER_PINNED flag set */ in add_timer_on()
1310 timer->flags |= TIMER_PINNED; in add_timer_on()
1312 new_base = get_timer_cpu_base(timer->flags, cpu); in add_timer_on()
1315 * If @timer was on a different CPU, it should be migrated with the in add_timer_on()
1319 base = lock_timer_base(timer, &flags); in add_timer_on()
1321 * Has @timer been shutdown? This needs to be evaluated while in add_timer_on()
1324 if (!timer->function) in add_timer_on()
1328 timer->flags |= TIMER_MIGRATING; in add_timer_on()
1330 raw_spin_unlock(&base->lock); in add_timer_on()
1332 raw_spin_lock(&base->lock); in add_timer_on()
1333 WRITE_ONCE(timer->flags, in add_timer_on()
1334 (timer->flags & ~TIMER_BASEMASK) | cpu); in add_timer_on()
1338 debug_timer_activate(timer); in add_timer_on()
1339 internal_add_timer(base, timer); in add_timer_on()
1341 raw_spin_unlock_irqrestore(&base->lock, flags); in add_timer_on()
1346 * __timer_delete - Internal function: Deactivate a timer
1347 * @timer: The timer to be deactivated
1348 * @shutdown: If true, this indicates that the timer is about to be
1351 * If @shutdown is true then @timer->function is set to NULL under the
1352 * timer base lock which prevents further rearming of the time. In that
1353 * case any attempt to rearm @timer after this function returns will be
1357 * * %0 - The timer was not pending
1358 * * %1 - The timer was pending and deactivated
1360 static int __timer_delete(struct timer_list *timer, bool shutdown) in __timer_delete() argument
1366 debug_assert_init(timer); in __timer_delete()
1370 * timer is pending or not to protect against a concurrent rearm in __timer_delete()
1373 * enqueued timer is dequeued and cannot end up with in __timer_delete()
1374 * timer->function == NULL in the expiry code. in __timer_delete()
1376 * If timer->function is currently executed, then this makes sure in __timer_delete()
1377 * that the callback cannot requeue the timer. in __timer_delete()
1379 if (timer_pending(timer) || shutdown) { in __timer_delete()
1380 base = lock_timer_base(timer, &flags); in __timer_delete()
1381 ret = detach_if_pending(timer, base, true); in __timer_delete()
1383 timer->function = NULL; in __timer_delete()
1384 raw_spin_unlock_irqrestore(&base->lock, flags); in __timer_delete()
1391 * timer_delete - Deactivate a timer
1392 * @timer: The timer to be deactivated
1394 * The function only deactivates a pending timer, but contrary to
1395 * timer_delete_sync() it does not take into account whether the timer's
1397 * It neither prevents rearming of the timer. If @timer can be rearmed
1401 * * %0 - The timer was not pending
1402 * * %1 - The timer was pending and deactivated
1404 int timer_delete(struct timer_list *timer) in timer_delete() argument
1406 return __timer_delete(timer, false); in timer_delete()
1411 * timer_shutdown - Deactivate a timer and prevent rearming
1412 * @timer: The timer to be deactivated
1414 * The function does not wait for an eventually running timer callback on a
1415 * different CPU but it prevents rearming of the timer. Any attempt to arm
1416 * @timer after this function returns will be silently ignored.
1422 * * %0 - The timer was not pending
1423 * * %1 - The timer was pending
1425 int timer_shutdown(struct timer_list *timer) in timer_shutdown() argument
1427 return __timer_delete(timer, true); in timer_shutdown()
1432 * __try_to_del_timer_sync - Internal function: Try to deactivate a timer
1433 * @timer: Timer to deactivate
1434 * @shutdown: If true, this indicates that the timer is about to be
1437 * If @shutdown is true then @timer->function is set to NULL under the
1438 * timer base lock which prevents further rearming of the timer. Any
1439 * attempt to rearm @timer after this function returns will be silently
1442 * This function cannot guarantee that the timer cannot be rearmed
1447 * * %0 - The timer was not pending
1448 * * %1 - The timer was pending and deactivated
1449 * * %-1 - The timer callback function is running on a different CPU
1451 static int __try_to_del_timer_sync(struct timer_list *timer, bool shutdown) in __try_to_del_timer_sync() argument
1455 int ret = -1; in __try_to_del_timer_sync()
1457 debug_assert_init(timer); in __try_to_del_timer_sync()
1459 base = lock_timer_base(timer, &flags); in __try_to_del_timer_sync()
1461 if (base->running_timer != timer) in __try_to_del_timer_sync()
1462 ret = detach_if_pending(timer, base, true); in __try_to_del_timer_sync()
1464 timer->function = NULL; in __try_to_del_timer_sync()
1466 raw_spin_unlock_irqrestore(&base->lock, flags); in __try_to_del_timer_sync()
1472 * timer_delete_sync_try - Try to deactivate a timer
1473 * @timer: Timer to deactivate
1475 * This function tries to deactivate a timer. On success the timer is not
1476 * queued and the timer callback function is not running on any CPU.
1478 * This function does not guarantee that the timer cannot be rearmed right
1483 * * %0 - The timer was not pending
1484 * * %1 - The timer was pending and deactivated
1485 * * %-1 - The timer callback function is running on a different CPU
1487 int timer_delete_sync_try(struct timer_list *timer) in timer_delete_sync_try() argument
1489 return __try_to_del_timer_sync(timer, false); in timer_delete_sync_try()
1496 spin_lock_init(&base->expiry_lock); in timer_base_init_expiry_lock()
1501 spin_lock(&base->expiry_lock); in timer_base_lock_expiry()
1506 spin_unlock(&base->expiry_lock); in timer_base_unlock_expiry()
1512 * If there is a waiter for base->expiry_lock, then it was waiting for the
1513 * timer callback to finish. Drop expiry_lock and reacquire it. That allows
1517 __releases(&base->lock) __releases(&base->expiry_lock) in timer_sync_wait_running()
1518 __acquires(&base->expiry_lock) __acquires(&base->lock) in timer_sync_wait_running()
1520 if (atomic_read(&base->timer_waiters)) { in timer_sync_wait_running()
1521 raw_spin_unlock_irq(&base->lock); in timer_sync_wait_running()
1522 spin_unlock(&base->expiry_lock); in timer_sync_wait_running()
1523 spin_lock(&base->expiry_lock); in timer_sync_wait_running()
1524 raw_spin_lock_irq(&base->lock); in timer_sync_wait_running()
1530 * deletion of a timer failed because the timer callback function was
1535 * delete a timer preempted the softirq thread running the timer callback
1538 static void del_timer_wait_running(struct timer_list *timer) in del_timer_wait_running() argument
1542 tf = READ_ONCE(timer->flags); in del_timer_wait_running()
1548 * which is held by the softirq across the timer in del_timer_wait_running()
1550 * expire the next timer. In theory the timer could already in del_timer_wait_running()
1554 atomic_inc(&base->timer_waiters); in del_timer_wait_running()
1555 spin_lock_bh(&base->expiry_lock); in del_timer_wait_running()
1556 atomic_dec(&base->timer_waiters); in del_timer_wait_running()
1557 spin_unlock_bh(&base->expiry_lock); in del_timer_wait_running()
1565 static inline void del_timer_wait_running(struct timer_list *timer) { } in del_timer_wait_running() argument
1569 * __timer_delete_sync - Internal function: Deactivate a timer and wait
1571 * @timer: The timer to be deactivated
1572 * @shutdown: If true, @timer->function will be set to NULL under the
1573 * timer base lock which prevents rearming of @timer
1575 * If @shutdown is not set the timer can be rearmed later. If the timer can
1579 * If @shutdown is set then @timer->function is set to NULL under timer
1580 * base lock which prevents rearming of the timer. Any attempt to rearm
1581 * a shutdown timer is silently ignored.
1583 * If the timer should be reused after shutdown it has to be initialized
1587 * * %0 - The timer was not pending
1588 * * %1 - The timer was pending and deactivated
1590 static int __timer_delete_sync(struct timer_list *timer, bool shutdown) in __timer_delete_sync() argument
1602 lock_map_acquire(&timer->lockdep_map); in __timer_delete_sync()
1603 lock_map_release(&timer->lockdep_map); in __timer_delete_sync()
1610 WARN_ON(in_hardirq() && !(timer->flags & TIMER_IRQSAFE)); in __timer_delete_sync()
1616 if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE)) in __timer_delete_sync()
1620 ret = __try_to_del_timer_sync(timer, shutdown); in __timer_delete_sync()
1623 del_timer_wait_running(timer); in __timer_delete_sync()
1632 * timer_delete_sync - Deactivate a timer and wait for the handler to finish.
1633 * @timer: The timer to be deactivated
1635 * Synchronization rules: Callers must prevent restarting of the timer,
1637 * interrupt contexts unless the timer is an irqsafe one. The caller must
1638 * not hold locks which would prevent completion of the timer's callback
1639 * function. The timer's handler must not call add_timer_on(). Upon exit
1640 * the timer is not queued and the handler is not running on any CPU.
1643 * interrupt context. Even if the lock has nothing to do with the timer in
1647 * ---- ----
1650 * base->running_timer = mytimer;
1655 * while (base->running_timer == mytimer);
1661 * This function cannot guarantee that the timer is not rearmed again by
1670 * * %0 - The timer was not pending
1671 * * %1 - The timer was pending and deactivated
1673 int timer_delete_sync(struct timer_list *timer) in timer_delete_sync() argument
1675 return __timer_delete_sync(timer, false); in timer_delete_sync()
1680 * timer_shutdown_sync - Shutdown a timer and prevent rearming
1681 * @timer: The timer to be shutdown
1684 * - @timer is not queued
1685 * - The callback function of @timer is not running
1686 * - @timer cannot be enqueued again. Any attempt to rearm
1687 * @timer is silently ignored.
1692 * the timer is subject to a circular dependency problem.
1694 * A common pattern for this is a timer and a workqueue where the timer can
1695 * schedule work and work can arm the timer. On shutdown the workqueue must
1696 * be destroyed and the timer must be prevented from rearming. Unless the
1697 * code has conditionals like 'if (mything->in_shutdown)' to prevent that
1703 * timer_shutdown_sync(&mything->timer);
1704 * workqueue_destroy(&mything->workqueue);
1708 * This obviously implies that the timer is not required to be functional
1712 * * %0 - The timer was not pending
1713 * * %1 - The timer was pending
1715 int timer_shutdown_sync(struct timer_list *timer) in timer_shutdown_sync() argument
1717 return __timer_delete_sync(timer, true); in timer_shutdown_sync()
1721 static void call_timer_fn(struct timer_list *timer, in call_timer_fn() argument
1729 * It is permissible to free the timer from inside the in call_timer_fn()
1733 * timer->lockdep_map, make a copy and use that here. in call_timer_fn()
1737 lockdep_copy_map(&lockdep_map, &timer->lockdep_map); in call_timer_fn()
1746 trace_timer_expire_entry(timer, baseclk); in call_timer_fn()
1747 fn(timer); in call_timer_fn()
1748 trace_timer_expire_exit(timer); in call_timer_fn()
1753 WARN_ONCE(1, "timer: %pS preempt leak: %08x -> %08x\n", in call_timer_fn()
1768 * This value is required only for tracing. base->clk was in expire_timers()
1770 * is related to the old base->clk value. in expire_timers()
1772 unsigned long baseclk = base->clk - 1; in expire_timers()
1775 struct timer_list *timer; in expire_timers() local
1778 timer = hlist_entry(head->first, struct timer_list, entry); in expire_timers()
1780 base->running_timer = timer; in expire_timers()
1781 detach_timer(timer, true); in expire_timers()
1783 fn = timer->function; in expire_timers()
1787 base->running_timer = NULL; in expire_timers()
1791 if (timer->flags & TIMER_IRQSAFE) { in expire_timers()
1792 raw_spin_unlock(&base->lock); in expire_timers()
1793 call_timer_fn(timer, fn, baseclk); in expire_timers()
1794 raw_spin_lock(&base->lock); in expire_timers()
1795 base->running_timer = NULL; in expire_timers()
1797 raw_spin_unlock_irq(&base->lock); in expire_timers()
1798 call_timer_fn(timer, fn, baseclk); in expire_timers()
1799 raw_spin_lock_irq(&base->lock); in expire_timers()
1800 base->running_timer = NULL; in expire_timers()
1809 unsigned long clk = base->clk = base->next_expiry; in collect_expired_timers()
1817 if (__test_and_clear_bit(idx, base->pending_map)) { in collect_expired_timers()
1818 vec = base->vectors + idx; in collect_expired_timers()
1842 pos = find_next_bit(base->pending_map, end, start); in next_pending_bucket()
1844 return pos - start; in next_pending_bucket()
1846 pos = find_next_bit(base->pending_map, start, offset); in next_pending_bucket()
1847 return pos < start ? pos + LVL_SIZE - start : -1; in next_pending_bucket()
1851 * Search the first expiring timer in the various clock levels. Caller must
1852 * hold base->lock.
1854 * Store next expiry time in base->next_expiry.
1861 next = base->clk + TIMER_NEXT_MAX_DELTA; in timer_recalc_next_expiry()
1862 clk = base->clk; in timer_recalc_next_expiry()
1878 if (pos <= ((LVL_CLK_DIV - lvl_clk) & LVL_CLK_MASK)) in timer_recalc_next_expiry()
1885 * next expiring bucket in that level. base->clk is the next in timer_recalc_next_expiry()
1922 WRITE_ONCE(base->next_expiry, next); in timer_recalc_next_expiry()
1923 base->next_expiry_recalc = false; in timer_recalc_next_expiry()
1924 base->timers_pending = !(next == base->clk + TIMER_NEXT_MAX_DELTA); in timer_recalc_next_expiry()
1929 * Check, if the next hrtimer event is before the next timer wheel
1944 * If the next timer is already expired, return the tick base in cmp_next_hrtimer_event()
1953 * make sure that this tick really expires the timer to avoid in cmp_next_hrtimer_event()
1954 * a ping pong of the nohz stop code. in cmp_next_hrtimer_event()
1964 if (base->next_expiry_recalc) in next_timer_interrupt()
1969 * unnecessary raise of the timer softirq when the next_expiry value in next_timer_interrupt()
1970 * will be reached even if there is no timer pending. in next_timer_interrupt()
1973 * easy comparable to find out which base holds the first pending timer. in next_timer_interrupt()
1975 if (!base->timers_pending) in next_timer_interrupt()
1976 WRITE_ONCE(base->next_expiry, basej + TIMER_NEXT_MAX_DELTA); in next_timer_interrupt()
1978 return base->next_expiry; in next_timer_interrupt()
1998 * it in the local expiry value. The next global event is irrelevant in in fetch_next_timer_interrupt()
2005 tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC; in fetch_next_timer_interrupt()
2012 * as local timers will be handled by CPU itself. When not in fetch_next_timer_interrupt()
2013 * updating tevt->global with the already missed first global in fetch_next_timer_interrupt()
2014 * timer, it is possible that it will be missed completely. in fetch_next_timer_interrupt()
2016 * * The local callers will ignore the tevt->global anyway, when in fetch_next_timer_interrupt()
2020 tevt->global = tevt->local; in fetch_next_timer_interrupt()
2027 * If the local queue expires first, then the global event can be in fetch_next_timer_interrupt()
2030 if (!local_first && base_global->timers_pending) in fetch_next_timer_interrupt()
2031 tevt->global = basem + (u64)(nextevt_global - basej) * TICK_NSEC; in fetch_next_timer_interrupt()
2033 if (base_local->timers_pending) in fetch_next_timer_interrupt()
2034 tevt->local = basem + (u64)(nextevt_local - basej) * TICK_NSEC; in fetch_next_timer_interrupt()
2041 * fetch_next_timer_interrupt_remote() - Store next timers into @tevt
2047 * Stores the next pending local and global timer expiry values in the
2049 * field is set to KTIME_MAX. If local event expires before global
2052 * Caller needs to make sure timer base locks are held (use
2061 /* Preset local / global events */ in fetch_next_timer_interrupt_remote()
2062 tevt->local = tevt->global = KTIME_MAX; in fetch_next_timer_interrupt_remote()
2067 lockdep_assert_held(&base_local->lock); in fetch_next_timer_interrupt_remote()
2068 lockdep_assert_held(&base_global->lock); in fetch_next_timer_interrupt_remote()
2074 * timer_unlock_remote_bases - unlock timer bases of cpu
2077 * Unlocks the remote timer bases.
2080 __releases(timer_bases[BASE_LOCAL]->lock) in timer_unlock_remote_bases()
2081 __releases(timer_bases[BASE_GLOBAL]->lock) in timer_unlock_remote_bases()
2088 raw_spin_unlock(&base_global->lock); in timer_unlock_remote_bases()
2089 raw_spin_unlock(&base_local->lock); in timer_unlock_remote_bases()
2093 * timer_lock_remote_bases - lock timer bases of cpu
2096 * Locks the remote timer bases.
2099 __acquires(timer_bases[BASE_LOCAL]->lock) in timer_lock_remote_bases()
2100 __acquires(timer_bases[BASE_GLOBAL]->lock) in timer_lock_remote_bases()
2109 raw_spin_lock(&base_local->lock); in timer_lock_remote_bases()
2110 raw_spin_lock_nested(&base_global->lock, SINGLE_DEPTH_NESTING); in timer_lock_remote_bases()
2114 * timer_base_is_idle() - Return whether timer base is set idle
2116 * Returns value of local timer base is_idle value.
2126 * timer_expire_remote() - expire global timers of cpu
2145 next_tmigr = tmigr_cpu_new_timer(tevt->global); in timer_use_tmigr()
2147 next_tmigr = tmigr_cpu_deactivate(tevt->global); in timer_use_tmigr()
2149 next_tmigr = tmigr_quick_check(tevt->global); in timer_use_tmigr()
2152 * If the CPU is the last going idle in timer migration hierarchy, make in timer_use_tmigr()
2156 if (next_tmigr < tevt->local) { in timer_use_tmigr()
2163 tmp = div_u64(next_tmigr - basem, TICK_NSEC); in timer_use_tmigr()
2166 tevt->local = next_tmigr; in timer_use_tmigr()
2175 * Make sure first event is written into tevt->local to not miss a in timer_use_tmigr()
2176 * timer on !SMP systems. in timer_use_tmigr()
2178 tevt->local = min_t(u64, tevt->local, tevt->global); in timer_use_tmigr()
2185 struct timer_events tevt = { .local = KTIME_MAX, .global = KTIME_MAX }; in __get_next_timer_interrupt()
2192 * to try to stop it. in __get_next_timer_interrupt()
2197 return tevt.local; in __get_next_timer_interrupt()
2203 raw_spin_lock(&base_local->lock); in __get_next_timer_interrupt()
2204 raw_spin_lock_nested(&base_global->lock, SINGLE_DEPTH_NESTING); in __get_next_timer_interrupt()
2211 * timer migration hierarchy related functions. The value for the next in __get_next_timer_interrupt()
2212 * global timer in @tevt struct equals then KTIME_MAX. This is also in __get_next_timer_interrupt()
2213 * true, when the timer base is idle. in __get_next_timer_interrupt()
2215 * The proper timer migration hierarchy function depends on the callsite in __get_next_timer_interrupt()
2216 * and whether timer base is idle or not. @nextevt will be updated when in __get_next_timer_interrupt()
2217 * this CPU needs to handle the first timer migration hierarchy in __get_next_timer_interrupt()
2223 base_local->is_idle, &tevt); in __get_next_timer_interrupt()
2233 * Set base->is_idle only when caller is timer_base_try_to_set_idle() in __get_next_timer_interrupt()
2239 * global timer into timer migration hierarchy. Therefore a new in __get_next_timer_interrupt()
2242 * If the base is marked idle then any timer add operation must in __get_next_timer_interrupt()
2248 if (!base_local->is_idle && time_after(nextevt, basej + 1)) { in __get_next_timer_interrupt()
2249 base_local->is_idle = true; in __get_next_timer_interrupt()
2252 * in nohz_full mode need a self-IPI to kick reprogramming in __get_next_timer_interrupt()
2255 if (tick_nohz_full_cpu(base_local->cpu)) in __get_next_timer_interrupt()
2256 base_global->is_idle = true; in __get_next_timer_interrupt()
2257 trace_timer_base_idle(true, base_local->cpu); in __get_next_timer_interrupt()
2259 *idle = base_local->is_idle; in __get_next_timer_interrupt()
2262 * When timer base is not set idle, undo the effect of in __get_next_timer_interrupt()
2263 * tmigr_cpu_deactivate() to prevent inconsistent states - active in __get_next_timer_interrupt()
2264 * timer base but inactive timer migration hierarchy. in __get_next_timer_interrupt()
2266 * When timer base was already marked idle, nothing will be in __get_next_timer_interrupt()
2269 if (!base_local->is_idle && idle_is_possible) in __get_next_timer_interrupt()
2273 raw_spin_unlock(&base_global->lock); in __get_next_timer_interrupt()
2274 raw_spin_unlock(&base_local->lock); in __get_next_timer_interrupt()
2276 return cmp_next_hrtimer_event(basem, tevt.local); in __get_next_timer_interrupt()
2280 * get_next_timer_interrupt() - return the time (clock mono) of the next timer
2284 * Returns the tick aligned clock monotonic time of the next pending timer or
2285 * KTIME_MAX if no timer is pending. If timer of global base was queued into
2286 * timer migration hierarchy, first global timer is not taken into account. If
2287 * it was the last CPU of timer migration hierarchy going idle, first global
2296 * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases
2299 * @idle: pointer to store the value of timer_base->is_idle on return;
2302 * Returns the tick aligned clock monotonic time of the next pending timer or
2303 * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is
2315 * timer_clear_idle - Clear the idle state of the timer base
2322 * We do this unlocked. The worst outcome is a remote pinned timer in timer_clear_idle()
2333 /* Activate without holding the timer_base->lock */ in timer_clear_idle()
2339 * __run_timers - run all expired timers (if any) on this CPU.
2340 * @base: the timer vector to be processed.
2347 lockdep_assert_held(&base->lock); in __run_timers()
2349 if (base->running_timer) in __run_timers()
2352 while (time_after_eq(jiffies, base->clk) && in __run_timers()
2353 time_after_eq(jiffies, base->next_expiry)) { in __run_timers()
2357 * timer at this clk are that all matching timers have been in __run_timers()
2358 * dequeued or no timer has been queued since in __run_timers()
2362 WARN_ON_ONCE(!levels && !base->next_expiry_recalc in __run_timers()
2363 && base->timers_pending); in __run_timers()
2365 * While executing timers, base->clk is set 1 offset ahead of in __run_timers()
2368 base->clk++; in __run_timers()
2371 while (levels--) in __run_timers()
2379 if (time_before(jiffies, READ_ONCE(base->next_expiry))) in __run_timer_base()
2383 raw_spin_lock_irq(&base->lock); in __run_timer_base()
2385 raw_spin_unlock_irq(&base->lock); in __run_timer_base()
2397 * This function runs timers and the timer-tq in bottom half context.
2412 * Called by the local, per-CPU timer interrupt on SMP.
2426 * the lockless local read, sanity checker could complain about in run_local_timers()
2435 * worst outcome is a superfluous raise of the timer softirq in run_local_timers()
2438 * 2. A new first pinned timer is enqueued by a remote CPU in run_local_timers()
2443 * is missed, then the timer would expire one jiffy late - in run_local_timers()
2451 * Possible remote writers are using WRITE_ONCE(). Local reader in run_local_timers()
2454 if (time_after_eq(jiffies, READ_ONCE(base->next_expiry)) || in run_local_timers()
2463 * Called from the timer interrupt handler to charge one tick to the current
2470 /* Note: this timer irq context must be accounted for as well. */ in update_process_times()
2486 struct timer_list *timer; in migrate_timer_list() local
2487 int cpu = new_base->cpu; in migrate_timer_list()
2490 timer = hlist_entry(head->first, struct timer_list, entry); in migrate_timer_list()
2491 detach_timer(timer, false); in migrate_timer_list()
2492 timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu; in migrate_timer_list()
2493 internal_add_timer(new_base, timer); in migrate_timer_list()
2504 base->clk = jiffies; in timers_prepare_cpu()
2505 base->next_expiry = base->clk + TIMER_NEXT_MAX_DELTA; in timers_prepare_cpu()
2506 base->next_expiry_recalc = false; in timers_prepare_cpu()
2507 base->timers_pending = false; in timers_prepare_cpu()
2508 base->is_idle = false; in timers_prepare_cpu()
2526 raw_spin_lock_irq(&new_base->lock); in timers_dead_cpu()
2527 raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); in timers_dead_cpu()
2535 WARN_ON_ONCE(old_base->running_timer); in timers_dead_cpu()
2536 old_base->running_timer = NULL; in timers_dead_cpu()
2539 migrate_timer_list(new_base, old_base->vectors + i); in timers_dead_cpu()
2541 raw_spin_unlock(&old_base->lock); in timers_dead_cpu()
2542 raw_spin_unlock_irq(&new_base->lock); in timers_dead_cpu()
2557 base->cpu = cpu; in init_timer_cpu()
2558 raw_spin_lock_init(&base->lock); in init_timer_cpu()
2559 base->clk = jiffies; in init_timer_cpu()
2560 base->next_expiry = base->clk + TIMER_NEXT_MAX_DELTA; in init_timer_cpu()