From: Thomas Renninger on
On Monday 22 March 2010 19:38:39 Borislav Petkov wrote:
> From: Mark Langsdorf <mark.langsdorf(a)amd.com>
>
> Starting with model 10 of Family 0x10, AMD processors may have
> support for APERF/MPERF. Add support for identifying it and using
> it within cpufreq. Move the APERF/MPERF functions out of the
> acpi-cpufreq code and into their own file so they can easily be
> shared.
>
> Signed-off-by: Mark Langsdorf <mark.langsdorf(a)amd.com>
> Signed-off-by: Borislav Petkov <borislav.petkov(a)amd.com>
> ---
> arch/x86/kernel/cpu/amd.c | 6 +++
> arch/x86/kernel/cpu/cpufreq/Makefile | 4 +-
> arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 44 +-----------------------
> arch/x86/kernel/cpu/cpufreq/mperf.c | 50 ++++++++++++++++++++++++++++
> arch/x86/kernel/cpu/cpufreq/mperf.h | 9 +++++
> arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 8 ++++
> 6 files changed, 77 insertions(+), 44 deletions(-)
> create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.c
> create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.h
>
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index e485825..796f662 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -537,6 +537,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
> set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
> }
>
> + if (c->cpuid_level >= 6) {
> + unsigned ecx = cpuid_ecx(6);
> + if (ecx & 0x01)
> + set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> + }
This is nearly identical to (beside c->cpuid_level > 6),
in arch/x86/kernel/cpu/intel.c:
if (c->cpuid_level > 6) {
unsigned ecx = cpuid_ecx(6);
if (ecx & 0x01)
set_cpu_cap(c, X86_FEATURE_APERFMPERF);
}
I expect you are correct... or could it get moved to general x86 init code?

Thomas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Borislav Petkov on
From: Thomas Renninger <trenn(a)suse.de>
Date: Tue, Mar 23, 2010 at 12:26:22PM +0100

> On Monday 22 March 2010 19:38:39 Borislav Petkov wrote:
> > From: Mark Langsdorf <mark.langsdorf(a)amd.com>
> >
> > Starting with model 10 of Family 0x10, AMD processors may have
> > support for APERF/MPERF. Add support for identifying it and using
> > it within cpufreq. Move the APERF/MPERF functions out of the
> > acpi-cpufreq code and into their own file so they can easily be
> > shared.
> >
> > Signed-off-by: Mark Langsdorf <mark.langsdorf(a)amd.com>
> > Signed-off-by: Borislav Petkov <borislav.petkov(a)amd.com>
> > ---
> > arch/x86/kernel/cpu/amd.c | 6 +++
> > arch/x86/kernel/cpu/cpufreq/Makefile | 4 +-
> > arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 44 +-----------------------
> > arch/x86/kernel/cpu/cpufreq/mperf.c | 50 ++++++++++++++++++++++++++++
> > arch/x86/kernel/cpu/cpufreq/mperf.h | 9 +++++
> > arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 8 ++++
> > 6 files changed, 77 insertions(+), 44 deletions(-)
> > create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.c
> > create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.h
> >
> > diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> > index e485825..796f662 100644
> > --- a/arch/x86/kernel/cpu/amd.c
> > +++ b/arch/x86/kernel/cpu/amd.c
> > @@ -537,6 +537,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
> > set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
> > }
> >
> > + if (c->cpuid_level >= 6) {
> > + unsigned ecx = cpuid_ecx(6);
> > + if (ecx & 0x01)
> > + set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> > + }
> This is nearly identical to (beside c->cpuid_level > 6),
> in arch/x86/kernel/cpu/intel.c:
> if (c->cpuid_level > 6) {
> unsigned ecx = cpuid_ecx(6);
> if (ecx & 0x01)
> set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> }
> I expect you are correct... or could it get moved to general x86 init code?

Sounds good...

--
Regards/Gruss,
Boris.

--
Advanced Micro Devices, Inc.
Operating Systems Research Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Thomas Renninger on
On Wednesday 24 March 2010 18:46:21 Borislav Petkov wrote:
> From: Mark Langsdorf <mark.langsdorf(a)amd.com>
>
> Starting with model 10 of Family 0x10, AMD processors may have
> support for APERF/MPERF. Add support for identifying it and using
> it within cpufreq. Move the APERF/MPERF functions out of the
> acpi-cpufreq code and into their own file so they can easily be
> shared.
>
> Signed-off-by: Mark Langsdorf <mark.langsdorf(a)amd.com>
> Signed-off-by: Borislav Petkov <borislav.petkov(a)amd.com>
> ---
> arch/x86/kernel/cpu/amd.c | 6 +++
> arch/x86/kernel/cpu/cpufreq/Makefile | 4 +-
> arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 44 +-----------------------
> arch/x86/kernel/cpu/cpufreq/mperf.c | 50 ++++++++++++++++++++++++++++
> arch/x86/kernel/cpu/cpufreq/mperf.h | 9 +++++
> arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 8 ++++
> 6 files changed, 77 insertions(+), 44 deletions(-)
> create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.c
> create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.h
>
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index e485825..796f662 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -537,6 +537,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
> set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
> }
>
> + if (c->cpuid_level >= 6) {
> + unsigned ecx = cpuid_ecx(6);
> + if (ecx & 0x01)
> + set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> + }
> +
Can you put this into:
arch/x86/kernel/cpu/common.c (or wherever it fits in general x86 cpu init code)
and remove this (arch/x86/kernel/cpu/intel.c):
if (c->cpuid_level > 6) {
unsigned ecx = cpuid_ecx(6);
if (ecx & 0x01)
set_cpu_cap(c, X86_FEATURE_APERFMPERF);
}

an x86 maintainer might want to double check, but I expect this should work
for all x86 machines?

Thomas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Borislav Petkov on
From: Thomas Renninger <trenn(a)suse.de>
Date: Thu, Mar 25, 2010 at 10:43:04AM +0100

Hi Thomas,

> On Wednesday 24 March 2010 18:46:21 Borislav Petkov wrote:
> > From: Mark Langsdorf <mark.langsdorf(a)amd.com>
> >
> > Starting with model 10 of Family 0x10, AMD processors may have
> > support for APERF/MPERF. Add support for identifying it and using
> > it within cpufreq. Move the APERF/MPERF functions out of the
> > acpi-cpufreq code and into their own file so they can easily be
> > shared.
> >
> > Signed-off-by: Mark Langsdorf <mark.langsdorf(a)amd.com>
> > Signed-off-by: Borislav Petkov <borislav.petkov(a)amd.com>
> > ---
> > arch/x86/kernel/cpu/amd.c | 6 +++
> > arch/x86/kernel/cpu/cpufreq/Makefile | 4 +-
> > arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 44 +-----------------------
> > arch/x86/kernel/cpu/cpufreq/mperf.c | 50 ++++++++++++++++++++++++++++
> > arch/x86/kernel/cpu/cpufreq/mperf.h | 9 +++++
> > arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 8 ++++
> > 6 files changed, 77 insertions(+), 44 deletions(-)
> > create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.c
> > create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.h
> >
> > diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> > index e485825..796f662 100644
> > --- a/arch/x86/kernel/cpu/amd.c
> > +++ b/arch/x86/kernel/cpu/amd.c
> > @@ -537,6 +537,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
> > set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
> > }
> >
> > + if (c->cpuid_level >= 6) {
> > + unsigned ecx = cpuid_ecx(6);
> > + if (ecx & 0x01)
> > + set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> > + }
> > +
> Can you put this into:
> arch/x86/kernel/cpu/common.c (or wherever it fits in general x86 cpu init code)
> and remove this (arch/x86/kernel/cpu/intel.c):
> if (c->cpuid_level > 6) {
> unsigned ecx = cpuid_ecx(6);
> if (ecx & 0x01)
> set_cpu_cap(c, X86_FEATURE_APERFMPERF);
> }
>
> an x86 maintainer might want to double check, but I expect this should work
> for all x86 machines?

Yes, it should. However, there's the remote, far-fetched possibility
that other x86 vendors besides AMD and Intel, might have/plan to have
CPUID, base function 6, ECX[1] defined as a completely different feature
flag. And then it becomes ugly.

Besides, this is, strictly speaking, not x86 generic code but AMD- and
Intel-generic (huh, is there something like that? :)) code.

So, IMO, this is a judgement call based on the current settings of the
duplication and bloating levels of the x86 maintainers' filters :)

Let's have some more opinions, please...

Thanks.

--
Regards/Gruss,
Boris.

--
Advanced Micro Devices, Inc.
Operating Systems Research Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Valdis.Kletnieks on
On Thu, 25 Mar 2010 10:43:04 BST, Thomas Renninger said:

> > + if (c->cpuid_level >= 6) {

> and remove this (arch/x86/kernel/cpu/intel.c):
> if (c->cpuid_level > 6) {

So is > or >= the correct comparator here?