Skip to contentSkip to conversation

[2.5] notsc option needs some attention/TLC

PATCH Mikael Pettersson 8 participants 12 messages Nov 9, 2002 – Nov 12, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 11 lines · Zwane Mwaikambo

notsc doesn't work on a box with a TSC, when we need need the option the most...

Index: linux-2.5.46-bochs/arch/i386/kernel/cpu/common.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.46/arch/i386/kernel/cpu/common.c,v retrieving revision 1.1.1.1
diff -u -r1.1.1.1 common.c

arch/i386/kernel/cpu/common.c line 19

Quoted 8 lines
arch/i386/kernel/cpu/common.c +5 -0
@@ -12,6 +12,11 @@
 
 static int cachesize_override __initdata = -1;
 static int disable_x86_fxsr __initdata = 0;
+#ifdef CONFIG_X86_TSC
+static int tsc_disable __initdata = 0;
+#else
+#define tsc_disable	1
+#endif

CONFIG_X86_TSC means "I have a TSC, period" not "I may have a TSC". It's an optimisation option, not a "try this" option.

If we configure for "I have a TSC, period" you add the option to disable it, which nullifies any benefit of the config option in the first place since we can't assume TSC presence any more. If we don't configure for TSC, you force tsc_disable, which means that a generic kernel _can't_ use the TSC.

People with broken TSCs need to run non-TSC-assuming kernels.

/Mikael

#1 lore raw
Quoted 5 lines · Mikael Pettersson

If we configure for "I have a TSC, period" you add the option to disable it, which nullifies any benefit of the config option in the first place since we can't assume TSC presence any more. If we don't configure for TSC, you force tsc_disable, which means that a generic kernel _can't_ use the TSC.

2.4 was modified to printk a message that TSC was not disabled. This does confuse people

#2 lore raw
Quoted 8 lines
Quoted 5 lines

If we configure for "I have a TSC, period" you add the option to disable it, which nullifies any benefit of the config option in the first place since we can't assume TSC presence any more. If we don't configure for TSC, you force tsc_disable, which means that a generic kernel _can't_ use the TSC.

2.4 was modified to printk a message that TSC was not disabled. This does confuse people

Having this config option ass-backwards is mind-bogglingly confusing, and there seems no real reason for it. John had a plan to just put in CONFIG_X86_PIT instead as the inverse of this, and delete CONFIG_X86_TSC. He seems to have gone off this idea for some reason I can't understand ... I think it solves a lot of these issues ...

Having a config option called TSC that in fact has nothing to directly do with the TSC, but disables the PIT seems silly. The first time I read all this code I spend quite a while thinking it was all the incorrect, and the wrong way around ... things should be more intuitive than that.

M.

#3 lore raw
In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 5 lines · Mikael Pettersson

If we configure for "I have a TSC, period" you add the option to disable it, which nullifies any benefit of the config option in the first place since we can't assume TSC presence any more. If we don't configure for TSC, you force tsc_disable, which means that a generic kernel _can't_ use the TSC.

2.4 was modified to printk a message that TSC was not disabled. This does confuse people

This is all very confusing, notsc isnn't supposed to work with cpus with TSCs?

Zwane

Signature · 1 line
function.linuxpower.ca
#4 lore raw
Quoted 5 lines · Zwane Mwaikambo
Quoted 2 lines

2.4 was modified to printk a message that TSC was not disabled. This does confuse people

This is all very confusing, notsc isnn't supposed to work with cpus with TSCs?

User boots TSC only kernel
User gets problem
User reads docs and says "notsc"
User still has problem
User confused.

In the TSC only case printing a message that the TSC disable was not possible is IMHO good

#5 lore raw
In reply to Zwane Mwaikambo
Quoted 2 lines · Zwane Mwaikambo

This is all very confusing, notsc isnn't supposed to work with cpus with TSCs?

No.

You have two different cases:

- a kernel compiled for TSC-only. This one simply will not _work_ without a TSC, since it is statically compiled for the TSC case. Here, "notsc" simply cannot do anything, so it just prints a message saying that it doesn't work.

- a "generic" kernel, which can do the TSC decision dynamically, will use the TSC flag in the CPU features field to decide whether to use the TSC or not. Here, "notsc" will clear the flag unconditionally, so even if your CPU claims to have a TSC, it won't get used.

NOTE! We used to do a lot more statically, and on the whole the hard-coded CONFIG_X86_TSC usage has pretty much disappeared in modern kernels. It's used mainly by the "get_cycles()" macro, which is not all that commonly used any more (it used to be used by the scheduler, I think that's gone too these days).

Linus

#6 lore raw
Quoted 4 lines · Linus Torvalds

- a kernel compiled for TSC-only. This one simply will not _work_ without a TSC, since it is statically compiled for the TSC case. Here, "notsc" simply cannot do anything, so it just prints a message saying that it doesn't work.

IMHO, if you boot a "TSC-only" kernel on a machine without TSC, the correct answer should be

Panic: This kernel is compiled for TSC-only. No TSC found. Machine halted.

Same goes IMHO for "i686 on lower", "i586 on lower" and so on.

Everything else leads to strange effects and hard to decipher bug reports. If in doubt, boot i386 compiled kernel.

Regards
Henning

Signature · 5 lines
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     [email protected]

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   [email protected]
D-91054 Buckenhof     Fax.: 09131 / 50654-20   
#7 lore raw
Quoted 10 lines · Henning P. Schmiedehausen
Quoted 4 lines

- a kernel compiled for TSC-only. This one simply will not _work_ without a TSC, since it is statically compiled for the TSC case. Here, "notsc" simply cannot do anything, so it just prints a message saying that it doesn't work.

IMHO, if you boot a "TSC-only" kernel on a machine without TSC, the correct answer should be

Panic: This kernel is compiled for TSC-only. No TSC found. Machine halted.

And that happens -- see check_config() in <asm-i386/bugs.h>.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#8 lore raw
In reply to Linus Torvalds
Quoted 7 lines · Linus Torvalds

No.
You have two different cases:
- a kernel compiled for TSC-only. This one simply will not _work_ without a TSC, since it is statically compiled for the TSC case. Here, "notsc" simply cannot do anything, so it just prints a message saying that it doesn't work.
- a "generic" kernel, which can do the TSC decision dynamically, will use

Quoted 8 lines

the TSC flag in the CPU features field to decide whether to use the TSC or not. Here, "notsc" will clear the flag unconditionally, so even if your CPU claims to have a TSC, it won't get used.
NOTE! We used to do a lot more statically, and on the whole the hard-coded CONFIG_X86_TSC usage has pretty much disappeared in modern kernels. It's used mainly by the "get_cycles()" macro, which is not all that commonly used any more (it used to be used by the scheduler, I think that's gone too these days).

Then the options have been mangled and it doesn't do this right anymore, with the net result that there's no way to turn off TSC synch ever. I've narrowed this down to config options setting CONFIG_X86_TSC for at least for all cpu revisions > 586 plus unconditional TSC usage given CONFIG_X86_TSC.

Bill

#9 lore raw
Quoted 5 lines · William Lee Irwin III

Then the options have been mangled and it doesn't do this right anymore, with the net result that there's no way to turn off TSC synch ever. I've narrowed this down to config options setting CONFIG_X86_TSC for at least for all cpu revisions > 586

But that's the point. If you specify that you have a CPU > 586, then you specify at compile-time that you have TSC.

If your TSC is broken, then you shouldn't do that. You should compile for "generic x86" (386), and then say "notsc".

(Yeah, it should work for i486 too, but in general it's the "generic 386" that should work on all machines because it doesn't assume anything about the capabilities of the machine).

But considering that we don't use the static TSC knowledge very much any more, you might want to remove CONFIG_X86_TSC altogether, though, and replace its uses with run-time checks. We've done that with a lot of the other config stuff earlier (SSE/XMM) because the static compiled options are just too inconvenient and not worth the maintenance hassles..

Linus

#10 lore raw
Quoted 4 lines · Linus Torvalds

But that's the point. If you specify that you have a CPU > 586, then you specify at compile-time that you have TSC.
If your TSC is broken, then you shouldn't do that. You should compile for "generic x86" (386), and then say "notsc".

Quoted 8 lines

(Yeah, it should work for i486 too, but in general it's the "generic 386" that should work on all machines because it doesn't assume anything about the capabilities of the machine).
But considering that we don't use the static TSC knowledge very much any more, you might want to remove CONFIG_X86_TSC altogether, though, and replace its uses with run-time checks. We've done that with a lot of the other config stuff earlier (SSE/XMM) because the static compiled options are just too inconvenient and not worth the maintenance hassles..

Performance considerations make compiling for 386 a relatively poor solution. I'm very much in favor of the runtime checks and will intensively investigate that method of dealing with the situation, and with any luck follow up soon with a solution acceptable to both you and others for this dynamic TSC usage issue.

Thanks,
Bill

#11 lore raw
In reply to Linus Torvalds
Quoted 5 lines · Linus Torvalds

But considering that we don't use the static TSC knowledge very much any more, you might want to remove CONFIG_X86_TSC altogether, though, and replace its uses with run-time checks. We've done that with a lot of the other config stuff earlier (SSE/XMM) because the static compiled options are just too inconvenient and not worth the maintenance hassles..

Or we use the new config stuff to stick in

Twiddle Advanced Bits Y/N

	Include PPro fence fix
	Include ...
	Include ...