sched/clock, clocksource: Add optional cs::mark_unstable() method
PeterZ reported that we'd fail to mark the TSC unstable when the clocksource watchdog finds it unsuitable. Allow a clocksource to run a custom action when its being marked unstable and hook up the TSC unstable code. Reported-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
cb42c9a3eb
commit
12907fbb1a
@ -1106,6 +1106,16 @@ static u64 read_tsc(struct clocksource *cs)
|
|||||||
return (u64)rdtsc_ordered();
|
return (u64)rdtsc_ordered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tsc_cs_mark_unstable(struct clocksource *cs)
|
||||||
|
{
|
||||||
|
if (tsc_unstable)
|
||||||
|
return;
|
||||||
|
tsc_unstable = 1;
|
||||||
|
clear_sched_clock_stable();
|
||||||
|
disable_sched_clock_irqtime();
|
||||||
|
pr_info("Marking TSC unstable due to clocksource watchdog\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* .mask MUST be CLOCKSOURCE_MASK(64). See comment above read_tsc()
|
* .mask MUST be CLOCKSOURCE_MASK(64). See comment above read_tsc()
|
||||||
*/
|
*/
|
||||||
@ -1118,6 +1128,7 @@ static struct clocksource clocksource_tsc = {
|
|||||||
CLOCK_SOURCE_MUST_VERIFY,
|
CLOCK_SOURCE_MUST_VERIFY,
|
||||||
.archdata = { .vclock_mode = VCLOCK_TSC },
|
.archdata = { .vclock_mode = VCLOCK_TSC },
|
||||||
.resume = tsc_resume,
|
.resume = tsc_resume,
|
||||||
|
.mark_unstable = tsc_cs_mark_unstable,
|
||||||
};
|
};
|
||||||
|
|
||||||
void mark_tsc_unstable(char *reason)
|
void mark_tsc_unstable(char *reason)
|
||||||
|
@ -62,6 +62,8 @@ struct module;
|
|||||||
* @archdata: arch-specific data
|
* @archdata: arch-specific data
|
||||||
* @suspend: suspend function for the clocksource, if necessary
|
* @suspend: suspend function for the clocksource, if necessary
|
||||||
* @resume: resume function for the clocksource, if necessary
|
* @resume: resume function for the clocksource, if necessary
|
||||||
|
* @mark_unstable: Optional function to inform the clocksource driver that
|
||||||
|
* the watchdog marked the clocksource unstable
|
||||||
* @owner: module reference, must be set by clocksource in modules
|
* @owner: module reference, must be set by clocksource in modules
|
||||||
*
|
*
|
||||||
* Note: This struct is not used in hotpathes of the timekeeping code
|
* Note: This struct is not used in hotpathes of the timekeeping code
|
||||||
@ -93,6 +95,7 @@ struct clocksource {
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void (*suspend)(struct clocksource *cs);
|
void (*suspend)(struct clocksource *cs);
|
||||||
void (*resume)(struct clocksource *cs);
|
void (*resume)(struct clocksource *cs);
|
||||||
|
void (*mark_unstable)(struct clocksource *cs);
|
||||||
|
|
||||||
/* private: */
|
/* private: */
|
||||||
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
|
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
|
||||||
|
@ -141,6 +141,10 @@ static void __clocksource_unstable(struct clocksource *cs)
|
|||||||
{
|
{
|
||||||
cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
|
cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
|
||||||
cs->flags |= CLOCK_SOURCE_UNSTABLE;
|
cs->flags |= CLOCK_SOURCE_UNSTABLE;
|
||||||
|
|
||||||
|
if (cs->mark_unstable)
|
||||||
|
cs->mark_unstable(cs);
|
||||||
|
|
||||||
if (finished_booting)
|
if (finished_booting)
|
||||||
schedule_work(&watchdog_work);
|
schedule_work(&watchdog_work);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user