Skip to contentSkip to conversation

x86/mwait-idle: Tweak reporting when MONITOR is not available

PATCH In review Andrew Cooper 2 participants 2 messages Sep 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mwait-idle: Tweak reporting when MONITOR is not available

Currently, booting Xen as a PVH guest yields:

(d10) (XEN) mwait-idle: does not run on family 6 model 60

which is inaccurate.

The problem is the lack of monitor, rather than the family/model. Combine the two CPUID checks and skip the list search in the case that is is going to fail for feature reasons.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/mwait-idle.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/cpu/mwait-idle.c +5 -5
index 77fc3dd..e3b5334 100644
@@ -1113,17 +1113,17 @@ static void __init mwait_idle_state_table_update(void)
 static int __init mwait_idle_probe(void)
 {
 	unsigned int eax, ebx, ecx;
-	const struct x86_cpu_id *id = x86_match_cpu(intel_idle_ids);
+	const struct x86_cpu_id *id;
 
-	if (!id) {
+	if (!cpu_has_monitor || boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
+		return -ENODEV;
+
+	if (!(id = x86_match_cpu(intel_idle_ids))) {
 		pr_debug(PREFIX "does not run on family %d model %d\n",
 			 boot_cpu_data.x86, boot_cpu_data.x86_model);
 		return -ENODEV;
 	}
 
-	if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
-		return -ENODEV;
-
 	cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
 
 	if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 27.09.18 at 13:12, <[email protected]> wrote:

Currently, booting Xen as a PVH guest yields:

(d10) (XEN) mwait-idle: does not run on family 6 model 60

Quoted 7 lines

which is inaccurate.

The problem is the lack of monitor, rather than the family/model. Combine the two CPUID checks and skip the list search in the case that is is going to fail for feature reasons.

For the specific case here and at this point in time, the change is acceptable, so feel free to use

However,

Quoted 8 lines
xen/arch/x86/cpu/mwait-idle.c +1 -1
@@ -1113,17 +1113,17 @@ static void __init mwait_idle_state_table_update(void)
 static int __init mwait_idle_probe(void)
 {
 	unsigned int eax, ebx, ecx;
-	const struct x86_cpu_id *id = x86_match_cpu(intel_idle_ids);
+	const struct x86_cpu_id *id;

xen/arch/x86/cpu/mwait-idle.c static void __init mwait_idle_state_table_update(void) · line 1125

Quoted 10 lines
xen/arch/x86/cpu/mwait-idle.c +4 -1
 
-	if (!id) {
+	if (!cpu_has_monitor || boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
+		return -ENODEV;
+
+	if (!(id = x86_match_cpu(intel_idle_ids))) {
 		pr_debug(PREFIX "does not run on family %d model %d\n",
 			 boot_cpu_data.x86, boot_cpu_data.x86_model);
 		return -ENODEV;
 	}

... the cpu_has_monitor check is (here) redundant with what intel_idle_ids[] says, and in the more general case (including possibly here, going forward) there might be entries in such a table with differing feature flag requests. Therefore I would prefer if the redundancy was not introduced (also to avoid others [blindly] cloning this code), and instead the log message be made less misleading in the PVH case. The moving ahead of the CPUID level check, otoh, is fine with me (but won't help your case at all afaict), since new (future) feature dependencies are rather unlikely to be towards lower levels.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel