This patch implements Barcelona CPU detection.
Signed-off-by: Robert Richter <[email protected]>
Index: linux-2.6.22-rc3/arch/i386/perfmon/perfmon.c
===================================================================
--- linux-2.6.22-rc3.orig/arch/i386/perfmon/perfmon.c
+++ linux-2.6.22-rc3/arch/i386/perfmon/perfmon.c
@@ -1059,6 +1059,7 @@ char *pfm_arch_get_pmu_module_name(void)
goto try_arch;
}
case 15:
+ case 16:
/* All Opteron processors */
if (cpu_data->x86_vendor == X86_VENDOR_AMD)
return "perfmon_k8";
Index: linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
===================================================================
--- linux-2.6.22-rc3.orig/arch/x86_64/perfmon/perfmon_k8.c
+++ linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
@@ -307,7 +307,12 @@ static int pfm_k8_probe_pmu(void)
return -1;
}
- if (current_cpu_data.x86 != 15) {
+ switch (current_cpu_data.x86) {
+ case 15:
+ case 16:
+ PFM_INFO("found family=%d", current_cpu_data.x86);
+ break;
+ default:
PFM_INFO("unsupported family=%d", current_cpu_data.x86);
return -1;
}
--
AMD Saxony, Dresden, Germany
Operating System Research Center
email: [email protected]
On Wed, 20 Jun 2007, Robert Richter wrote:
> Index: linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
> ===================================================================
> --- linux-2.6.22-rc3.orig/arch/x86_64/perfmon/perfmon_k8.c
> +++ linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
> @@ -307,7 +307,12 @@ static int pfm_k8_probe_pmu(void)
> return -1;
> }
>
> - if (current_cpu_data.x86 != 15) {
> + switch (current_cpu_data.x86) {
> + case 15:
> + case 16:
> + PFM_INFO("found family=%d", current_cpu_data.x86);
> + break;
> + default:
> PFM_INFO("unsupported family=%d", current_cpu_data.x86);
> return -1;
> }
This still shouldn't be a switch clause because you're hiding the return
-1; in the default label. I think it would be better to write:
if (current_cpu_data.x86 == 15 || current_cpu_data.x86 == 16)
PFM_INFO("found family=%d", current_cpu_data.x86);
else {
PFM_INFO("unsupported family=%d", current_cpu_data.x86);
return -1;
}
On 20.06.07 12:45:35, David Rientjes wrote:
> On Wed, 20 Jun 2007, Robert Richter wrote:
>
> > Index: linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
> > ===================================================================
> > --- linux-2.6.22-rc3.orig/arch/x86_64/perfmon/perfmon_k8.c
> > +++ linux-2.6.22-rc3/arch/x86_64/perfmon/perfmon_k8.c
> > @@ -307,7 +307,12 @@ static int pfm_k8_probe_pmu(void)
> > return -1;
> > }
> >
> > - if (current_cpu_data.x86 != 15) {
> > + switch (current_cpu_data.x86) {
> > + case 15:
> > + case 16:
> > + PFM_INFO("found family=%d", current_cpu_data.x86);
> > + break;
> > + default:
> > PFM_INFO("unsupported family=%d", current_cpu_data.x86);
> > return -1;
> > }
>
> This still shouldn't be a switch clause because you're hiding the return
> -1; in the default label. I think it would be better to write:
>
> if (current_cpu_data.x86 == 15 || current_cpu_data.x86 == 16)
> PFM_INFO("found family=%d", current_cpu_data.x86);
> else {
> PFM_INFO("unsupported family=%d", current_cpu_data.x86);
> return -1;
> }
>
>
With the next CPU family the if condition would be too long while
adding another case statement is more readable. Anyway, things always
have 2 sides and I understand your concerns.
-Robert
--
AMD Saxony, Dresden, Germany
Operating System Research Center
email: [email protected]