2008-03-25 06:22:22

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH] x86: pat cpu feature bit setting for known cpus

[PATCH] x86: pat cpu feature bit setting for known cpus

Signed-off-by: Yinghai Lu <[email protected]>

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index eb94460..b186047 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -309,6 +309,19 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)

}

+ clear_cpu_cap(c, X86_FEATURE_PAT);
+
+ switch (c->x86_vendor) {
+ case X86_VENDOR_AMD:
+ if (c->x86 >= 0xf && c->x86 <= 0x11)
+ set_cpu_cap(c, X86_FEATURE_PAT);
+ break;
+ case X86_VENDOR_INTEL:
+ if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
+ set_cpu_cap(c, X86_FEATURE_PAT);
+ break;
+ }
+
}

/*
@@ -397,6 +410,18 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
init_scattered_cpuid_features(c);
}

+ clear_cpu_cap(c, X86_FEATURE_PAT);
+
+ switch (c->x86_vendor) {
+ case X86_VENDOR_AMD:
+ if (c->x86 >= 0xf && c->x86 <= 0x11)
+ set_cpu_cap(c, X86_FEATURE_PAT);
+ break;
+ case X86_VENDOR_INTEL:
+ if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
+ set_cpu_cap(c, X86_FEATURE_PAT);
+ break;
+ }
}

static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 3f1dc97..ddaaaaa 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -979,12 +979,19 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
if (c->extended_cpuid_level >= 0x80000007)
c->x86_power = cpuid_edx(0x80000007);

+
+ clear_cpu_cap(c, X86_FEATURE_PAT);
+
switch (c->x86_vendor) {
case X86_VENDOR_AMD:
early_init_amd(c);
+ if (c->x86 >= 0xf && c->x86 <= 0x11)
+ set_cpu_cap(c, X86_FEATURE_PAT);
break;
case X86_VENDOR_INTEL:
early_init_intel(c);
+ if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
+ set_cpu_cap(c, X86_FEATURE_PAT);
break;
}

--- a/arch/x86/mm/pat.c 2008-03-24 23:10:32.000000000 -0700
+++ b/arch/x86/mm/pat.c 2008-03-24 23:11:38.000000000 -0700
@@ -42,19 +42,8 @@
if (!pat_wc_enabled)
return 0;

- if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
- (boot_cpu_data.x86 == 0xF ||
- (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model >= 15))) {
- if (cpu_has_pat) {
- return 1;
- }
- }
- if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
- boot_cpu_data.x86 >= 0xf && boot_cpu_data.x86 <= 0x11) {
- if (cpu_has_pat) {
- return 1;
- }
- }
+ if (cpu_has_pat)
+ return 1;

pat_wc_enabled = 0;
printk(KERN_INFO "CPU and/or kernel does not support PAT.\n");


2008-03-25 10:59:09

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus


* Yinghai Lu <[email protected]> wrote:

> [PATCH] x86: pat cpu feature bit setting for known cpus

thanks, applied - we need this to widen the testing scope of the PAT
changes.

Ingo

2008-03-25 13:39:21

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

Yinghai Lu wrote:
> [PATCH] x86: pat cpu feature bit setting for known cpus
>
> Signed-off-by: Yinghai Lu <[email protected]>

OK, note previous question: what is the motivation for having this as a
whitelist (as opposed to a blacklist)?

-hpa

2008-03-25 18:03:47

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Tue, Mar 25, 2008 at 6:38 AM, H. Peter Anvin <[email protected]> wrote:
> Yinghai Lu wrote:
> > [PATCH] x86: pat cpu feature bit setting for known cpus
> >
> > Signed-off-by: Yinghai Lu <[email protected]>
>
> OK, note previous question: what is the motivation for having this as a
> whitelist (as opposed to a blacklist)?

Venkatesh could tell?

YH

2008-03-25 19:17:47

by Pallipadi, Venkatesh

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Tue, Mar 25, 2008 at 11:03:37AM -0700, Yinghai Lu wrote:
> On Tue, Mar 25, 2008 at 6:38 AM, H. Peter Anvin <[email protected]> wrote:
> > Yinghai Lu wrote:
> > > [PATCH] x86: pat cpu feature bit setting for known cpus
> > >
> > > Signed-off-by: Yinghai Lu <[email protected]>
> >
> > OK, note previous question: what is the motivation for having this as a
> > whitelist (as opposed to a blacklist)?
>
> Venkatesh could tell?

Main reason for white-list at this point is not to be side-tracked by
real or potential erratas on older CPUs. Focussing on getting the support for
this feature on current and future CPUs. If older CPUs have survived all these
days without this feature, they should be doing OK.

Other reason being the amount of testing we get on those older systems. I mean,
any regression on some specific CPU is hard to find unless it is being tested
or someone audits all the errata documents to prepare the blacklist (Unless
we want to have big blacklist which is just !current_whitelist). We do not
have any self test that can detect and report any problematic CPUs that we
can add to the blacklist.

Having said that, if there is a need for this on older CPUs, I am OK with
having this as a blacklist.

Thanks,
Venki

2008-03-25 20:08:55

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus


* Venki Pallipadi <[email protected]> wrote:

> > > OK, note previous question: what is the motivation for having
> > > this as a whitelist (as opposed to a blacklist)?
> >
> > Venkatesh could tell?
>
> Main reason for white-list at this point is not to be side-tracked by
> real or potential erratas on older CPUs. Focussing on getting the
> support for this feature on current and future CPUs. If older CPUs
> have survived all these days without this feature, they should be
> doing OK.

well, the upside would be that since most testing of Linux kernels is
done on _old_ hardware (people tend to risk their old hw first ;-), we'd
get faster convergence of the codebase, even though we have the risk of
erratas (known and unknown ones alike). Code that artificially limits
its utility is almost always slow to stabilize.

Ingo

2008-03-25 20:38:52

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

Ingo Molnar wrote:
> * Venki Pallipadi <[email protected]> wrote:
>
>>>> OK, note previous question: what is the motivation for having
>>>> this as a whitelist (as opposed to a blacklist)?
>>> Venkatesh could tell?
>> Main reason for white-list at this point is not to be side-tracked by
>> real or potential erratas on older CPUs. Focussing on getting the
>> support for this feature on current and future CPUs. If older CPUs
>> have survived all these days without this feature, they should be
>> doing OK.
>
> well, the upside would be that since most testing of Linux kernels is
> done on _old_ hardware (people tend to risk their old hw first ;-), we'd
> get faster convergence of the codebase, even though we have the risk of
> erratas (known and unknown ones alike). Code that artificially limits
> its utility is almost always slow to stabilize.
>

Yes, using a whitelist of this type is wrong, IMO, and smells faintly of
vendor-lockin.

-hpa

2008-03-25 23:02:34

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

H. Peter Anvin wrote:
> Ingo Molnar wrote:
>> * Venki Pallipadi <[email protected]> wrote:
>>
>>>>> OK, note previous question: what is the motivation for having
>>>>> this as a whitelist (as opposed to a blacklist)?
>>>> Venkatesh could tell?
>>> Main reason for white-list at this point is not to be side-tracked by
>>> real or potential erratas on older CPUs. Focussing on getting the
>>> support for this feature on current and future CPUs. If older CPUs
>>> have survived all these days without this feature, they should be
>>> doing OK.
>>
>> well, the upside would be that since most testing of Linux kernels is
>> done on _old_ hardware (people tend to risk their old hw first ;-),
>> we'd get faster convergence of the codebase, even though we have the
>> risk of erratas (known and unknown ones alike). Code that artificially
>> limits its utility is almost always slow to stabilize.
>>
>
> Yes, using a whitelist of this type is wrong, IMO, and smells faintly of
> vendor-lockin.
>

By the way, I want to clarify: I didn't mean it was *intended* as
vendor-lockin, just that it's an undesirable effect of this.

-hpa

2008-03-25 23:05:37

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Tue, Mar 25, 2008 at 4:01 PM, H. Peter Anvin <[email protected]> wrote:
>
> H. Peter Anvin wrote:
> > Ingo Molnar wrote:
> >> * Venki Pallipadi <[email protected]> wrote:
> >>
> >>>>> OK, note previous question: what is the motivation for having
> >>>>> this as a whitelist (as opposed to a blacklist)?
> >>>> Venkatesh could tell?
> >>> Main reason for white-list at this point is not to be side-tracked by
> >>> real or potential erratas on older CPUs. Focussing on getting the
> >>> support for this feature on current and future CPUs. If older CPUs
> >>> have survived all these days without this feature, they should be
> >>> doing OK.
> >>
> >> well, the upside would be that since most testing of Linux kernels is
> >> done on _old_ hardware (people tend to risk their old hw first ;-),
> >> we'd get faster convergence of the codebase, even though we have the
> >> risk of erratas (known and unknown ones alike). Code that artificially
> >> limits its utility is almost always slow to stabilize.
> >>
> >
> > Yes, using a whitelist of this type is wrong, IMO, and smells faintly of
> > vendor-lockin.
> >
>
> By the way, I want to clarify: I didn't mean it was *intended* as
> vendor-lockin, just that it's an undesirable effect of this.

if the PAT works, we may need to trim the memory according to MTRR, right?

YH

2008-03-25 23:07:31

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

Yinghai Lu wrote:
>>
>> By the way, I want to clarify: I didn't mean it was *intended* as
>> vendor-lockin, just that it's an undesirable effect of this.
>
> if the PAT works, we may need to trim the memory according to MTRR, right?
>

That doesn't seem like it's specific to PAT?

-hpa

2008-03-25 23:08:59

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Tue, Mar 25, 2008 at 4:06 PM, H. Peter Anvin <[email protected]> wrote:
> Yinghai Lu wrote:
> >>
> >> By the way, I want to clarify: I didn't mean it was *intended* as
> >> vendor-lockin, just that it's an undesirable effect of this.
> >
> > if the PAT works, we may need to trim the memory according to MTRR, right?
> >
>
> That doesn't seem like it's specific to PAT?

could page table to set WRBACK the range that is not covered by MTRR in e820..

YH

2008-03-25 23:39:13

by Pallipadi, Venkatesh

[permalink] [raw]
Subject: RE: [PATCH] x86: pat cpu feature bit setting for known cpus



>-----Original Message-----
>From: Yinghai Lu [mailto:[email protected]]
>Sent: Tuesday, March 25, 2008 4:09 PM
>To: H. Peter Anvin
>Cc: Ingo Molnar; Pallipadi, Venkatesh; Thomas Gleixner; Andrew
>Morton; kernel list; Siddha, Suresh B
>Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus
>
>On Tue, Mar 25, 2008 at 4:06 PM, H. Peter Anvin <[email protected]> wrote:
>> Yinghai Lu wrote:
>> >>
>> >> By the way, I want to clarify: I didn't mean it was
>*intended* as
>> >> vendor-lockin, just that it's an undesirable effect of this.
>> >
>> > if the PAT works, we may need to trim the memory
>according to MTRR, right?
>> >
>>
>> That doesn't seem like it's specific to PAT?
>
>could page table to set WRBACK the range that is not covered
>by MTRR in e820..
>

Trimming of e820 memory is already done by Jesse's patch here
commit 99fc8d424bc5d80
Are you referring to similar thing?

Thanks,
Venki

2008-03-26 00:01:22

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Tue, Mar 25, 2008 at 4:38 PM, Pallipadi, Venkatesh
<[email protected]> wrote:
>
>
>
> >-----Original Message-----
> >From: Yinghai Lu [mailto:[email protected]]
> >Sent: Tuesday, March 25, 2008 4:09 PM
> >To: H. Peter Anvin
> >Cc: Ingo Molnar; Pallipadi, Venkatesh; Thomas Gleixner; Andrew
> >Morton; kernel list; Siddha, Suresh B
> >Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus
> >
> >On Tue, Mar 25, 2008 at 4:06 PM, H. Peter Anvin <[email protected]> wrote:
> >> Yinghai Lu wrote:
> >> >>
> >> >> By the way, I want to clarify: I didn't mean it was
> >*intended* as
> >> >> vendor-lockin, just that it's an undesirable effect of this.
> >> >
> >> > if the PAT works, we may need to trim the memory
> >according to MTRR, right?
> >> >
> >>
> >> That doesn't seem like it's specific to PAT?
> >
> >could page table to set WRBACK the range that is not covered
> >by MTRR in e820..
> >
>
> Trimming of e820 memory is already done by Jesse's patch here
> commit 99fc8d424bc5d80
> Are you referring to similar thing?
>
Yes.

YH

2008-03-26 00:12:08

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

Yinghai Lu wrote:
> On Tue, Mar 25, 2008 at 4:06 PM, H. Peter Anvin <[email protected]> wrote:
>> Yinghai Lu wrote:
>> >>
>> >> By the way, I want to clarify: I didn't mean it was *intended* as
>> >> vendor-lockin, just that it's an undesirable effect of this.
>> >
>> > if the PAT works, we may need to trim the memory according to MTRR, right?
>> >
>>
>> That doesn't seem like it's specific to PAT?
>
> could page table to set WRBACK the range that is not covered by MTRR in e820..
>

We have to trim anyway... lest we end up using uncached memory and then
we're in a world of hurt.

-hpa

2008-03-28 13:41:26

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus


On Mon 2008-03-24 23:24:34, Yinghai Lu wrote:
> [PATCH] x86: pat cpu feature bit setting for known cpus
>
> Signed-off-by: Yinghai Lu <[email protected]>
>
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index eb94460..b186047 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -309,6 +309,19 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
>
> }
>
> + clear_cpu_cap(c, X86_FEATURE_PAT);
> +
> + switch (c->x86_vendor) {
> + case X86_VENDOR_AMD:
> + if (c->x86 >= 0xf && c->x86 <= 0x11)
> + set_cpu_cap(c, X86_FEATURE_PAT);
> + break;
> + case X86_VENDOR_INTEL:
> + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> + set_cpu_cap(c, X86_FEATURE_PAT);
> + break;
> + }
> +
> }
>
> /*
> @@ -397,6 +410,18 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
> init_scattered_cpuid_features(c);
> }
>
> + clear_cpu_cap(c, X86_FEATURE_PAT);
> +
> + switch (c->x86_vendor) {
> + case X86_VENDOR_AMD:
> + if (c->x86 >= 0xf && c->x86 <= 0x11)
> + set_cpu_cap(c, X86_FEATURE_PAT);
> + break;
> + case X86_VENDOR_INTEL:
> + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> + set_cpu_cap(c, X86_FEATURE_PAT);
> + break;
> + }
> }
>

Cut&paste programming? Can you make it a function?

> diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
> index 3f1dc97..ddaaaaa 100644
> --- a/arch/x86/kernel/setup_64.c
> +++ b/arch/x86/kernel/setup_64.c
> @@ -979,12 +979,19 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
> if (c->extended_cpuid_level >= 0x80000007)
> c->x86_power = cpuid_edx(0x80000007);
>
> +
> + clear_cpu_cap(c, X86_FEATURE_PAT);



> switch (c->x86_vendor) {
> case X86_VENDOR_AMD:
> early_init_amd(c);
> + if (c->x86 >= 0xf && c->x86 <= 0x11)
> + set_cpu_cap(c, X86_FEATURE_PAT);
> break;
> case X86_VENDOR_INTEL:
> early_init_intel(c);
> + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> + set_cpu_cap(c, X86_FEATURE_PAT);
> break;
> }

one more copy...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2008-03-28 15:01:22

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Fri, Mar 28, 2008 at 6:41 AM, Pavel Machek <[email protected]> wrote:
>
>
> On Mon 2008-03-24 23:24:34, Yinghai Lu wrote:
> > [PATCH] x86: pat cpu feature bit setting for known cpus
> >
> > Signed-off-by: Yinghai Lu <[email protected]>
> >
> > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> > index eb94460..b186047 100644
> > --- a/arch/x86/kernel/cpu/common.c
> > +++ b/arch/x86/kernel/cpu/common.c
> > @@ -309,6 +309,19 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
> >
> > }
> >
> > + clear_cpu_cap(c, X86_FEATURE_PAT);
> > +
> > + switch (c->x86_vendor) {
> > + case X86_VENDOR_AMD:
> > + if (c->x86 >= 0xf && c->x86 <= 0x11)
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > + break;
> > + case X86_VENDOR_INTEL:
> > + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > + break;
> > + }
> > +
> > }
> >
> > /*
> > @@ -397,6 +410,18 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
> > init_scattered_cpuid_features(c);
> > }
> >
> > + clear_cpu_cap(c, X86_FEATURE_PAT);
> > +
> > + switch (c->x86_vendor) {
> > + case X86_VENDOR_AMD:
> > + if (c->x86 >= 0xf && c->x86 <= 0x11)
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > + break;
> > + case X86_VENDOR_INTEL:
> > + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > + break;
> > + }
> > }
> >
>
> Cut&paste programming? Can you make it a function?

yes. just want to leave one stub, so could add other cap setting if
needed later in early or late identify_cpu.

>
>
> > diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
> > index 3f1dc97..ddaaaaa 100644
> > --- a/arch/x86/kernel/setup_64.c
> > +++ b/arch/x86/kernel/setup_64.c
> > @@ -979,12 +979,19 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
> > if (c->extended_cpuid_level >= 0x80000007)
> > c->x86_power = cpuid_edx(0x80000007);
> >
> > +
> > + clear_cpu_cap(c, X86_FEATURE_PAT);
>
>
>
> > switch (c->x86_vendor) {
> > case X86_VENDOR_AMD:
> > early_init_amd(c);
> > + if (c->x86 >= 0xf && c->x86 <= 0x11)
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > break;
> > case X86_VENDOR_INTEL:
> > early_init_intel(c);
> > + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
> > + set_cpu_cap(c, X86_FEATURE_PAT);
> > break;
> > }
>
> one more copy...

for 64 bit.

YH

2008-03-30 11:43:35

by dean gaudet

[permalink] [raw]
Subject: Re: [PATCH] x86: pat cpu feature bit setting for known cpus

On Mon, 24 Mar 2008, Yinghai Lu wrote:

> [PATCH] x86: pat cpu feature bit setting for known cpus
>
> Signed-off-by: Yinghai Lu <[email protected]>
>
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index eb94460..b186047 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -309,6 +309,19 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
>
> }
>
> + clear_cpu_cap(c, X86_FEATURE_PAT);
> +
> + switch (c->x86_vendor) {
> + case X86_VENDOR_AMD:
> + if (c->x86 >= 0xf && c->x86 <= 0x11)
> + set_cpu_cap(c, X86_FEATURE_PAT);

just a general comment on things like this... "x->x86 <= 0x11" ensures
this file will have to be updated every time a new AMD CPU is released.


> + break;
> + case X86_VENDOR_INTEL:
> + if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))

note that you didn't limit intel the same way... at least for the numerous
core2 processor models.

-dean