mirror of https://gitee.com/openkylin/linux.git
[PATCH] highres: do not run the TIMER_SOFTIRQ after switching to highres mode
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. [dilinger@debian.org: add debug warning] [akpm@linux-foundation.org: make debug warning compile] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andres Salomon <dilinger@debian.org> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andres Salomon <dilinger@debian.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d1d67174b4
commit
f8953856eb
|
@ -540,19 +540,19 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
|
||||||
/*
|
/*
|
||||||
* Switch to high resolution mode
|
* 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);
|
struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (base->hres_active)
|
if (base->hres_active)
|
||||||
return;
|
return 1;
|
||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
|
|
||||||
if (tick_init_highres()) {
|
if (tick_init_highres()) {
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
base->hres_active = 1;
|
base->hres_active = 1;
|
||||||
base->clock_base[CLOCK_REALTIME].resolution = KTIME_HIGH_RES;
|
base->clock_base[CLOCK_REALTIME].resolution = KTIME_HIGH_RES;
|
||||||
|
@ -565,13 +565,14 @@ static void hrtimer_switch_to_hres(void)
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
printk(KERN_INFO "Switched to high resolution mode on CPU %d\n",
|
printk(KERN_INFO "Switched to high resolution mode on CPU %d\n",
|
||||||
smp_processor_id());
|
smp_processor_id());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline int hrtimer_hres_active(void) { return 0; }
|
static inline int hrtimer_hres_active(void) { return 0; }
|
||||||
static inline int hrtimer_is_hres_enabled(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 0; }
|
||||||
static inline void hrtimer_force_reprogram(struct hrtimer_cpu_base *base) { }
|
static inline void hrtimer_force_reprogram(struct hrtimer_cpu_base *base) { }
|
||||||
static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
|
static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
|
||||||
struct hrtimer_clock_base *base)
|
struct hrtimer_clock_base *base)
|
||||||
|
@ -1130,6 +1131,9 @@ static inline void run_hrtimer_queue(struct hrtimer_cpu_base *cpu_base,
|
||||||
if (base->softirq_time.tv64 <= timer->expires.tv64)
|
if (base->softirq_time.tv64 <= timer->expires.tv64)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef CONFIG_HIGH_RES_TIMERS
|
||||||
|
WARN_ON_ONCE(timer->cb_mode == HRTIMER_CB_IRQSAFE_NO_SOFTIRQ);
|
||||||
|
#endif
|
||||||
timer_stats_account_hrtimer(timer);
|
timer_stats_account_hrtimer(timer);
|
||||||
|
|
||||||
fn = timer->function;
|
fn = timer->function;
|
||||||
|
@ -1173,7 +1177,8 @@ void hrtimer_run_queues(void)
|
||||||
* deadlock vs. xtime_lock.
|
* deadlock vs. xtime_lock.
|
||||||
*/
|
*/
|
||||||
if (tick_check_oneshot_change(!hrtimer_is_hres_enabled()))
|
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);
|
hrtimer_get_softirq_time(cpu_base);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue