[PATCH] highres: do not run the TIMER_SOFTIRQ after switching to highres mode
- From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- Date: Tue, 06 Mar 2007 18:29:55 +0100
On Tue, 2007-03-06 at 08:44 -0800, Linus Torvalds wrote:
This is just a coding style thing, but I thought I should really point it
out, because these kinds of things quite often result in nasty bugs simply
because the source code is so hard to read properly:
/me pleads guilty !
Replacement patch below.
tglx
--------------------->
The TIMER_SOFTIRQ runs the hrtimers during bootup until a usable
clocksource and clock event sources are registered. The switch to high
resolution mode happens inside of the TIMER_SOFTIRQ, but runs the
softirq afterwards. That way the tick emulation timer, which was set up
in the switch to highres might be executed in the softirq context, which
is a BUG. The rbtree has not to be touched by the softirq after the
highres switch.
This BUG was observed by Andres Salomon, who provided the information to
debug it.
Return early from the softirq, when the switch was sucessful.
Remove also the superfluid hres_active check on top of
hrtimer_switch_to_hres(), as we never get there, once we switched over.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
Cc: Andres Salomon <dilinger@xxxxxxxxxx>
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index de93a81..2e465df 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -540,19 +540,18 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
/*
* Switch to high resolution mode
*/
-static void hrtimer_switch_to_hres(void)
+static int hrtimer_switch_to_hres(void)
{
struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
unsigned long flags;
-
- if (base->hres_active)
- return;
+ int err;
local_irq_save(flags);
- if (tick_init_highres()) {
+ err = tick_init_highres();
+ if (err < 0) {
local_irq_restore(flags);
- return;
+ return err;
}
base->hres_active = 1;
base->clock_base[CLOCK_REALTIME].resolution = KTIME_HIGH_RES;
@@ -565,13 +564,14 @@ static void hrtimer_switch_to_hres(void)
local_irq_restore(flags);
printk(KERN_INFO "Switched to high resolution mode on CPU %d\n",
smp_processor_id());
+ return 0;
}
#else
static inline int hrtimer_hres_active(void) { return 0; }
static inline int hrtimer_is_hres_enabled(void) { return 0; }
-static inline void hrtimer_switch_to_hres(void) { }
+static inline int hrtimer_switch_to_hres(void) { return -EINVAL; }
static inline void hrtimer_force_reprogram(struct hrtimer_cpu_base *base) { }
static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
struct hrtimer_clock_base *base)
@@ -1173,7 +1173,8 @@ void hrtimer_run_queues(void)
* deadlock vs. xtime_lock.
*/
if (tick_check_oneshot_change(!hrtimer_is_hres_enabled()))
- hrtimer_switch_to_hres();
+ if (!hrtimer_switch_to_hres())
+ return;
hrtimer_get_softirq_time(cpu_base);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [PATCH] highres: do not run the TIMER_SOFTIRQ after switching to highres mode
- From: Linus Torvalds
- Re: [PATCH] highres: do not run the TIMER_SOFTIRQ after switching to highres mode
- References:
- [5/6] 2.6.21-rc2: known regressions
- From: Adrian Bunk
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Thomas Gleixner
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Linus Torvalds
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Linus Torvalds
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Thomas Gleixner
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Linus Torvalds
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Linus Torvalds
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Michael S. Tsirkin
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Ingo Molnar
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Michael S. Tsirkin
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Ingo Molnar
- Re: [5/6] 2.6.21-rc2: known regressions
- From: Linus Torvalds
- [5/6] 2.6.21-rc2: known regressions
- Prev by Date: Re: [RFC] BadRAM still not ready for inclusion ? (was: Re: Free Linux Driver Development!)
- Next by Date: Re: [patch v2] epoll use a single inode ...
- Previous by thread: Re: [5/6] 2.6.21-rc2: known regressions
- Next by thread: Re: [PATCH] highres: do not run the TIMER_SOFTIRQ after switching to highres mode
- Index(es):
Relevant Pages
|