diff mbox series

tools/power turbostat: Get APIC ID for all processors

Message ID 20180808130306.32483-1-prarit@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Len Brown
Headers show
Series tools/power turbostat: Get APIC ID for all processors | expand

Commit Message

Prarit Bhargava Aug. 8, 2018, 1:03 p.m. UTC
FWIW the kernel does the same thing on arch/x86/kernel/cpu/common.c:1194.

P.

---8<---

turbostat shows apicid = 0 for all non-Intel processors.

The APIC ID code can be run on all processors and must read bits 20-27.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
---
 tools/power/x86/turbostat/turbostat.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Len Brown Aug. 8, 2018, 8:10 p.m. UTC | #1
-       t->apic_id = (ebx >> 24) & 0xf;
+       t->apic_id = (ebx >> 24) & 0xff;

Thanks for pointing out this bug in the existing code, something I
moved, but did not fix in my patch yesterday.
Both Intel and AMD use 8-bits 31-24 for legacy APIC-ID, not 4-bits
27-24.  Didn't notice, since I only really look at XAPIC-id these
days...


On Wed, Aug 8, 2018 at 9:03 AM Prarit Bhargava <prarit@redhat.com> wrote:
>
> FWIW the kernel does the same thing on arch/x86/kernel/cpu/common.c:1194.
>
> P.
>
> ---8<---
>
> turbostat shows apicid = 0 for all non-Intel processors.
>
> The APIC ID code can be run on all processors and must read bits 20-27.
>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> ---
>  tools/power/x86/turbostat/turbostat.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> index 980bd9d20646..2dc212b88651 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -1671,13 +1671,10 @@ void get_apic_id(struct thread_data *t)
>
>         eax = ebx = ecx = edx = 0;
>
> -       if (!genuine_intel)
> -               return;
> -
>         __cpuid(0, max_level, ebx, ecx, edx);
>
>         __cpuid(1, eax, ebx, ecx, edx);
> -       t->apic_id = (ebx >> 24) & 0xf;
> +       t->apic_id = (ebx >> 24) & 0xff;
>
>         if (max_level < 0xb)
>                 return;
> --
> 2.14.4
>
Prarit Bhargava Aug. 9, 2018, 12:09 p.m. UTC | #2
On 08/08/2018 04:10 PM, Len Brown wrote:
> -       t->apic_id = (ebx >> 24) & 0xf;
> +       t->apic_id = (ebx >> 24) & 0xff;
> 
> Thanks for pointing out this bug in the existing code, something I
> moved, but did not fix in my patch yesterday.
> Both Intel and AMD use 8-bits 31-24 for legacy APIC-ID, not 4-bits
> 27-24.  Didn't notice, since I only really look at XAPIC-id these
> days...

Oh my math is wrong.  Duh.  I'll resend this as a v2.

P.

> 
> 
> On Wed, Aug 8, 2018 at 9:03 AM Prarit Bhargava <prarit@redhat.com> wrote:
>>
>> FWIW the kernel does the same thing on arch/x86/kernel/cpu/common.c:1194.
>>
>> P.
>>
>> ---8<---
>>
>> turbostat shows apicid = 0 for all non-Intel processors.
>>
>> The APIC ID code can be run on all processors and must read bits 20-27.
>>
>> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
>> ---
>>  tools/power/x86/turbostat/turbostat.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
>> index 980bd9d20646..2dc212b88651 100644
>> --- a/tools/power/x86/turbostat/turbostat.c
>> +++ b/tools/power/x86/turbostat/turbostat.c
>> @@ -1671,13 +1671,10 @@ void get_apic_id(struct thread_data *t)
>>
>>         eax = ebx = ecx = edx = 0;
>>
>> -       if (!genuine_intel)
>> -               return;
>> -
>>         __cpuid(0, max_level, ebx, ecx, edx);
>>
>>         __cpuid(1, eax, ebx, ecx, edx);
>> -       t->apic_id = (ebx >> 24) & 0xf;
>> +       t->apic_id = (ebx >> 24) & 0xff;
>>
>>         if (max_level < 0xb)
>>                 return;
>> --
>> 2.14.4
>>
> 
>
diff mbox series

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 980bd9d20646..2dc212b88651 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1671,13 +1671,10 @@  void get_apic_id(struct thread_data *t)
 
 	eax = ebx = ecx = edx = 0;
 
-	if (!genuine_intel)
-		return;
-
 	__cpuid(0, max_level, ebx, ecx, edx);
 
 	__cpuid(1, eax, ebx, ecx, edx);
-	t->apic_id = (ebx >> 24) & 0xf;
+	t->apic_id = (ebx >> 24) & 0xff;
 
 	if (max_level < 0xb)
 		return;