Skip to content

Commit e9088ad

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/tsc: Always unregister clocksource_tsc_early
Don't leave the tsc-early clocksource registered if it errors out early. This was reported by Diego, who on his Core2 era machine got TSC invalidated while it was running with tsc-early (due to C-states). This results in keeping tsc-early with very bad effects. Reported-and-Tested-by: Diego Viola <[email protected]> Fixes: aa83c45 ("x86/tsc: Introduce early tsc clocksource") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 6da6c0d commit e9088ad

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kernel/tsc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ static void tsc_refine_calibration_work(struct work_struct *work)
12441244

12451245
/* Don't bother refining TSC on unstable systems */
12461246
if (tsc_unstable)
1247-
return;
1247+
goto unreg;
12481248

12491249
/*
12501250
* Since the work is started early in boot, we may be
@@ -1297,11 +1297,12 @@ static void tsc_refine_calibration_work(struct work_struct *work)
12971297

12981298
out:
12991299
if (tsc_unstable)
1300-
return;
1300+
goto unreg;
13011301

13021302
if (boot_cpu_has(X86_FEATURE_ART))
13031303
art_related_clocksource = &clocksource_tsc;
13041304
clocksource_register_khz(&clocksource_tsc, tsc_khz);
1305+
unreg:
13051306
clocksource_unregister(&clocksource_tsc_early);
13061307
}
13071308

@@ -1311,8 +1312,8 @@ static int __init init_tsc_clocksource(void)
13111312
if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_disabled > 0 || !tsc_khz)
13121313
return 0;
13131314

1314-
if (check_tsc_unstable())
1315-
return 0;
1315+
if (tsc_unstable)
1316+
goto unreg;
13161317

13171318
if (tsc_clocksource_reliable)
13181319
clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
@@ -1328,6 +1329,7 @@ static int __init init_tsc_clocksource(void)
13281329
if (boot_cpu_has(X86_FEATURE_ART))
13291330
art_related_clocksource = &clocksource_tsc;
13301331
clocksource_register_khz(&clocksource_tsc, tsc_khz);
1332+
unreg:
13311333
clocksource_unregister(&clocksource_tsc_early);
13321334
return 0;
13331335
}

0 commit comments

Comments
 (0)