Skip to contentSkip to conversation

perf_counter/x86: Fix incorrect default branch

PATCH In review Yong Wang 2 participants 6 messages Jun 9, 2009 – Jun 10, 2009 x86

lore
Share & tools
lore

Yong Wang

author
#0 lore raw

PATCH 1/1 perf_counter/x86: Fix incorrect default branch

The event selector and UMASK values of Nehalem do not apply to all Intel processors.

---
 arch/x86/kernel/cpu/perf_counter.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_counter.c +2 -1
index 56001fe..c74b6d1 100644
@@ -1413,7 +1413,6 @@ static int intel_pmu_init(void)
 
 		pr_cont("Core2 events, ");
 		break;
-	default:
 	case 26:
 		memcpy(hw_cache_event_ids, nehalem_hw_cache_event_ids,
 		       sizeof(hw_cache_event_ids));
@@ -1426,6 +1425,8 @@ static int intel_pmu_init(void)
 
 		pr_cont("Atom events, ");
 		break;
+	default:
+		break;
 	}
 	return 0;
 }
#1 lore raw
Quoted 2 lines · Yong Wang

The event selector and UMASK values of Nehalem do not apply to all Intel processors.

The idea was to offer _some_ sort of table on new CPUs, instead of nothing...

Eventually Intel stops changing those model specific index values in future CPUs and puts them into architectural perfmon, for fundamental stats like L1/LLC cache statistics.

In that case defaulting to the latest (known) enumeration might work out to be just the thing used by all future CPUs.

So this is a subtle hint ;-)

Ingo

author
#2 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 2 lines · Yong Wang

The event selector and UMASK values of Nehalem do not apply to all Intel processors.

The idea was to offer _some_ sort of table on new CPUs, instead of nothing...

Quoted 9 lines

Eventually Intel stops changing those model specific index values in future CPUs and puts them into architectural perfmon, for fundamental stats like L1/LLC cache statistics.

In that case defaulting to the latest (known) enumeration might work out to be just the thing used by all future CPUs.

So this is a subtle hint ;-)

I see what you mean. You talked about future cpus. But what about those old ones that are not atom, core2 or nehalem? Forget about them?

Thanks
-Yong

#3 lore raw
Quoted 17 lines · Yong Wang
Quoted 16 lines · Ingo Molnar
Quoted 2 lines · Yong Wang

The event selector and UMASK values of Nehalem do not apply to all Intel processors.

The idea was to offer _some_ sort of table on new CPUs, instead of nothing...

Eventually Intel stops changing those model specific index values in future CPUs and puts them into architectural perfmon, for fundamental stats like L1/LLC cache statistics.

In that case defaulting to the latest (known) enumeration might work out to be just the thing used by all future CPUs.

Quoted 6 lines
Quoted 2 lines

So this is a subtle hint ;-)

I see what you mean. You talked about future cpus. But what about those old ones that are not atom, core2 or nehalem? Forget about them?

They dont have X86_FEATURE_ARCH_PERFMON set, right?

I made the switch statement under the assumption that it covers all existing arch-perfmon CPU models. If not, the 'default:' placement would indeed be buggy.

Ingo

author
#4 lore raw
Quoted 7 lines · Ingo Molnar

They dont have X86_FEATURE_ARCH_PERFMON set, right?

I made the switch statement under the assumption that it covers all existing arch-perfmon CPU models. If not, the 'default:' placement would indeed be buggy.

OK, you are right. X86_FEATURE_ARCH_PERFMON eliminates all the old CPUs. However, the logic still seems not correct. Both the Core2 CPUs I'm using are recognized as Nehalem/Corei7. /proc/cpuinfo and cpuid outputs are given below.

The first one:
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz
stepping : 6

CPUID.0x00000001: eax=0x00010676

The second one:
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
stepping : 6

CPUID.0x00000001: eax=0x000006f6

Looks like it's not enough to just look at boot_cpu_data.x86_model.

-Yong

#5 lore raw
Quoted 30 lines · Yong Wang
Quoted 7 lines · Ingo Molnar

They dont have X86_FEATURE_ARCH_PERFMON set, right?

I made the switch statement under the assumption that it covers all existing arch-perfmon CPU models. If not, the 'default:' placement would indeed be buggy.

OK, you are right. X86_FEATURE_ARCH_PERFMON eliminates all the old CPUs. However, the logic still seems not correct. Both the Core2 CPUs I'm using are recognized as Nehalem/Corei7. /proc/cpuinfo and cpuid outputs are given below.

The first one:
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz
stepping : 6

CPUID.0x00000001: eax=0x00010676

The second one:
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
stepping : 6

Quoted 3 lines

CPUID.0x00000001: eax=0x000006f6

Looks like it's not enough to just look at boot_cpu_data.x86_model.

Yeah - i've applied the patch you sent, thanks. I'm mostly working on NHM so i didnt notice.

Ingo