From: Andrew Morton <akpm@osdl.org>
To: Reuben Farrelly <reuben-lkml@reub.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.12-rc3-mm1
Date: Tue, 3 May 2005 02:07:05 -0700 [thread overview]
Message-ID: <20050503020705.29bbffbd.akpm@osdl.org> (raw)
In-Reply-To: <42773DC0.4050803@reub.net>
Reuben Farrelly <reuben-lkml@reub.net> wrote:
>
> Hi Andrew,
>
> Andrew Morton wrote:
> > ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.12-rc3/2.6.12-rc3-mm1/
> >
> > - There's still a bug in the new timer code. If you think you hit it,
> > please revert
> >
> > timers-fixes-improvements-fix.patch then
> > timers-fixes-improvements-smp_processor_id-fix.patch then
> > timers-fixes-improvements.patch
> >
> > or, better, fix the bug.
>
> FWIW, I can reproduce this timer bug fairly consistently, by simply
> rebooting my cisco router. That means that my linux box has no default
> gateway, and hence the networking blows up within about 30s and dies
> with a stack trace which has references to timers.
>
> I'll back out those three patches and see if it continues, but hopefully
> my little discovery is useful to someone in terms of coming up with a
> fix....
>
Rather than backing things out, please add this instead:
From: Oleg Nesterov <oleg@tv-sign.ru>
The bug was identified by Maneesh Soni.
When __mod_timer() changes timer's base it waits for the completion of
timer->function. It is just stupid: the caller of __mod_timer() can held
locks which would prevent completion of the timer's handler.
Solution: do not change the base of the currently running timer.
Side effect: __mod_timer() doesn't garantees anymore that timer will run on
the local cpu.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
kernel/timer.c | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
diff -puN kernel/timer.c~timers-fix-__mod_timer-vs-__run_timers-deadlock kernel/timer.c
--- 25/kernel/timer.c~timers-fix-__mod_timer-vs-__run_timers-deadlock 2005-05-01 02:20:28.415889280 -0700
+++ 25-akpm/kernel/timer.c 2005-05-01 02:20:28.420888520 -0700
@@ -211,41 +211,39 @@ int __mod_timer(struct timer_list *timer
timer_base_t *base;
tvec_base_t *new_base;
unsigned long flags;
- int ret = -1;
+ int ret;
BUG_ON(!timer->function);
check_timer(timer);
- do {
- base = lock_timer_base(timer, &flags);
- new_base = &__get_cpu_var(tvec_bases);
+ base = lock_timer_base(timer, &flags);
- /* Ensure the timer is serialized. */
- if (base != &new_base->t_base
- && base->running_timer == timer)
- goto unlock;
+ ret = 0;
+ if (timer_pending(timer)) {
+ detach_timer(timer, 0);
+ ret = 1;
+ }
- ret = 0;
- if (timer_pending(timer)) {
- detach_timer(timer, 0);
- ret = 1;
- }
+ new_base = &__get_cpu_var(tvec_bases);
- if (base != &new_base->t_base) {
+ if (base != &new_base->t_base) {
+ if (unlikely(base->running_timer == timer))
+ /* Don't change timer's base while it is running.
+ * Needed for serialization of timer wrt itself. */
+ new_base = container_of(base, tvec_base_t, t_base);
+ else {
timer->base = NULL;
/* Safe: the timer can't be seen via ->entry,
* and lock_timer_base checks ->base != 0. */
spin_unlock(&base->lock);
- base = &new_base->t_base;
- spin_lock(&base->lock);
- timer->base = base;
+ spin_lock(&new_base->t_base.lock);
+ timer->base = &new_base->t_base;
}
+ }
- timer->expires = expires;
- internal_add_timer(new_base, timer);
-unlock:
- spin_unlock_irqrestore(&base->lock, flags);
- } while (ret < 0);
+ timer->expires = expires;
+ internal_add_timer(new_base, timer);
+ spin_unlock_irqrestore(&new_base->t_base.lock, flags);
return ret;
}
_
next prev parent reply other threads:[~2005-05-03 9:08 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa.gbejpad.1vj8f9r@ifi.uio.no>
2005-05-03 9:00 ` 2.6.12-rc3-mm1 Reuben Farrelly
2005-05-03 9:07 ` Andrew Morton [this message]
2005-05-03 9:49 ` 2.6.12-rc3-mm1 Reuben Farrelly
2005-05-01 8:49 2.6.12-rc3-mm1 Li, Shaohua
-- strict thread matches above, loose matches on Subject: below --
2005-04-30 6:16 2.6.12-rc3-mm1 Andrew Morton
2005-04-30 9:40 ` 2.6.12-rc3-mm1 Brice Goglin
2005-04-30 10:30 ` 2.6.12-rc3-mm1 Brice Goglin
2005-04-30 10:38 ` 2.6.12-rc3-mm1 Andrew Morton
2005-04-30 11:10 ` 2.6.12-rc3-mm1 Alexander Nyberg
2005-04-30 11:26 ` 2.6.12-rc3-mm1 Andrew Morton
2005-04-30 12:27 ` 2.6.12-rc3-mm1 Ed Tomlinson
2005-04-30 22:08 ` 2.6.12-rc3-mm1 Valdis.Kletnieks
2005-04-30 22:36 ` 2.6.12-rc3-mm1 Zwane Mwaikambo
2005-04-30 22:51 ` 2.6.12-rc3-mm1 Jesper Juhl
2005-04-30 22:53 ` 2.6.12-rc3-mm1 Ed Tomlinson
2005-04-30 23:05 ` 2.6.12-rc3-mm1 Zwane Mwaikambo
2005-04-30 23:10 ` 2.6.12-rc3-mm1 Randy.Dunlap
2005-05-01 13:09 ` 2.6.12-rc3-mm1 Ed Tomlinson
2005-05-01 13:30 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-05-02 15:28 ` 2.6.12-rc3-mm1 Valdis.Kletnieks
2005-05-02 15:49 ` 2.6.12-rc3-mm1 Randy.Dunlap
2005-05-02 16:11 ` 2.6.12-rc3-mm1 Valdis.Kletnieks
2005-05-02 22:20 ` 2.6.12-rc3-mm1 Andrew Morton
2005-05-02 22:39 ` 2.6.12-rc3-mm1 Olivier Galibert
2005-05-03 0:34 ` 2.6.12-rc3-mm1 Randy.Dunlap
2005-05-02 22:41 ` 2.6.12-rc3-mm1 Frank Sorenson
2005-05-03 16:02 ` 2.6.12-rc3-mm1 Bill Davidsen
2005-05-01 13:19 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-04-30 13:25 ` 2.6.12-rc3-mm1 Alexander Nyberg
2005-04-30 13:50 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-04-30 14:07 ` 2.6.12-rc3-mm1 Richard Purdie
2005-04-30 15:04 ` 2.6.12-rc3-mm1 Russell King
2005-04-30 19:49 ` 2.6.12-rc3-mm1 Andrew Morton
2005-04-30 22:03 ` 2.6.12-rc3-mm1 Richard Purdie
2005-04-30 14:20 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-04-30 16:43 ` 2.6.12-rc3-mm1 Zwane Mwaikambo
2005-04-30 17:05 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
2005-04-30 18:08 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
2005-04-30 18:56 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-04-30 19:46 ` 2.6.12-rc3-mm1 Andrew Morton
2005-04-30 20:01 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
2005-05-08 3:53 ` 2.6.12-rc3-mm1 Li Shaohua
2005-04-30 18:30 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
2005-04-30 18:58 ` 2.6.12-rc3-mm1 Adrian Bunk
2005-04-30 15:29 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
2005-04-30 15:39 ` 2.6.12-rc3-mm1 Zwane Mwaikambo
2005-04-30 15:44 ` 2.6.12-rc3-mm1 Brice Goglin
2005-04-30 16:02 ` 2.6.12-rc3-mm1 Zwane Mwaikambo
2005-04-30 15:48 ` 2.6.12-rc3-mm1 Carlos Martin
2005-04-30 15:48 ` 2.6.12-rc3-mm1 Coywolf Qi Hunt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050503020705.29bbffbd.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=reuben-lkml@reub.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox