Skip to contentSkip to conversation

x86/ACPI/cstate: Output AMD on APCI C1 FFH MWAIT AMD systems

PATCH In review Prarit Bhargava 3 participants 6 messages Aug 8, 2018 – Aug 9, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ACPI/cstate: Output AMD on APCI C1 FFH MWAIT AMD systems

commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD systems") allows use of FFH for ACPI C1 but tools like cpupower and turbostat display INTEL for the cstate description.

Output "AMD" for AMD systems with FFH for ACPI C1.

Cc Len Brown <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/acpi/cstate.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arch/x86/kernel/acpi/cstate.c +9 -3
index dde437f5d14f..f10d3c673519 100644
@@ -76,6 +76,7 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
 	unsigned int edx_part;
 	unsigned int cstate_type; /* C-state type and not ACPI C-state type */
 	unsigned int num_cstate_subtype;
+	struct cpuinfo_x86 *c = &boot_cpu_data;
 
 	cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
 
@@ -107,9 +108,14 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
 			"Monitor-Mwait will be used to enter C-%d state\n",
 			cx->type);
 	}
-	snprintf(cx->desc,
-			ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
-			cx->address);
+	if (c->x86_vendor == X86_VENDOR_INTEL)
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
+			 cx->address);
+	else
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH AMD MWAIT 0x%x",
+			 cx->address);
 out:
 	return retval;
 }
Signature · 1 line
2.14.4
#1 lore raw
Quoted 5 lines · Prarit Bhargava

commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD systems") allows use of FFH for ACPI C1 but tools like cpupower and turbostat display INTEL for the cstate description.

Output "AMD" for AMD systems with FFH for ACPI C1.

Um, is it good idea?

First, you are changing kernel API.

Quoted 5 lines
arch/x86/kernel/acpi/cstate.c +0 -1
@@ -107,9 +108,14 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
 			"Monitor-Mwait will be used to enter C-%d state\n",
 			cx->type);
 	}
-	snprintf(cx->desc,

arch/x86/kernel/acpi/cstate.c static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) · line 118

Quoted 10 lines
arch/x86/kernel/acpi/cstate.c +8 -2
-			ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
-			cx->address);
+	if (c->x86_vendor == X86_VENDOR_INTEL)
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
+			 cx->address);
+	else
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH AMD MWAIT 0x%x",
+			 cx->address);

Second, I read it as "Intel MWAIT" instruction is used. Yes, AMD cpu can use Intel MWAIT, too...

Third, there are more CPU vendors out there.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
reviewer
#2 lore raw

I think it is sufficient to simply delete the "INTEL" in that string.

In the unlikely event that this "change to a kernel API" breaks something, we can add it back.

-Len

Quoted 37 lines · Pavel Machek
Quoted 5 lines · Prarit Bhargava

commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD systems") allows use of FFH for ACPI C1 but tools like cpupower and turbostat display INTEL for the cstate description.

Output "AMD" for AMD systems with FFH for ACPI C1.

Um, is it good idea?

First, you are changing kernel API.

Quoted 5 lines
arch/x86/kernel/acpi/cstate.c +0 -1
@@ -107,9 +108,14 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
                      "Monitor-Mwait will be used to enter C-%d state\n",
                      cx->type);
      }
-     snprintf(cx->desc,

arch/x86/kernel/acpi/cstate.c static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) · line 118

Quoted 10 lines
arch/x86/kernel/acpi/cstate.c +8 -2
-                     ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
-                     cx->address);
+     if (c->x86_vendor == X86_VENDOR_INTEL)
+             snprintf(cx->desc,
+                      ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
+                      cx->address);
+     else
+             snprintf(cx->desc,
+                      ACPI_CX_DESC_LEN, "ACPI FFH AMD MWAIT 0x%x",
+                      cx->address);

Second, I read it as "Intel MWAIT" instruction is used. Yes, AMD cpu can use Intel MWAIT, too...

Third, there are more CPU vendors out there.

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

Signature · 1 line
Len Brown, Intel Open Source Technology Center
#3 lore raw
Quoted 4 lines · Len Brown

I think it is sufficient to simply delete the "INTEL" in that string.

In the unlikely event that this "change to a kernel API" breaks something, we can add it back.

I'd just leave it alone. But yes, just deleting INTEL is better than patch below.
Pavel

Quoted 39 lines
Quoted 36 lines · Prarit Bhargava
Quoted 5 lines

commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD systems") allows use of FFH for ACPI C1 but tools like cpupower and turbostat display INTEL for the cstate description.

Output "AMD" for AMD systems with FFH for ACPI C1.

Um, is it good idea?

First, you are changing kernel API.

Quoted 5 lines
arch/x86/kernel/acpi/cstate.c +0 -1
@@ -107,9 +108,14 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
                      "Monitor-Mwait will be used to enter C-%d state\n",
                      cx->type);
      }
-     snprintf(cx->desc,

arch/x86/kernel/acpi/cstate.c static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) · line 118

Quoted 10 lines
arch/x86/kernel/acpi/cstate.c +8 -2
-                     ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
-                     cx->address);
+     if (c->x86_vendor == X86_VENDOR_INTEL)
+             snprintf(cx->desc,
+                      ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
+                      cx->address);
+     else
+             snprintf(cx->desc,
+                      ACPI_CX_DESC_LEN, "ACPI FFH AMD MWAIT 0x%x",
+                      cx->address);

Second, I read it as "Intel MWAIT" instruction is used. Yes, AMD cpu can use Intel MWAIT, too...

Third, there are more CPU vendors out there.

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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek
Quoted 5 lines · Prarit Bhargava

commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD systems") allows use of FFH for ACPI C1 but tools like cpupower and turbostat display INTEL for the cstate description.

Output "AMD" for AMD systems with FFH for ACPI C1.

Um, is it good idea?

Quoted 1 line

First, you are changing kernel API.

I thought about that and the AMD support was only added a year ago so I think it is okay to change. Secondly, I did a grep for the use of the desc file in the Fedora sources and only found a few places where the file is referenced. They all *report* the data but do not use it to make a decision.

For example, turbostat and cpupower only return the data to the console.

Quoted 11 lines
Quoted 11 lines
arch/x86/kernel/acpi/cstate.c +3 -3
@@ -107,9 +108,14 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
 			"Monitor-Mwait will be used to enter C-%d state\n",
 			cx->type);
 	}
-	snprintf(cx->desc,
-			ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
-			cx->address);
+	if (c->x86_vendor == X86_VENDOR_INTEL)
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
Quoted 8 lines

arch/x86/kernel/acpi/cstate.c static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) · line 118

Quoted 5 lines
arch/x86/kernel/acpi/cstate.c +5 -0
+			 cx->address);
+	else
+		snprintf(cx->desc,
+			 ACPI_CX_DESC_LEN, "ACPI FFH AMD MWAIT 0x%x",
+			 cx->address);

Second, I read it as "Intel MWAIT" instruction is used. Yes, AMD cpu can use Intel MWAIT, too...

That's true but the weirdness of seeing INTEL on an AMD box there made me push this patch.

Quoted 2 lines

Third, there are more CPU vendors out there.

Not in this code. It is AMD & Intel only. I thought about dropping INTEL, and also switching to X86.

Should we drop INTEL from the above or not (as suggested later in this thread)? It feels like everyone is on the fence about it.

P.

Quoted 3 lines

Pavel

reviewer
#5 lore raw
Quoted 4 lines
Quoted 1 line

"ACPI FFH INTEL MWAIT 0x%x"

Should we drop INTEL from the above or not (as suggested later in this thread)? It feels like everyone is on the fence about it.

Okay with me to drop the "INTEL" part of this string -- it actually doesn't add any information.

thanks,
-Len