Performance of del_timer_sync
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Geoff Gustafson
Quoted 2 lines · Andrew Morton
<anal>del_singleshot_timer_sync</anal>
Quoted 8 lines
Quoted 1 line
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.
Looks good. Your email client performs bizarre whitespace transformations, so I had to fix the patch up by hand.
Here's an incremental patch:
include/linux/timer.h renamed from include/linux/timer.h~del_singleshot_timer_sync-tweaks +2 -2
@@ -87,8 +87,8 @@ static inline void add_timer(struct time }#ifdef CONFIG_SMP -extern int del_timer_sync (struct timer_list * timer); -extern int del_singleshot_timer_sync (struct timer_list * timer); +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)
kernel/timer.c renamed from kernel/timer.c~del_singleshot_timer_sync-tweaks +11 -6
@@ -317,10 +317,16 @@ EXPORT_SYMBOL(del_timer);* * 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. +* interrupt contexts. The caller must not hold locks which would prevent +* completion of the timer's handler. 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. +* +* del_timer_sync() is slow and complicated because it copes with timer +* handlers which re-arm the timer (periodic timers). If the timer handler +* is known to not do this (a single shot timer) then use +* del_singleshot_timer_sync() instead. */ int del_timer_sync (struct timer_list *timer) {
@@ -348,7 +354,6 @@ del_again:return ret; } -EXPORT_SYMBOL (del_timer_sync);/***
@@ -361,8 +366,9 @@ EXPORT_SYMBOL(del_timer_sync);* * 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. +* interrupt contexts. The caller must not hold locks which would prevent +* completion of the timer's handler. 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. */
@@ -377,7 +383,6 @@ int del_singleshot_timer_sync(struct tim return ret; } -EXPORT_SYMBOL (del_singleshot_timer_sync);#endif
_