Messages in this thread Patch in this message | | | Date | Wed, 19 Jun 2013 10:59:15 +0800 | From | Chen Gang <> | Subject | [PATCH] kernel/timer.c: using spin_lock_irqsave instead of spin_lock + local_irq_save, especially when CONFIG_LOCKDEP not defined |
| |
When CONFIG_LOCKDEP is not defined, spin_lock_irqsave() is not equal to spin_lock() + local_irq_save().
In __mod_timer(), After call spin_lock_irqsave() with 'base->lock' in lock_timer_base(), it may use spin_lock() with the 'new_base->lock'.
It may let original call do_raw_spin_lock_flags() with 'base->lock', but new call LOCK_CONTENDED() with 'new_base->lock'.
In fact, we need both of them call do_raw_spin_lock_flags(), so use spin_lock_irqsave() instead of spin_lock() + local_irq_save().
Signed-off-by: Chen Gang <gang.chen@asianux.com> --- kernel/timer.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c index aa8b964..2550a62 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -754,9 +754,9 @@ __mod_timer(struct timer_list *timer, unsigned long expires, if (likely(base->running_timer != timer)) { /* See the comment in lock_timer_base() */ timer_set_base(timer, NULL); - spin_unlock(&base->lock); + spin_unlock_irqrestore(&base->lock, flags); base = new_base; - spin_lock(&base->lock); + spin_lock_irqsave(&base->lock, flags); timer_set_base(timer, base); } } -- 1.7.7.6
| |