qemu: enable PV EOI for qemu 1.3
PATCH 1/1 qemu: enable PV EOI for qemu 1.3
Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type.
--- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
hw/pc.h +2 -0
@@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);int e820_add_entry (uint64_t ,uint64_t ,uint32_t ); +void enable_kvm_pv_eoi (void ); +#endif
hw/pc_piix.c +13 -1
@@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); } +static void pc_init_pci_pv_eoi (ram_addr_t ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +enable_kvm_pv_eoi (); +pc_init_pci (ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,
@@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, };
target-i386/cpu.c +15 -0
@@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static bool kvm_pv_eoi_enabled; +static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;
@@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 <<KVM_FEATURE_ASYNC_PF ) | (1 <<KVM_FEATURE_STEAL_TIME ) | (1 <<KVM_FEATURE_CLOCKSOURCE_STABLE_BIT ); +if (kvm_pv_eoi_enabled) + plus_kvm_features |= (0x1 <<KVM_FEATURE_PV_EOI );#else plus_kvm_features =0 ;#endif
@@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) }type_init (x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header +* both files include to put this into. +* Put it here to silence compiler warning. +*/ +void enable_kvm_pv_eoi(void); + +void enable_kvm_pv_eoi (void ) +{ + kvm_pv_eoi_enabled = true; +}
Signature · 1 line
MST
Quoted 31 lines · Michael S. Tsirkin
Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type.
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)hw/pc.h +2
-0@@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);int e820_add_entry (uint64_t ,uint64_t ,uint32_t ); +void enable_kvm_pv_eoi (void ); +#endif hw/pc_piix.c +1
-0@@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); } +static void pc_init_pci_pv_eoi(ram_addr_t ram_size,
hw/pc_piix.c static void pc_init_pci(ram_addr_t ram_size, · line 314
Quoted 10 lines
hw/pc_piix.c +10
-0+const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ +enable_kvm_pv_eoi (); +pc_init_pci (ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +}
Maybe it's better to name it pc_init_pci_1_3() (or something like that)? I plan to submit a bug fix (unrelated to PV EOI) that will require using a separate init function for the pc-1.3 machine type too, so pv_eoi won't be the only difference between pc-1.2 and pc-1.3.
Quoted 18 lines
hw/pc_piix.c +2
-1+ static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,@@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, };target-i386/cpu.c +0
-0
target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1100
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static bool kvm_pv_eoi_enabled;
Maybe we can do this as:
static int default_kvm_features = (1 << KVM_FEATURE_CLOCKSOURCE) |
(1 << KVM_FEATURE_NOP_IO_DELAY) |
(1 << KVM_FEATURE_MMU_OP) |
(1 << KVM_FEATURE_CLOCKSOURCE2) |
(1 << KVM_FEATURE_ASYNC_PF) |
(1 << KVM_FEATURE_STEAL_TIME) |
(1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT);
[...]
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
{
[...]
plus_kvm_features = default_kvm_features;
[...]
}
[...]
void enable_kvm_pv_eoi(void)
{
default_kvm_features = (1UL << KVM_FEATURE_PV_EOI);
}On either case, the global variable should eventually go away when we make CPU objects support global properties. But I still support including a solution like this one, as the CPU modelling work is taking really long to be finished and I don't think this should hold the inclusion of pv_eoi support.
Quoted 14 lines
target-i386/cpu.c +3
-0+static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;@@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 <<KVM_FEATURE_ASYNC_PF ) | (1 <<KVM_FEATURE_STEAL_TIME ) | (1 <<KVM_FEATURE_CLOCKSOURCE_STABLE_BIT ); +if (kvm_pv_eoi_enabled) + plus_kvm_features |= (0x1 <<KVM_FEATURE_PV_EOI );#else plus_kvm_features =0 ;#endif
target-i386/cpu.c static void x86_cpu_register_types(void) · line 1964
Quoted 8 lines
target-i386/cpu.c +5
-0@@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) }type_init (x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header +* both files include to put this into. +* Put it here to silence compiler warning. +*/
Why can't pc_piix.c simply include cpu.h?
Quoted 8 lines
target-i386/cpu.c +6
-0+void enable_kvm_pv_eoi (void ); + +void enable_kvm_pv_eoi (void ) +{ + kvm_pv_eoi_enabled = true; +}Signature · 1 line
MST
Signature · 1 line
Eduardo
Quoted 31 lines · Eduardo Habkost
Quoted 30 lines · Michael S. Tsirkin
Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type.
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)hw/pc.h +2
-0@@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);int e820_add_entry (uint64_t ,uint64_t ,uint32_t ); +void enable_kvm_pv_eoi (void ); +#endif hw/pc_piix.c +0
-0@@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); }
Quoted 17 lines
hw/pc_piix.c static void pc_init_pci(ram_addr_t ram_size, · line 314
Quoted 11 lines
hw/pc_piix.c +11
-0+static void pc_init_pci_pv_eoi (ram_addr_t ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +enable_kvm_pv_eoi (); +pc_init_pci (ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +}Maybe it's better to name it
pc_init_pci_1_3()(or something like that)? I plan to submit a bug fix (unrelated to PV EOI) that will require using a separate init function for the pc-1.3 machine type too, sopv_eoiwon't be the only difference between pc-1.2 and pc-1.3.
1.4 will need to enable it too.
I'l rename pc_init_pci as pc_init_pci_1_2 instead.
Quoted 36 lines
Quoted 18 lines
hw/pc_piix.c +2
-1+ static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,@@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, };target-i386/cpu.c +0
-0target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1100
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static bool kvm_pv_eoi_enabled;Maybe we can do this as:
static int
default_kvm_features= (1 <<KVM_FEATURE_CLOCKSOURCE) |(1 << KVM_FEATURE_NOP_IO_DELAY) | (1 << KVM_FEATURE_MMU_OP) | (1 << KVM_FEATURE_CLOCKSOURCE2) | (1 << KVM_FEATURE_ASYNC_PF) | (1 << KVM_FEATURE_STEAL_TIME) | (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); [...] static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) { [...]
Quoted 8 lines
plus_kvm_features = default_kvm_features;
[...]
}
[...]
void enable_kvm_pv_eoi(void)
{
default_kvm_features = (1UL << KVM_FEATURE_PV_EOI);
}How is it better? Also disabling steal time etc for 1.3? Why?
Quoted 42 lines
On either case, the global variable should eventually go away when we make CPU objects support global properties. But I still support including a solution like this one, as the CPU modelling work is taking really long to be finished and I don't think this should hold the inclusion of
pv_eoisupport.Quoted 14 lines
target-i386/cpu.c +3
-0+static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;@@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 <<KVM_FEATURE_ASYNC_PF ) | (1 <<KVM_FEATURE_STEAL_TIME ) | (1 <<KVM_FEATURE_CLOCKSOURCE_STABLE_BIT ); +if (kvm_pv_eoi_enabled) + plus_kvm_features |= (0x1 <<KVM_FEATURE_PV_EOI );#else plus_kvm_features =0 ;#endif target-i386/cpu.c static void x86_cpu_register_types(void) · line 1964
Quoted 8 lines
target-i386/cpu.c +5
-0@@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) }type_init (x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header +* both files include to put this into. +* Put it here to silence compiler warning. +*/ Why can't
pc_piix.csimply includecpu.h?Quoted 8 lines
target-i386/cpu.c +6
-0+void enable_kvm_pv_eoi (void ); + +void enable_kvm_pv_eoi (void ) +{ + kvm_pv_eoi_enabled = true; +}Signature · 1 line
MSTSignature · 1 line
Eduardo
Quoted 50 lines · Michael S. Tsirkin
Quoted 31 lines · Eduardo Habkost
Quoted 30 lines · Michael S. Tsirkin
Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type.
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)hw/pc.h +2
-0@@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);int e820_add_entry (uint64_t ,uint64_t ,uint32_t ); +void enable_kvm_pv_eoi (void ); +#endif hw/pc_piix.c +0
-0@@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); }Quoted 17 lines
hw/pc_piix.c static void pc_init_pci(ram_addr_t ram_size, · line 314
Quoted 11 lines
hw/pc_piix.c +11
-0+static void pc_init_pci_pv_eoi (ram_addr_t ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +enable_kvm_pv_eoi (); +pc_init_pci (ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +}Maybe it's better to name it
pc_init_pci_1_3()(or something like that)? I plan to submit a bug fix (unrelated to PV EOI) that will require using a separate init function for the pc-1.3 machine type too, sopv_eoiwon't be the only difference between pc-1.2 and pc-1.3.
Quoted 2 lines
1.4 will need to enable it too.
I'l renamepc_init_pciaspc_init_pci_1_2instead.
Yes, that would work, too.
Quoted 46 lines
Quoted 37 lines
Quoted 19 lines
hw/pc_piix.c +2
-1+ static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,@@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, };target-i386/cpu.c +0
-0target-i386/cpu.c static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, · line 1100
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static bool kvm_pv_eoi_enabled;Maybe we can do this as:
static int
default_kvm_features= (1 <<KVM_FEATURE_CLOCKSOURCE) |(1 << KVM_FEATURE_NOP_IO_DELAY) | (1 << KVM_FEATURE_MMU_OP) | (1 << KVM_FEATURE_CLOCKSOURCE2) | (1 << KVM_FEATURE_ASYNC_PF) | (1 << KVM_FEATURE_STEAL_TIME) | (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); [...] static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) { [...]Quoted 8 lines
plus_kvm_features = default_kvm_features; [...] } [...] void enable_kvm_pv_eoi(void) { default_kvm_features = (1UL << KVM_FEATURE_PV_EOI); }
Quoted 1 line
How is it better? Also disabling steal time etc for 1.3? Why?
Typo. That was supposed to be "|=", not "=".
It would make the code simpler (eliminating a conditional statement), it allows other flags to be changed using the same variable if needed, and makes it clear that it is simply changing the default KVM flags, not unconditionally enabling/disabling pv_eoi (as "-cpu ...,+pv_eoi" and "-cpu ...,-pv_eoi" would still work).
Quoted 43 lines
Quoted 43 lines
On either case, the global variable should eventually go away when we make CPU objects support global properties. But I still support including a solution like this one, as the CPU modelling work is taking really long to be finished and I don't think this should hold the inclusion of
pv_eoisupport.Quoted 14 lines
target-i386/cpu.c +3
-0+static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;@@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 <<KVM_FEATURE_ASYNC_PF ) | (1 <<KVM_FEATURE_STEAL_TIME ) | (1 <<KVM_FEATURE_CLOCKSOURCE_STABLE_BIT ); +if (kvm_pv_eoi_enabled) + plus_kvm_features |= (0x1 <<KVM_FEATURE_PV_EOI );#else plus_kvm_features =0 ;#endif target-i386/cpu.c static void x86_cpu_register_types(void) · line 1964
Quoted 8 lines
target-i386/cpu.c +5
-0@@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) }type_init (x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header +* both files include to put this into. +* Put it here to silence compiler warning. +*/ Why can't
pc_piix.csimply includecpu.h?Quoted 8 lines
target-i386/cpu.c +6
-0+void enable_kvm_pv_eoi (void ); + +void enable_kvm_pv_eoi (void ) +{ + kvm_pv_eoi_enabled = true; +}Signature · 1 line
MSTSignature · 1 line
Eduardo
Signature · 1 line
Eduardo
Quoted 68 lines · Michael S. Tsirkin
Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type.
Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)hw/pc.h +2
-0@@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);int e820_add_entry (uint64_t ,uint64_t ,uint32_t ); +void enable_kvm_pv_eoi (void ); +#endif hw/pc_piix.c +13
-1@@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); } +static void pc_init_pci_pv_eoi (ram_addr_t ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +enable_kvm_pv_eoi (); +pc_init_pci (ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,@@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, };target-i386/cpu.c +2
-0@@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value /1000 ; } +static bool kvm_pv_eoi_enabled; +static int cpu_x86_find_by_name (x86_def_t *x86_cpu_def,const char *cpu_model) {unsigned int i;
target-i386/cpu.c static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) · line 1140
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 <<KVM_FEATURE_ASYNC_PF ) | (1 <<KVM_FEATURE_STEAL_TIME ) | (1 <<KVM_FEATURE_CLOCKSOURCE_STABLE_BIT ); +if (kvm_pv_eoi_enabled)
Missing braces, please read CODING_STYLE. ;-)
target-i386/cpu.c static void x86_cpu_register_types(void) · line 1963
Quoted 12 lines
target-i386/cpu.c +5
-0+ plus_kvm_features |= (0x1 <<KVM_FEATURE_PV_EOI );#else plus_kvm_features =0 ;#endif @@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) }type_init (x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header +* both files include to put this into. +* Put it here to silence compiler warning.
No, both cpu.c and pc_piix.c include kvm.h.
Quoted 10 lines
target-i386/cpu.c +7
-1+*/ +void enable_kvm_pv_eoi (void ); + +void enable_kvm_pv_eoi (void ) +{ + kvm_pv_eoi_enabled = true; +} --MST