4 #include <linux/list.h>
5 #include <linux/ktime.h>
6 #include <linux/stddef.h>
7 #include <linux/debugobjects.h>
8 #include <linux/stringify.h>
13 struct list_head entry
;
14 unsigned long expires
;
16 void (*function
)(unsigned long);
19 struct tvec_base
*base
;
20 #ifdef CONFIG_TIMER_STATS
26 struct lockdep_map lockdep_map
;
30 extern struct tvec_base boot_tvec_bases
;
34 * NB: because we have to copy the lockdep_map, setting the lockdep_map key
35 * (second argument) here is required, otherwise it could be initialised to
36 * the copy of the lockdep_map later! We use the pointer to and the string
37 * "<file>:<line>" as the key resp. the name of the lockdep_map.
39 #define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) \
40 .lockdep_map = STATIC_LOCKDEP_MAP_INIT(_kn, &_kn),
42 #define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
45 #define TIMER_INITIALIZER(_function, _expires, _data) { \
46 .entry = { .prev = TIMER_ENTRY_STATIC }, \
47 .function = (_function), \
48 .expires = (_expires), \
50 .base = &boot_tvec_bases, \
51 __TIMER_LOCKDEP_MAP_INITIALIZER( \
52 __FILE__ ":" __stringify(__LINE__)) \
55 #define DEFINE_TIMER(_name, _function, _expires, _data) \
56 struct timer_list _name = \
57 TIMER_INITIALIZER(_function, _expires, _data)
59 void init_timer_key(struct timer_list
*timer
,
61 struct lock_class_key
*key
);
62 void init_timer_deferrable_key(struct timer_list
*timer
,
64 struct lock_class_key
*key
);
67 #define init_timer(timer) \
69 static struct lock_class_key __key; \
70 init_timer_key((timer), #timer, &__key); \
73 #define init_timer_deferrable(timer) \
75 static struct lock_class_key __key; \
76 init_timer_deferrable_key((timer), #timer, &__key); \
79 #define init_timer_on_stack(timer) \
81 static struct lock_class_key __key; \
82 init_timer_on_stack_key((timer), #timer, &__key); \
85 #define setup_timer(timer, fn, data) \
87 static struct lock_class_key __key; \
88 setup_timer_key((timer), #timer, &__key, (fn), (data));\
91 #define setup_timer_on_stack(timer, fn, data) \
93 static struct lock_class_key __key; \
94 setup_timer_on_stack_key((timer), #timer, &__key, \
98 #define init_timer(timer)\
99 init_timer_key((timer), NULL, NULL)
100 #define init_timer_deferrable(timer)\
101 init_timer_deferrable_key((timer), NULL, NULL)
102 #define init_timer_on_stack(timer)\
103 init_timer_on_stack_key((timer), NULL, NULL)
104 #define setup_timer(timer, fn, data)\
105 setup_timer_key((timer), NULL, NULL, (fn), (data))
106 #define setup_timer_on_stack(timer, fn, data)\
107 setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
110 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
111 extern void init_timer_on_stack_key(struct timer_list
*timer
,
113 struct lock_class_key
*key
);
114 extern void destroy_timer_on_stack(struct timer_list
*timer
);
116 static inline void destroy_timer_on_stack(struct timer_list
*timer
) { }
117 static inline void init_timer_on_stack_key(struct timer_list
*timer
,
119 struct lock_class_key
*key
)
121 init_timer_key(timer
, name
, key
);
125 static inline void setup_timer_key(struct timer_list
* timer
,
127 struct lock_class_key
*key
,
128 void (*function
)(unsigned long),
131 timer
->function
= function
;
133 init_timer_key(timer
, name
, key
);
136 static inline void setup_timer_on_stack_key(struct timer_list
*timer
,
138 struct lock_class_key
*key
,
139 void (*function
)(unsigned long),
142 timer
->function
= function
;
144 init_timer_on_stack_key(timer
, name
, key
);
148 * timer_pending - is a timer pending?
149 * @timer: the timer in question
151 * timer_pending will tell whether a given timer is currently pending,
152 * or not. Callers must ensure serialization wrt. other operations done
153 * to this timer, eg. interrupt contexts, or other CPUs on SMP.
155 * return value: 1 if the timer is pending, 0 if not.
157 static inline int timer_pending(const struct timer_list
* timer
)
159 return timer
->entry
.next
!= NULL
;
162 extern void add_timer_on(struct timer_list
*timer
, int cpu
);
163 extern int del_timer(struct timer_list
* timer
);
164 extern int mod_timer(struct timer_list
*timer
, unsigned long expires
);
165 extern int mod_timer_pending(struct timer_list
*timer
, unsigned long expires
);
166 extern int mod_timer_pinned(struct timer_list
*timer
, unsigned long expires
);
168 #define TIMER_NOT_PINNED 0
169 #define TIMER_PINNED 1
171 * The jiffies value which is added to now, when there is no timer
172 * in the timer wheel:
174 #define NEXT_TIMER_MAX_DELTA ((1UL << 30) - 1)
177 * Return when the next timer-wheel timeout occurs (in absolute jiffies),
178 * locks the timer base:
180 extern unsigned long next_timer_interrupt(void);
182 * Return when the next timer-wheel timeout occurs (in absolute jiffies),
183 * locks the timer base and does the comparison against the given
186 extern unsigned long get_next_timer_interrupt(unsigned long now
);
189 * Timer-statistics info:
191 #ifdef CONFIG_TIMER_STATS
193 extern int timer_stats_active
;
195 #define TIMER_STATS_FLAG_DEFERRABLE 0x1
197 extern void init_timer_stats(void);
199 extern void timer_stats_update_stats(void *timer
, pid_t pid
, void *startf
,
200 void *timerf
, char *comm
,
201 unsigned int timer_flag
);
203 extern void __timer_stats_timer_set_start_info(struct timer_list
*timer
,
206 static inline void timer_stats_timer_set_start_info(struct timer_list
*timer
)
208 if (likely(!timer_stats_active
))
210 __timer_stats_timer_set_start_info(timer
, __builtin_return_address(0));
213 static inline void timer_stats_timer_clear_start_info(struct timer_list
*timer
)
215 timer
->start_site
= NULL
;
218 static inline void init_timer_stats(void)
222 static inline void timer_stats_timer_set_start_info(struct timer_list
*timer
)
226 static inline void timer_stats_timer_clear_start_info(struct timer_list
*timer
)
231 extern void add_timer(struct timer_list
*timer
);
234 extern int try_to_del_timer_sync(struct timer_list
*timer
);
235 extern int del_timer_sync(struct timer_list
*timer
);
237 # define try_to_del_timer_sync(t) del_timer(t)
238 # define del_timer_sync(t) del_timer(t)
241 #define del_singleshot_timer_sync(t) del_timer_sync(t)
243 extern void init_timers(void);
244 extern void run_local_timers(void);
246 extern enum hrtimer_restart
it_real_fn(struct hrtimer
*);
248 unsigned long __round_jiffies(unsigned long j
, int cpu
);
249 unsigned long __round_jiffies_relative(unsigned long j
, int cpu
);
250 unsigned long round_jiffies(unsigned long j
);
251 unsigned long round_jiffies_relative(unsigned long j
);
253 unsigned long __round_jiffies_up(unsigned long j
, int cpu
);
254 unsigned long __round_jiffies_up_relative(unsigned long j
, int cpu
);
255 unsigned long round_jiffies_up(unsigned long j
);
256 unsigned long round_jiffies_up_relative(unsigned long j
);