aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/timer.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-02-18 06:23:29 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-18 13:26:33 -0500
commit74019224ac34b044b44a31dd89a54e3477db4896 (patch)
treebf7b04319c0c4329eb6cef0788737c14d2fa9030 /include/linux/timer.h
parent5955c7a2cfb6a35429adea5dc480002b15ca8cfc (diff)
timers: add mod_timer_pending()
Impact: new timer API Based on an idea from Martin Josefsson with the help of Patrick McHardy and Stephen Hemminger: introduce the mod_timer_pending() API which is a mod_timer() offspring that is an invariant on already removed timers. (regular mod_timer() re-activates non-pending timers.) This is useful for the networking code in that it can allow unserialized mod_timer_pending() timer-forwarding calls, but a single del_timer*() will stop the timer from being reactivated again. Also while at it: - optimize the regular mod_timer() path some more, the timer-stat and a debug check was needlessly duplicated in __mod_timer(). - make the exports come straight after the function, as most other exports in timer.c already did. - eliminate __mod_timer() as an external API, change the users to mod_timer(). The regular mod_timer() code path is not impacted significantly, due to inlining optimizations and due to the simplifications. Based-on-patch-from: Stephen Hemminger <shemminger@vyatta.com> Acked-by: Stephen Hemminger <shemminger@vyatta.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Patrick McHardy <kaber@trash.net> Cc: netdev@vger.kernel.org Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/timer.h')
-rw-r--r--include/linux/timer.h22
1 files changed, 2 insertions, 20 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h
index daf9685b861c..e2d662e3416e 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -86,8 +86,8 @@ static inline int timer_pending(const struct timer_list * timer)
86 86
87extern void add_timer_on(struct timer_list *timer, int cpu); 87extern void add_timer_on(struct timer_list *timer, int cpu);
88extern int del_timer(struct timer_list * timer); 88extern int del_timer(struct timer_list * timer);
89extern int __mod_timer(struct timer_list *timer, unsigned long expires);
90extern int mod_timer(struct timer_list *timer, unsigned long expires); 89extern int mod_timer(struct timer_list *timer, unsigned long expires);
90extern int mod_timer_pending(struct timer_list *timer, unsigned long expires);
91 91
92/* 92/*
93 * The jiffies value which is added to now, when there is no timer 93 * The jiffies value which is added to now, when there is no timer
@@ -146,25 +146,7 @@ static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
146} 146}
147#endif 147#endif
148 148
149/** 149extern void add_timer(struct timer_list *timer);
150 * add_timer - start a timer
151 * @timer: the timer to be added
152 *
153 * The kernel will do a ->function(->data) callback from the
154 * timer interrupt at the ->expires point in the future. The
155 * current time is 'jiffies'.
156 *
157 * The timer's ->expires, ->function (and if the handler uses it, ->data)
158 * fields must be set prior calling this function.
159 *
160 * Timers with an ->expires field in the past will be executed in the next
161 * timer tick.
162 */
163static inline void add_timer(struct timer_list *timer)
164{
165 BUG_ON(timer_pending(timer));
166 __mod_timer(timer, timer->expires);
167}
168 150
169#ifdef CONFIG_SMP 151#ifdef CONFIG_SMP
170 extern int try_to_del_timer_sync(struct timer_list *timer); 152 extern int try_to_del_timer_sync(struct timer_list *timer);