yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 1144c6fa17e7d3fca1e2940c8bd0da966c74e4c5 Mon Sep 17 00:00:00 2001
9ae3a8
From: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Date: Mon, 20 Jan 2014 19:05:30 +0100
9ae3a8
Subject: [PATCH 33/34] pc: Enable x2apic by default on more recent CPU models (v2)
9ae3a8
9ae3a8
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Message-id: <1390244730-31038-3-git-send-email-ehabkost@redhat.com>
9ae3a8
Patchwork-id: 56848
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 2/2] pc: Enable x2apic by default on more recent CPU models (v2)
9ae3a8
Bugzilla: 1049706
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Bandan Das <bsd@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1049706
9ae3a8
Brew scratch build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6900764
9ae3a8
Upstream status: not applicable (see notes below)
9ae3a8
9ae3a8
On RHEL-6 we already enabled x2apic by default on Conroe, Penryn,
9ae3a8
Nehalem, Westmere, SandyBridge, Haswell, Opteron_G{1,2,3}.
9ae3a8
9ae3a8
To not introduce performance regressions, this patch changes the rhel7
9ae3a8
machine-types to enable x2apic by default on all those models and also
9ae3a8
on Opteron_G{4,5}.
9ae3a8
9ae3a8
Quoting the patch I sent upstream[1]:
9ae3a8
9ae3a8
> Normally we try to keep the CPU model definitions as close as the real
9ae3a8
> CPUs as possible, but x2apic can be emulated by KVM without host CPU
9ae3a8
> support for x2apic, and it improves performance by reducing APIC access
9ae3a8
> overhead. x2apic emulation is available on KVM since 2009 (Linux
9ae3a8
> 2.6.32-rc1), there's no reason for not enabling x2apic by default when
9ae3a8
> running KVM.
9ae3a8
9ae3a8
Upstream status is "not applicable" because this patch touches only the
9ae3a8
rhel7-specific PC code. I am doing this because my plan is to enable
9ae3a8
x2apic by default even if upstream rejects my patch, and I want to get
9ae3a8
this done as soon as possible to get more testing exposure.
9ae3a8
9ae3a8
[1] A patch was submitted to change cpu.c to add x2apic to those CPU models
9ae3a8
    upstream, and can be seen at:
9ae3a8
    Message-Id: <1390228618-21663-1-git-send-email-ehabkost@redhat.com>
9ae3a8
    http://article.gmane.org/gmane.comp.emulators.qemu/251492
9ae3a8
9ae3a8
    The upstream patch is a resend. A similar patch was sent in
9ae3a8
    September 2013, was ACKed by Gleb, but was ignored by all
9ae3a8
    maintainers.
9ae3a8
9ae3a8
Changes v2:
9ae3a8
 * Use the new pc_compat_rhel*() functions
9ae3a8
 * Disable x2apic explicitly on Opteron_G{4,5} on pc_compat_rhel650()
9ae3a8
9ae3a8
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c | 12 ++++++++++++
9ae3a8
 hw/i386/pc_q35.c  | 10 ++++++++++
9ae3a8
 2 files changed, 22 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c |   12 ++++++++++++
9ae3a8
 hw/i386/pc_q35.c  |   10 ++++++++++
9ae3a8
 2 files changed, 22 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
9ae3a8
index 769571c..663c9d5 100644
9ae3a8
--- a/hw/i386/pc_piix.c
9ae3a8
+++ b/hw/i386/pc_piix.c
9ae3a8
@@ -745,6 +745,16 @@ machine_init(pc_machine_init);
9ae3a8
 
9ae3a8
 static void pc_compat_rhel700(QEMUMachineInitArgs *args)
9ae3a8
 {
9ae3a8
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    /* SandyBridge and Haswell already have x2apic enabled */
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
 }
9ae3a8
 
9ae3a8
 static void pc_init_rhel700(QEMUMachineInitArgs *args)
9ae3a8
@@ -899,6 +909,8 @@ static void pc_compat_rhel650(QEMUMachineInitArgs *args)
9ae3a8
     x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
     x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, 0, CPUID_EXT_X2APIC);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, 0, CPUID_EXT_X2APIC);
9ae3a8
 
9ae3a8
     x86_cpu_compat_set_features("phenom", FEAT_8000_0001_EDX,
9ae3a8
                                 0, CPUID_EXT2_RDTSCP);
9ae3a8
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
9ae3a8
index 0280a95..232c62d 100644
9ae3a8
--- a/hw/i386/pc_q35.c
9ae3a8
+++ b/hw/i386/pc_q35.c
9ae3a8
@@ -270,6 +270,16 @@ machine_init(pc_q35_machine_init);
9ae3a8
 
9ae3a8
 static void pc_q35_compat_rhel700(QEMUMachineInitArgs *args)
9ae3a8
 {
9ae3a8
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    /* SandyBridge and Haswell already have x2apic enabled */
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
9ae3a8
 }
9ae3a8
 
9ae3a8
 static void pc_q35_init_rhel700(QEMUMachineInitArgs *args)
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8