Skip to contentSkip to conversation

x86: fix confusing name of /proc/cpuinfo "ht" flag

RFC PATCH In review Bartlomiej Zolnierkiewicz 7 participants 14 messages Nov 11, 2009 – Nov 13, 2009 x86

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: fix confusing name of /proc/cpuinfo "ht" flag

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

---
It could be that there are some user-space programs depending on "ht" flag so the patch is marked as RFC..

 arch/x86/include/asm/cpufeature.h |    4 ++--
 arch/x86/kernel/cpu/capflags.c    |    2 +-
 arch/x86/kernel/cpu/common.c      |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +2 -2
Index: b/arch/x86/include/asm/cpufeature.h
===================================================================
@@ -42,7 +42,7 @@
 #define X86_FEATURE_XMM		(0*32+25) /* "sse" */
 #define X86_FEATURE_XMM2	(0*32+26) /* "sse2" */
 #define X86_FEATURE_SELFSNOOP	(0*32+27) /* "ss" CPU self snoop */
-#define X86_FEATURE_HT		(0*32+28) /* Hyper-Threading */
+#define X86_FEATURE_HT_DETECTION (0*32+28) /* Hyper-Threading detection */
 #define X86_FEATURE_ACC		(0*32+29) /* "tm" Automatic clock control */
 #define X86_FEATURE_IA64	(0*32+30) /* IA-64 processor */
 #define X86_FEATURE_PBE		(0*32+31) /* Pending Break Enable */
@@ -220,7 +220,7 @@ extern const char * const x86_power_flag
 #define cpu_has_xmm2		boot_cpu_has(X86_FEATURE_XMM2)
 #define cpu_has_xmm3		boot_cpu_has(X86_FEATURE_XMM3)
 #define cpu_has_aes		boot_cpu_has(X86_FEATURE_AES)
-#define cpu_has_ht		boot_cpu_has(X86_FEATURE_HT)
+#define cpu_has_ht_detection	boot_cpu_has(X86_FEATURE_HT_DETECTION)
 #define cpu_has_mp		boot_cpu_has(X86_FEATURE_MP)
 #define cpu_has_nx		boot_cpu_has(X86_FEATURE_NX)
 #define cpu_has_k6_mtrr		boot_cpu_has(X86_FEATURE_K6_MTRR)
arch/x86/kernel/cpu/capflags.c +1 -1
Index: b/arch/x86/kernel/cpu/capflags.c
===================================================================
@@ -27,7 +27,7 @@ const char * const x86_cap_flags[NCAPINT
 	[X86_FEATURE_XMM]                = "sse",
 	[X86_FEATURE_XMM2]               = "sse2",
 	[X86_FEATURE_SELFSNOOP]          = "ss",
-	[X86_FEATURE_HT]                 = "ht",
+	[X86_FEATURE_HT_DETECTION]       = "ht_detection",
 	[X86_FEATURE_ACC]                = "tm",
 	[X86_FEATURE_IA64]               = "ia64",
 	[X86_FEATURE_PBE]                = "pbe",
arch/x86/kernel/cpu/common.c +1 -1
Index: b/arch/x86/kernel/cpu/common.c
===================================================================
@@ -433,7 +433,7 @@ void __cpuinit detect_ht(struct cpuinfo_
 	u32 eax, ebx, ecx, edx;
 	int index_msb, core_bits;
 
-	if (!cpu_has(c, X86_FEATURE_HT))
+	if (!cpu_has(c, X86_FEATURE_HT_DETECTION))
 		return;
 
 	if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
#1 lore raw
Quoted 10 lines · Bartlomiej Zolnierkiewicz

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

---
It could be that there are some user-space programs depending on "ht" flag so the patch is marked as RFC..

If a cpu is capable of ht but doesn't have any siblings, do we actually care?

If many people consider the "ht" flag to indicate that hyperthreading is actually available, what about instead changing the meaning of the "ht" flag to indicate that there actually are siblings?

Chris

#2 lore raw
Quoted 6 lines · Chris Friesen
Quoted 6 lines

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

Quoted 8 lines
Quoted 4 lines

---
It could be that there are some user-space programs depending on "ht" flag so the patch is marked as RFC..

If a cpu is capable of ht but doesn't have any siblings, do we actually care?

I have a Core2 Duo U7600 with siblings set to 2 and the 'ht' flag and I know the CPU in my lapdog does not actually support hyperthreading.

Quoted 4 lines

If many people consider the "ht" flag to indicate that hyperthreading is actually available, what about instead changing the meaning of the "ht" flag to indicate that there actually are siblings?

Could be determined surely by "grep siblings /proc/cpuinfo"?

Cheers

Signature · 2 lines
Alexander Clouter
.sigmonster says: Old musicians never die, they just decompose.
#3 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 10 lines · Bartlomiej Zolnierkiewicz

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

---
It could be that there are some user-space programs depending on "ht" flag so the patch is marked as RFC..

I think that is the only problem with this patch -- it is an ABI change.
See as it's been this way for years, a comment is probably the best
you can do...

Jeff

#4 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 5 lines · Bartlomiej Zolnierkiewicz

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

i think instead of changing 'ht' to 'ht_detect', it would be even more intuitive to only expose the 'ht' flag if the ht-detect capability is there _and_ if the number of siblings is 2 or more.

That way we dont change it - we just 'hide' the 'ht' string on the category of systems that can enumerate HT via the CPUID but dont actually have HyperThreading.

Hm?

Ingo

#5 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 5 lines · Bartlomiej Zolnierkiewicz

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

Quoted 8 lines

i think instead of changing 'ht' to 'ht_detect', it would be even more intuitive to only expose the 'ht' flag if the ht-detect capability is there _and_ if the number of siblings is 2 or more.

That way we dont change it - we just 'hide' the 'ht' string on the category of systems that can enumerate HT via the CPUID but dont actually have HyperThreading.

/proc/cpuinfo is a user-space visible ABI. Changing it is bad chicken.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#6 lore raw
Quoted 14 lines · H. Peter Anvin
Quoted 13 lines · Ingo Molnar
Quoted 5 lines · Bartlomiej Zolnierkiewicz

"ht" flag indicates only ability to detect siblings not HT presence itself.

Inspired by:
http://www.codemonkey.org.uk/2009/11/10/common-hyperthreading-misconception/

i think instead of changing 'ht' to 'ht_detect', it would be even more intuitive to only expose the 'ht' flag if the ht-detect capability is there _and_ if the number of siblings is 2 or more.

Quoted 6 lines
Quoted 3 lines

That way we dont change it - we just 'hide' the 'ht' string on the category of systems that can enumerate HT via the CPUID but dont actually have HyperThreading.

/proc/cpuinfo is a user-space visible ABI. Changing it is bad chicken.

Almost ... something is only an ABI if an actual application relies on the 'ht' flag being there on non-hyperthreading CPUs. We dont know whether there's any, but the likelyhood looks pretty low. Could park it a branch for some time to see whether anything trips up.

Ingo

#7 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 3 lines

/proc/cpuinfo is a user-space visible ABI. Changing it is bad chicken.

Almost ... something is only an ABI if an actual application relies on the 'ht' flag being there on non-hyperthreading CPUs. We dont know whether there's any, but the likelyhood looks pretty low. Could park it a branch for some time to see whether anything trips up.

No, please. We have had people who have "helpfully" tried to change /proc/cpuinfo in the past, and what we find is that application developers don't tell us -- they grumble among themselves and put out a new release saying "fixes breakage introduced by Linux ..."

It's an ABI. Keep it stable, please.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#8 lore raw
Quoted 11 lines · H. Peter Anvin
Quoted 9 lines · Ingo Molnar
Quoted 3 lines

/proc/cpuinfo is a user-space visible ABI. Changing it is bad chicken.

Almost ... something is only an ABI if an actual application relies on the 'ht' flag being there on non-hyperthreading CPUs. We dont know whether there's any, but the likelyhood looks pretty low. Could park it a branch for some time to see whether anything trips up.

Quoted 6 lines

No, please. We have had people who have "helpfully" tried to change /proc/cpuinfo in the past, and what we find is that application developers don't tell us -- they grumble among themselves and put out a new release saying "fixes breakage introduced by Linux ..."

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

Ingo

#9 lore raw
Quoted 8 lines · Ingo Molnar
Quoted 1 line

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

I agree that it's an ABI change, but any software depending on its current state has to implement a fallback for the case where 'ht' isn't present anyway unless there's some program that only runs on ht capable hardware, which sounds just crazy.

The only potential for breakage that I can see is that code that is tuned to be run in the HT case will stop running in cases where it shouldn't. Which sounds like a positive thing to me.

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#10 lore raw
Quoted 10 lines · Dave Jones
Quoted 8 lines · Ingo Molnar
Quoted 1 line

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

Quoted 8 lines

I agree that it's an ABI change, but any software depending on its current state has to implement a fallback for the case where 'ht' isn't present anyway unless there's some program that only runs on ht capable hardware, which sounds just crazy.

The only potential for breakage that I can see is that code that is tuned to be run in the HT case will stop running in cases where it shouldn't. Which sounds like a positive thing to me.

The most likely breakage would be some stupid licensing scheme.

The other aspect is that we as much as possible have tried to stay to the hardware-documented names of these strings. Inventing new strings is generally a bad idea.

-hpa

#11 lore raw
Quoted 20 lines · H. Peter Anvin
Quoted 10 lines · Dave Jones
Quoted 8 lines · Ingo Molnar
Quoted 1 line

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

Quoted 8 lines

I agree that it's an ABI change, but any software depending on its current state has to implement a fallback for the case where 'ht' isn't present anyway unless there's some program that only runs on ht capable hardware, which sounds just crazy.

The only potential for breakage that I can see is that code that is tuned to be run in the HT case will stop running in cases where it shouldn't. Which sounds like a positive thing to me.

Quoted 5 lines

The most likely breakage would be some stupid licensing scheme.

The other aspect is that we as much as possible have tried to stay to the hardware-documented names of these strings. Inventing new strings is generally a bad idea.

Agreed - and we rejected such patches a couple of times in the past and for good reasons. Some /proc details are rarely used by apps (so they are no real ABIs) but cpuinfo is frequently parsed.

Clearing the ht flag on non-hyperthreading CPUs would be a limited quirk/fix in essence applicable to a relatively narrow range of CPUs - and easily undone, should it cause any problems. So if Bart wants to take a stab at that it would be a nice solution to the problem at hand
...

Ingo

#12 lore raw
Quoted 33 lines · On Friday 13 November 2009 08:42:48 Ingo Molnar wrote:
Quoted 20 lines · H. Peter Anvin
Quoted 10 lines · Dave Jones
Quoted 8 lines · Ingo Molnar
Quoted 1 line

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

Quoted 8 lines

I agree that it's an ABI change, but any software depending on its current state has to implement a fallback for the case where 'ht' isn't present anyway unless there's some program that only runs on ht capable hardware, which sounds just crazy.

The only potential for breakage that I can see is that code that is tuned to be run in the HT case will stop running in cases where it shouldn't. Which sounds like a positive thing to me.

Quoted 5 lines

The most likely breakage would be some stupid licensing scheme.

The other aspect is that we as much as possible have tried to stay to the hardware-documented names of these strings. Inventing new strings is generally a bad idea.

Agreed - and we rejected such patches a couple of times in the past and for good reasons. Some /proc details are rarely used by apps (so they are no real ABIs) but cpuinfo is frequently parsed.

Quoted 5 lines

Clearing the ht flag on non-hyperthreading CPUs would be a limited quirk/fix in essence applicable to a relatively narrow range of CPUs - and easily undone, should it cause any problems. So if Bart wants to take a stab at that it would be a nice solution to the problem at hand
...

I'm rather busy with other/real stuff so if anybody wants to beat me to making the proper quirk just feel free to do it.

Signature · 1 line
Bartlomiej Zolnierkiewicz
#13 lore raw
In reply to Ingo Molnar
Quoted 6 lines · Ingo Molnar
Quoted 6 lines

No, please. We have had people who have "helpfully" tried to change /proc/cpuinfo in the past, and what we find is that application developers don't tell us -- they grumble among themselves and put out a new release saying "fixes breakage introduced by Linux ..."

Quoted 9 lines
Quoted 1 line

It's an ABI. Keep it stable, please.

That's generally true, but i'm not suggesting that: i'm suggesting to _clear_ the HT flag from the cpufeatures if there's only one sibling. It's meaningless in that case and as the link quoted by the original patch shows many people are confused by that.

I have such a box so i can test it. (but i dont expect any problems)

Ah, okay, that makes more sense. Someone else in the tread wanted to rename the flag.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.