RPC: Optimize away unnecessary del_timer_sync() operations, when we know there are no pending timers. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/sched.h | 1 + net/sunrpc/sched.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) Index: linux-2.6.10-rc1-up/net/sunrpc/sched.c =================================================================== --- linux-2.6.10-rc1-up.orig/net/sunrpc/sched.c 2004-10-23 18:05:56.819538468 -0400 +++ linux-2.6.10-rc1-up/net/sunrpc/sched.c 2004-10-23 18:06:06.468264740 -0400 @@ -101,6 +101,9 @@ static void rpc_run_timer(struct rpc_tas dprintk("RPC: %4d running timer\n", task->tk_pid); callback(task); } + smp_mb__before_clear_bit(); + clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate); + smp_mb__after_clear_bit(); } /* @@ -119,6 +122,7 @@ __rpc_add_timer(struct rpc_task *task, r task->tk_timeout_fn = timer; else task->tk_timeout_fn = __rpc_default_timer; + set_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate); mod_timer(&task->tk_timer, jiffies + task->tk_timeout); } @@ -129,8 +133,10 @@ __rpc_add_timer(struct rpc_task *task, r static inline void rpc_delete_timer(struct rpc_task *task) { - if (del_timer_sync(&task->tk_timer)) + if (test_and_clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate)) { + del_singleshot_timer_sync(&task->tk_timer); dprintk("RPC: %4d deleting timer\n", task->tk_pid); + } } /* Index: linux-2.6.10-rc1-up/include/linux/sunrpc/sched.h =================================================================== --- linux-2.6.10-rc1-up.orig/include/linux/sunrpc/sched.h 2004-10-23 18:05:56.818538600 -0400 +++ linux-2.6.10-rc1-up/include/linux/sunrpc/sched.h 2004-10-23 18:06:43.770340132 -0400 @@ -142,6 +142,7 @@ typedef void (*rpc_action)(struct rpc_ #define RPC_TASK_RUNNING 0 #define RPC_TASK_QUEUED 1 #define RPC_TASK_WAKEUP 2 +#define RPC_TASK_HAS_TIMER 3 #define RPC_IS_RUNNING(t) (test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) #define rpc_set_running(t) (set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate))