Skip to contentSkip to conversation

timers: introduce try_to_del_timer_sync()

PATCH In review Oleg Nesterov 1 participant 1 message May 22, 2005 High-resolution timers, timer wheel, clockevents

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 timers: introduce try_to_del_timer_sync()

This patch splits del_timer_sync() into 2 functions. The new one, try_to_del_timer_sync(), returns -1 when it hits executing timer.

It can be used in interrupt context, or when the caller hold locks which can prevent completion of the timer's handler.

NOTE. Currently it can't be used in interrupt context in UP case, because ->running_timer is used only with CONFIG_SMP.

Should the need arise, it is possible to kill #ifdef CONFIG_SMP in set_running_timer(), it is cheap.

include/linux/timer.h renamed from include/linux/timer.h~1_TRY +3 -1
@@ -76,9 +76,11 @@ static inline void add_timer(struct time
 }
 
 #ifdef CONFIG_SMP
+  extern int try_to_del_timer_sync(struct timer_list *timer);
   extern int del_timer_sync(struct timer_list *timer);
 #else
-# define del_timer_sync(t) del_timer(t)
+# define try_to_del_timer_sync(t)	del_timer(t)
+# define del_timer_sync(t)		del_timer(t)
 #endif
 
 #define del_singleshot_timer_sync(t) del_timer_sync(t)
kernel/timer.c renamed from kernel/timer.c~1_TRY +33 -20

67 lines not on this page · raw message