Message ID | 20180727115053.8965-1-calvin.walton@kepstin.ca (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Len Brown |
Headers | show |
Series | [v3] turbostat: Read extended processor family from CPUID | expand |
Applied -- thanks! On Fri, Jul 27, 2018 at 7:50 AM Calvin Walton <calvin.walton@kepstin.ca> wrote: > > This fixes the reported family on modern AMD processors (e.g. Ryzen, > which is family 0x17). Previously these processors all showed up as > family 0xf. > > See the document > https://support.amd.com/TechDocs/56255_OSRR.pdf > section CPUID_Fn00000001_EAX for how to calculate the family > from the BaseFamily and ExtFamily values. > > This matches the code in arch/x86/lib/cpu.c > > Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca> > --- > > v3: Having just looked at the arch/x86/lib/cpu.c code again, I realized > that it *didn't* actually match - the kernel code uses family >= 6 for > applying the extended model number, while I was applying it only to > family == 6 or family >= 0xf. Change that to match for consistency. > > v2: I'm still working on updating the RAPL patch on top of the changes for > v4.18, but this CPUID fix doesn't have to wait. > > tools/power/x86/turbostat/turbostat.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c > index bd9c6b31a504..ed024deed36f 100644 > --- a/tools/power/x86/turbostat/turbostat.c > +++ b/tools/power/x86/turbostat/turbostat.c > @@ -4031,7 +4031,9 @@ void process_cpuid() > family = (fms >> 8) & 0xf; > model = (fms >> 4) & 0xf; > stepping = fms & 0xf; > - if (family == 6 || family == 0xf) > + if (family == 0xf) > + family += (fms >> 20) & 0xff; > + if (family >= 6) > model += ((fms >> 16) & 0xf) << 4; > > if (!quiet) { > -- > 2.18.0 >
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index bd9c6b31a504..ed024deed36f 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -4031,7 +4031,9 @@ void process_cpuid() family = (fms >> 8) & 0xf; model = (fms >> 4) & 0xf; stepping = fms & 0xf; - if (family == 6 || family == 0xf) + if (family == 0xf) + family += (fms >> 20) & 0xff; + if (family >= 6) model += ((fms >> 16) & 0xf) << 4; if (!quiet) {
This fixes the reported family on modern AMD processors (e.g. Ryzen, which is family 0x17). Previously these processors all showed up as family 0xf. See the document https://support.amd.com/TechDocs/56255_OSRR.pdf section CPUID_Fn00000001_EAX for how to calculate the family from the BaseFamily and ExtFamily values. This matches the code in arch/x86/lib/cpu.c Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca> --- v3: Having just looked at the arch/x86/lib/cpu.c code again, I realized that it *didn't* actually match - the kernel code uses family >= 6 for applying the extended model number, while I was applying it only to family == 6 or family >= 0xf. Change that to match for consistency. v2: I'm still working on updating the RAPL patch on top of the changes for v4.18, but this CPUID fix doesn't have to wait. tools/power/x86/turbostat/turbostat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)