Skip to content

Commit fe9af81

Browse files
Pavel TatashinKAGA-KOKO
authored andcommitted
x86/tsc: Redefine notsc to behave as tsc=unstable
Currently, the notsc kernel parameter disables the use of the TSC by sched_clock(). However, this parameter does not prevent the kernel from accessing tsc in other places. The only rationale to boot with notsc is to avoid timing discrepancies on multi-socket systems where TSC are not properly synchronized, and thus exclude TSC from being used for time keeping. But that prevents using TSC as sched_clock() as well, which is not necessary as the core sched_clock() implementation can handle non synchronized TSC based sched clocks just fine. However, there is another method to solve the above problem: booting with tsc=unstable parameter. This parameter allows sched_clock() to use TSC and just excludes it from timekeeping. So there is no real reason to keep notsc, but for compatibility reasons the parameter has to stay. Make it behave like 'tsc=unstable' instead. [ tglx: Massaged changelog ] Signed-off-by: Pavel Tatashin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Dou Liyang <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [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 9b3661c commit fe9af81

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,8 +2835,6 @@
28352835

28362836
nosync [HW,M68K] Disables sync negotiation for all devices.
28372837

2838-
notsc [BUGS=X86-32] Disable Time Stamp Counter
2839-
28402838
nowatchdog [KNL] Disable both lockup detectors, i.e.
28412839
soft-lockup and NMI watchdog (hard-lockup).
28422840

Documentation/x86/x86_64/boot-options.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ APICs
9292
Timing
9393

9494
notsc
95-
Don't use the CPU time stamp counter to read the wall time.
96-
This can be used to work around timing problems on multiprocessor systems
97-
with not properly synchronized CPUs.
95+
Deprecated, use tsc=unstable instead.
9896

9997
nohpet
10098
Don't use the HPET timer.

arch/x86/kernel/tsc.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ EXPORT_SYMBOL(tsc_khz);
3838
*/
3939
static int __read_mostly tsc_unstable;
4040

41-
/* native_sched_clock() is called before tsc_init(), so
42-
we must start with the TSC soft disabled to prevent
43-
erroneous rdtsc usage on !boot_cpu_has(X86_FEATURE_TSC) processors */
44-
static int __read_mostly tsc_disabled = -1;
45-
4641
static DEFINE_STATIC_KEY_FALSE(__use_tsc);
4742

4843
int tsc_clocksource_reliable;
@@ -248,8 +243,7 @@ EXPORT_SYMBOL_GPL(check_tsc_unstable);
248243
#ifdef CONFIG_X86_TSC
249244
int __init notsc_setup(char *str)
250245
{
251-
pr_warn("Kernel compiled with CONFIG_X86_TSC, cannot disable TSC completely\n");
252-
tsc_disabled = 1;
246+
mark_tsc_unstable("boot parameter notsc");
253247
return 1;
254248
}
255249
#else
@@ -1307,7 +1301,7 @@ static void tsc_refine_calibration_work(struct work_struct *work)
13071301

13081302
static int __init init_tsc_clocksource(void)
13091303
{
1310-
if (!boot_cpu_has(X86_FEATURE_TSC) || tsc_disabled > 0 || !tsc_khz)
1304+
if (!boot_cpu_has(X86_FEATURE_TSC) || !tsc_khz)
13111305
return 0;
13121306

13131307
if (tsc_unstable)
@@ -1414,12 +1408,6 @@ void __init tsc_init(void)
14141408
set_cyc2ns_scale(tsc_khz, cpu, cyc);
14151409
}
14161410

1417-
if (tsc_disabled > 0)
1418-
return;
1419-
1420-
/* now allow native_sched_clock() to use rdtsc */
1421-
1422-
tsc_disabled = 0;
14231411
static_branch_enable(&__use_tsc);
14241412

14251413
if (!no_sched_irq_time)
@@ -1455,7 +1443,7 @@ unsigned long calibrate_delay_is_known(void)
14551443
int constant_tsc = cpu_has(&cpu_data(cpu), X86_FEATURE_CONSTANT_TSC);
14561444
const struct cpumask *mask = topology_core_cpumask(cpu);
14571445

1458-
if (tsc_disabled || !constant_tsc || !mask)
1446+
if (!constant_tsc || !mask)
14591447
return 0;
14601448

14611449
sibling = cpumask_any_but(mask, cpu);

0 commit comments

Comments
 (0)