hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/include/linux/timer.h
....@@ -40,19 +40,30 @@
4040 #define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
4141 #endif
4242
43
-/*
44
- * A deferrable timer will work normally when the system is busy, but
45
- * will not cause a CPU to come out of idle just to service it; instead,
46
- * the timer will be serviced when the CPU eventually wakes up with a
47
- * subsequent non-deferrable timer.
43
+/**
44
+ * @TIMER_DEFERRABLE: A deferrable timer will work normally when the
45
+ * system is busy, but will not cause a CPU to come out of idle just
46
+ * to service it; instead, the timer will be serviced when the CPU
47
+ * eventually wakes up with a subsequent non-deferrable timer.
4848 *
49
- * An irqsafe timer is executed with IRQ disabled and it's safe to wait for
50
- * the completion of the running instance from IRQ handlers, for example,
51
- * by calling del_timer_sync().
49
+ * @TIMER_IRQSAFE: An irqsafe timer is executed with IRQ disabled and
50
+ * it's safe to wait for the completion of the running instance from
51
+ * IRQ handlers, for example, by calling del_timer_sync().
5252 *
5353 * Note: The irq disabled callback execution is a special case for
5454 * workqueue locking issues. It's not meant for executing random crap
5555 * with interrupts disabled. Abuse is monitored!
56
+ *
57
+ * @TIMER_PINNED: A pinned timer will not be affected by any timer
58
+ * placement heuristics (like, NOHZ) and will always expire on the CPU
59
+ * on which the timer was enqueued.
60
+ *
61
+ * Note: Because enqueuing of timers can migrate the timer from one
62
+ * CPU to another, pinned timers are not guaranteed to stay on the
63
+ * initialy selected CPU. They move to the CPU on which the enqueue
64
+ * function is invoked via mod_timer() or add_timer(). If the timer
65
+ * should be placed on a particular CPU, then add_timer_on() has to be
66
+ * used.
5667 */
5768 #define TIMER_CPUMASK 0x0003FFFF
5869 #define TIMER_MIGRATING 0x00040000
....@@ -60,6 +71,7 @@
6071 #define TIMER_DEFERRABLE 0x00080000
6172 #define TIMER_PINNED 0x00100000
6273 #define TIMER_IRQSAFE 0x00200000
74
+#define TIMER_INIT_FLAGS (TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE)
6375 #define TIMER_ARRAYSHIFT 22
6476 #define TIMER_ARRAYMASK 0xFFC00000
6577
....@@ -157,7 +169,7 @@
157169 */
158170 static inline int timer_pending(const struct timer_list * timer)
159171 {
160
- return timer->entry.pprev != NULL;
172
+ return !hlist_unhashed_lockless(&timer->entry);
161173 }
162174
163175 extern void add_timer_on(struct timer_list *timer, int cpu);
....@@ -176,7 +188,7 @@
176188
177189 extern int try_to_del_timer_sync(struct timer_list *timer);
178190
179
-#ifdef CONFIG_SMP
191
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
180192 extern int del_timer_sync(struct timer_list *timer);
181193 #else
182194 # define del_timer_sync(t) del_timer(t)
....@@ -194,8 +206,7 @@
194206
195207 extern unsigned int sysctl_timer_migration;
196208 int timer_migration_handler(struct ctl_table *table, int write,
197
- void __user *buffer, size_t *lenp,
198
- loff_t *ppos);
209
+ void *buffer, size_t *lenp, loff_t *ppos);
199210 #endif
200211
201212 unsigned long __round_jiffies(unsigned long j, int cpu);