Performance of del_timer_sync
Subsystems (3)
Quoted 3 lines · Andrew Morton
<anal>del_singleshot_timer_sync</anal>
I vote we leave it up to Ken. But please, not
del_timer_kenneth().
Despite your markup language, I thought keeping the 'sync' sounded like a good idea, since that's the function it's replacing.
Here's a patch. I've done a small amount of testing with a 4p machine. I've at least seen that the average call to singleshot is down around 90 cycles, pretty similar/expected. We'll test on the original platform and post results.
- Geoff
* I am in a transitional period w/ email clients and can't seem to use any of them properly. Sorry for the dups, etc.
fs/aio.c +1 -1
@@ -793,7 +793,7 @@static inline void clear_timeout (struct timeout *to) { -del_timer_sync (&to->timer); +del_singleshot_timer_sync (&to->timer); } static int read_events(struct kioctx *ctx,
include/linux/timer.h +2 -0
@@ -88,8 +88,10 @@#ifdef CONFIG_SMP extern int del_timer_sync (struct timer_list * timer); +extern int del_singleshot_timer_sync (struct timer_list * timer);#else # define del_timer_sync (t) del_timer(t) +# define del_singleshot_timer_sync (t) del_timer(t)#endif extern void init_timers (void );
kernel/timer.c +30 -1
@@ -350,6 +350,35 @@ }EXPORT_SYMBOL (del_timer_sync); + +/*** +* del_singleshot_timer_sync - deactivate a non-recursive timer +* @timer: the timer to be deactivated +* +* This function is an optimization of del_timer_sync for the case where the +* caller can guarantee the timer does not reschedule itself in its timer +* function. +* +* Synchronization rules: callers must prevent restarting of the timer, +* otherwise this function is meaningless. It must not be called from +* interrupt contexts. Upon exit the timer is not queued and the handler +* is not running on any CPU. +* +* The function returns whether it has deactivated a pending timer or not. +*/ +int del_singleshot_timer_sync (struct timer_list *timer) +{ +int ret =del_timer (timer); + +if (!ret) { + ret =del_timer_sync (timer); +BUG_ON (ret); + } + +return ret; +} + +EXPORT_SYMBOL (del_singleshot_timer_sync);#endif static int cascade (tvec_base_t *base,tvec_t *tv,int index)
@@ -1109,7 +1138,7 @@add_timer (&timer);schedule (); -del_timer_sync (&timer); +del_singleshot_timer_sync (&timer); timeout = expire - jiffies;