aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/timer.h')
-rw-r--r--include/linux/timer.h47
1 files changed, 44 insertions, 3 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h
index ea965b857a50..6abd9138beda 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -24,9 +24,9 @@ struct timer_list {
24 int slack; 24 int slack;
25 25
26#ifdef CONFIG_TIMER_STATS 26#ifdef CONFIG_TIMER_STATS
27 int start_pid;
27 void *start_site; 28 void *start_site;
28 char start_comm[16]; 29 char start_comm[16];
29 int start_pid;
30#endif 30#endif
31#ifdef CONFIG_LOCKDEP 31#ifdef CONFIG_LOCKDEP
32 struct lockdep_map lockdep_map; 32 struct lockdep_map lockdep_map;
@@ -48,12 +48,38 @@ extern struct tvec_base boot_tvec_bases;
48#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) 48#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
49#endif 49#endif
50 50
51/*
52 * Note that all tvec_bases are 2 byte aligned and lower bit of
53 * base in timer_list is guaranteed to be zero. Use the LSB to
54 * indicate whether the timer is deferrable.
55 *
56 * A deferrable timer will work normally when the system is busy, but
57 * will not cause a CPU to come out of idle just to service it; instead,
58 * the timer will be serviced when the CPU eventually wakes up with a
59 * subsequent non-deferrable timer.
60 */
61#define TBASE_DEFERRABLE_FLAG (0x1)
62
51#define TIMER_INITIALIZER(_function, _expires, _data) { \ 63#define TIMER_INITIALIZER(_function, _expires, _data) { \
52 .entry = { .prev = TIMER_ENTRY_STATIC }, \ 64 .entry = { .prev = TIMER_ENTRY_STATIC }, \
53 .function = (_function), \ 65 .function = (_function), \
54 .expires = (_expires), \ 66 .expires = (_expires), \
55 .data = (_data), \ 67 .data = (_data), \
56 .base = &boot_tvec_bases, \ 68 .base = &boot_tvec_bases, \
69 .slack = -1, \
70 __TIMER_LOCKDEP_MAP_INITIALIZER( \
71 __FILE__ ":" __stringify(__LINE__)) \
72 }
73
74#define TBASE_MAKE_DEFERRED(ptr) ((struct tvec_base *) \
75 ((unsigned char *)(ptr) + TBASE_DEFERRABLE_FLAG))
76
77#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) {\
78 .entry = { .prev = TIMER_ENTRY_STATIC }, \
79 .function = (_function), \
80 .expires = (_expires), \
81 .data = (_data), \
82 .base = TBASE_MAKE_DEFERRED(&boot_tvec_bases), \
57 __TIMER_LOCKDEP_MAP_INITIALIZER( \ 83 __TIMER_LOCKDEP_MAP_INITIALIZER( \
58 __FILE__ ":" __stringify(__LINE__)) \ 84 __FILE__ ":" __stringify(__LINE__)) \
59 } 85 }
@@ -100,6 +126,13 @@ void init_timer_deferrable_key(struct timer_list *timer,
100 setup_timer_on_stack_key((timer), #timer, &__key, \ 126 setup_timer_on_stack_key((timer), #timer, &__key, \
101 (fn), (data)); \ 127 (fn), (data)); \
102 } while (0) 128 } while (0)
129#define setup_deferrable_timer_on_stack(timer, fn, data) \
130 do { \
131 static struct lock_class_key __key; \
132 setup_deferrable_timer_on_stack_key((timer), #timer, \
133 &__key, (fn), \
134 (data)); \
135 } while (0)
103#else 136#else
104#define init_timer(timer)\ 137#define init_timer(timer)\
105 init_timer_key((timer), NULL, NULL) 138 init_timer_key((timer), NULL, NULL)
@@ -111,6 +144,8 @@ void init_timer_deferrable_key(struct timer_list *timer,
111 setup_timer_key((timer), NULL, NULL, (fn), (data)) 144 setup_timer_key((timer), NULL, NULL, (fn), (data))
112#define setup_timer_on_stack(timer, fn, data)\ 145#define setup_timer_on_stack(timer, fn, data)\
113 setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data)) 146 setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
147#define setup_deferrable_timer_on_stack(timer, fn, data)\
148 setup_deferrable_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
114#endif 149#endif
115 150
116#ifdef CONFIG_DEBUG_OBJECTS_TIMERS 151#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
@@ -150,6 +185,12 @@ static inline void setup_timer_on_stack_key(struct timer_list *timer,
150 init_timer_on_stack_key(timer, name, key); 185 init_timer_on_stack_key(timer, name, key);
151} 186}
152 187
188extern void setup_deferrable_timer_on_stack_key(struct timer_list *timer,
189 const char *name,
190 struct lock_class_key *key,
191 void (*function)(unsigned long),
192 unsigned long data);
193
153/** 194/**
154 * timer_pending - is a timer pending? 195 * timer_pending - is a timer pending?
155 * @timer: the timer in question 196 * @timer: the timer in question
@@ -233,11 +274,11 @@ static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
233 274
234extern void add_timer(struct timer_list *timer); 275extern void add_timer(struct timer_list *timer);
235 276
277extern int try_to_del_timer_sync(struct timer_list *timer);
278
236#ifdef CONFIG_SMP 279#ifdef CONFIG_SMP
237 extern int try_to_del_timer_sync(struct timer_list *timer);
238 extern int del_timer_sync(struct timer_list *timer); 280 extern int del_timer_sync(struct timer_list *timer);
239#else 281#else
240# define try_to_del_timer_sync(t) del_timer(t)
241# define del_timer_sync(t) del_timer(t) 282# define del_timer_sync(t) del_timer(t)
242#endif 283#endif
243 284