i386/kvm: add support for KVM_CAP_X86_DISABLE_EXITS
PATCH RESEND v2 1/1 i386/kvm: add support for KVM_CAP_X86_DISABLE_EXITS
From: Wanpeng Li <[email protected]>
This patch adds support for KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VM capability(KVM_CAP_X86_DISABLE_EXITS) to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.
---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)
linux-headers/linux/kvm.h +5 -1
@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146
@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */
target/i386/cpu.h +2 -0
@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +#define KVM_HINTS_DEDICATED (1U << 0)#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */
target/i386/kvm.c +16 -0
@@ -1029,6 +1029,22 @@ int kvm_arch_init_vcpu(CPUState *cs) } } +if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + } + } +if (kvm_vm_enable_cap (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ,0 , disable_exits)) { +error_report ("kvm: DISABLE EXITS not supported" ); + } + } +qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 );
Signature · 1 line
2.7.4
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH RESEND v2] i386/kvm: add support for KVM_CAP_X86_DISABLE_EXITS
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'61dd49b0a1 i386/kvm: add support for KVM_CAP_X86_DISABLE_EXITS
=== OUTPUT BEGIN ===
Checking PATCH 1/1: i386/kvm: add support for KVM_CAP_X86_DISABLE_EXITS...
WARNING: line over 80 characters
#65: FILE: target/i386/kvm.c:1033:
+ int disable_exits = kvm_check_extension(cs->kvm_state, KVM_CAP_X86_DISABLE_EXITS);
ERROR: line over 90 characters
#75: FILE: target/i386/kvm.c:1043:
+ if (kvm_vm_enable_cap(cs->kvm_state, KVM_CAP_X86_DISABLE_EXITS, 0, disable_exits)) {
total: 1 errors, 1 warnings, 48 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Quoted 46 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
This patch adds support for
KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VMcapability(KVM_CAP_X86_DISABLE_EXITS)to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.Cc Paolo Bonzini <[email protected]>Cc Radim Krčmář <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)linux-headers/linux/kvm.h +5
-1@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */ target/i386/cpu.h +0
-0
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 689
Quoted 5 lines
target/i386/cpu.h +2
-0@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +
Why don't we use KVM_FEATURE_PV_UNHALT from kvm_para.h?
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 691
Quoted 2 lines
target/i386/cpu.h +0
-0#define KVM_HINTS_DEDICATED (1U << 0)
BTW I wonder whether we should switch to a value from kvm_para.h? I'll send a version to do it, pls take a look.
Quoted 30 lines
target/i386/cpu.h +0
-0#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ target/i386/kvm.c +16
-0@@ -1029,6 +1029,22 @@ int kvm_arch_init_vcpu(CPUState *cs) } } +if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + } + } +if (kvm_vm_enable_cap (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ,0 , disable_exits)) { +error_report ("kvm: DISABLE EXITS not supported" ); + } + } +qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 );Signature · 1 line
2.7.4
2018-04-18 2:08 GMT+08:00 Michael S. Tsirkin <[email protected]>:
Quoted 55 lines · Wanpeng Li
Quoted 46 lines
From: Wanpeng Li <[email protected]>
This patch adds support for
KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VMcapability(KVM_CAP_X86_DISABLE_EXITS)to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.Cc Paolo Bonzini <[email protected]>Cc Radim Krčmář <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)linux-headers/linux/kvm.h +5
-1@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */ target/i386/cpu.h +0
-0target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 689
Quoted 5 lines
target/i386/cpu.h +2
-0@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +Why don't we use
KVM_FEATURE_PV_UNHALTfromkvm_para.h?
Quoted 5 lines
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 691
Quoted 2 lines
target/i386/cpu.h +0
-0#define KVM_HINTS_DEDICATED (1U << 0)BTW I wonder whether we should switch to a value from
kvm_para.h? I'll send a version to do it, pls take a look.
Yeah, your patchset looks good.
Regards,
Wanpeng Li
Quoted 32 lines
Quoted 32 lines
target/i386/cpu.h +0
-0#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ target/i386/kvm.c +16
-1@@ -1029,6 +1029,22 @@ int kvm_arch_init_vcpu(CPUState *cs) } } +if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + } + } +if (kvm_vm_enable_cap (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ,0 , disable_exits)) { +error_report ("kvm: DISABLE EXITS not supported" ); + } + } +qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 ); --2.7.4
Quoted 59 lines · Wanpeng Li
2018-04-18 2:08 GMT+08:00 Michael S. Tsirkin <[email protected]>:
Quoted 58 lines · Wanpeng Li
Quoted 46 lines
From: Wanpeng Li <[email protected]>
This patch adds support for
KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VMcapability(KVM_CAP_X86_DISABLE_EXITS)to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.Cc Paolo Bonzini <[email protected]>Cc Radim Krčmář <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)linux-headers/linux/kvm.h +5
-1@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */ target/i386/cpu.h +0
-0target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 689
Quoted 5 lines
target/i386/cpu.h +2
-0@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +Why don't we use
KVM_FEATURE_PV_UNHALTfromkvm_para.h?Quoted 2 lines
target/i386/cpu.h +0
-0#define KVM_HINTS_DEDICATED (1U << 0)
Quoted 7 lines
Quoted 2 lines
BTW I wonder whether we should switch to a value from
kvm_para.h? I'll send a version to do it, pls take a look.Yeah, your patchset looks good.
Regards,
Wanpeng Li
Do you plan to rebase your patch and upstream it or do you expect me to do it?
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
target/i386/cpu.h +0
-0#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ target/i386/kvm.c +16
-1@@ -1029,6 +1029,22 @@ int kvm_arch_init_vcpu(CPUState *cs) } } +if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + } + } +if (kvm_vm_enable_cap (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ,0 , disable_exits)) { +error_report ("kvm: DISABLE EXITS not supported" ); + } + } +qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 ); --2.7.4
2018-05-12 5:57 GMT+08:00 Michael S. Tsirkin <[email protected]>:
Quoted 63 lines · Wanpeng Li
Quoted 62 lines
2018-04-18 2:08 GMT+08:00 Michael S. Tsirkin <[email protected]>:
Quoted 60 lines · Wanpeng Li
Quoted 46 lines
From: Wanpeng Li <[email protected]>
This patch adds support for
KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VMcapability(KVM_CAP_X86_DISABLE_EXITS)to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.Cc Paolo Bonzini <[email protected]>Cc Radim Krčmář <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)linux-headers/linux/kvm.h +5
-1@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */ target/i386/cpu.h +0
-0target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 689
Quoted 5 lines
target/i386/cpu.h +2
-0@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +Why don't we use
KVM_FEATURE_PV_UNHALTfromkvm_para.h?target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 691
Quoted 2 lines
target/i386/cpu.h +0
-0#define KVM_HINTS_DEDICATED (1U << 0)BTW I wonder whether we should switch to a value from
kvm_para.h? I'll send a version to do it, pls take a look.
Quoted 7 lines
Quoted 4 lines
Yeah, your patchset looks good.
Regards,
Wanpeng LiDo you plan to rebase your patch and upstream it or do you expect me to do it?
You can pick it since I am too busy recently. Thanks Michael!
Regards,
Wanpeng Li
Quoted 62 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
This patch adds support for
KVM_CAP_X86_DISABLE_EXITS. Provides userspace with per-VMcapability(KVM_CAP_X86_DISABLE_EXITS)to not intercept MWAIT/HLT/PAUSE in order that to improve latency in some workloads.Cc Paolo Bonzini <[email protected]>Cc Radim Krčmář <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
linux-headers/linux/kvm.h | 6 +++++- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-)linux-headers/linux/kvm.h +5
-1@@ -925,7 +925,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_GS 140#define KVM_CAP_S390_AIS 141#define KVM_CAP_SPAPR_TCE_VFIO 142 -#define KVM_CAP_X86_GUEST_MWAIT 143 +#define KVM_CAP_X86_DISABLE_EXITS 143#define KVM_CAP_ARM_USER_IRQ 144#define KVM_CAP_S390_CMMA_MIGRATION 145#define KVM_CAP_PPC_FWNMI 146@@ -1508,6 +1508,10 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) +#define KVM_X86_DISABLE_EXITS_HLT (1 << 1) +#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) +/* Available with KVM_CAP_ARM_USER_IRQ */ /* Bits for run->s.regs.device_irq_level */ target/i386/cpu.h +2
-0@@ -685,6 +685,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define KVM_PV_UNHALT (1U << 7) +#define KVM_HINTS_DEDICATED (1U << 0)#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ target/i386/kvm.c +0
-0@@ -1029,6 +1029,22 @@ int kvm_arch_init_vcpu(CPUState *cs) } }
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 10 lines
target/i386/kvm.c +10
-0+if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx, x86_cpu_list(), or somewhere else).
Quoted 12 lines
target/i386/kvm.c +6
-0+ } +if (kvm_vm_enable_cap (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ,0 , disable_exits)) { +error_report ("kvm: DISABLE EXITS not supported" ); + } + } +qemu_add_vm_change_state_handler (cpu_update_state, env); c =cpuid_find_entry (&cpuid_data.cpuid,1 ,0 );Signature · 1 line
2.7.4
Signature · 1 line
Eduardo
2018-04-18 4:59 GMT+08:00 Eduardo Habkost <[email protected]>:
Quoted 1 line · Wanpeng Li
[.../...]
Quoted 17 lines
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 11 lines
target/i386/kvm.c +10
-0+if (env->features[FEAT_KVM_HINTS ] &KVM_HINTS_DEDICATED ) { +int disable_exits =kvm_check_extension (cs->kvm_state,KVM_CAP_X86_DISABLE_EXITS ); + +if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).
What's your opinion, Paolo?
Regards,
Wanpeng Li
Paolo Bonzini
maintainerQuoted 8 lines · Eduardo Habkost
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 7 lines
target/i386/kvm.c +7
-0+if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }
Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in Documentation/virtual/kvm/cpuid.txt.
Paolo
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 7 lines
target/i386/kvm.c +7
-0+if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).
Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.
With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Signature · 1 line
Eduardo
Paolo Bonzini
maintainerQuoted 32 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 7 lines
target/i386/kvm.c +7
-0+if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
Quoted 4 lines
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Thanks,
Paolo
Quoted 33 lines · Paolo Bonzini
Quoted 32 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 7 lines
target/i386/kvm.c +7
-0+if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
Quoted 7 lines
Quoted 4 lines
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Signature · 1 line
Eduardo
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
target/i386/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 1041
Quoted 7 lines
target/i386/kvm.c +7
-0+if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | +KVM_X86_DISABLE_EXITS_HLT | +KVM_X86_DISABLE_EXITS_PAUSE ); +if (env->user_features[FEAT_KVM ] &KVM_PV_UNHALT ) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT ; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
Quoted 1 line
From pure API point of view, hint-dedicated looks good since
it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?
So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Quoted 2 lines
Signature · 1 line
Eduardo
Quoted 54 lines · Michael S. Tsirkin
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + if (env->user_features[FEAT_KVM] & KVM_PV_UNHALT) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
Quoted 7 lines
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Using a boolean flag that is _not_ considered a CPUID feature flag would be better. Using the CPUID feature flag name risks having management software enabling the flag by accident (as it will get included in query-cpu-model-* queries). A separate boolean flag would make this clearer.
Signature · 1 line
Eduardo
Quoted 60 lines · Eduardo Habkost
Quoted 59 lines · Michael S. Tsirkin
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + if (env->user_features[FEAT_KVM] & KVM_PV_UNHALT) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?
Quoted 8 lines
Quoted 2 lines
So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Using a boolean flag that is _not_ considered a CPUID feature flag would be better. Using the CPUID feature flag name risks having management software enabling the flag by accident (as it will get included in query-cpu-model-* queries). A separate boolean flag would make this clearer.
Can we remove all hints from query-cpu-model queries?
Quoted 2 lines
Signature · 1 line
Eduardo
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Eduardo Habkost
Quoted 61 lines · Michael S. Tsirkin
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + if (env->user_features[FEAT_KVM] & KVM_PV_UNHALT) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Quoted 7 lines
Quoted 5 lines
Using a boolean flag that is _not_ considered a CPUID feature flag would be better. Using the CPUID feature flag name risks having management software enabling the flag by accident (as it will get included in query-cpu-model-* queries). A separate boolean flag would make this clearer.
Can we remove all hints from query-cpu-model queries?
We already do (see usage of EatureWordInfo::no_autoenable_flags). This is just a matter of making the configuration option decoupled from the CPUID code, to avoid surprises elsewhere.
Signature · 1 line
Eduardo
Quoted 71 lines · Eduardo Habkost
Quoted 70 lines · Michael S. Tsirkin
Quoted 68 lines · Eduardo Habkost
Quoted 54 lines · Michael S. Tsirkin
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + if (env->user_features[FEAT_KVM] & KVM_PV_UNHALT) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
Quoted 7 lines
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Using a boolean flag that is _not_ considered a CPUID feature flag would be better. Using the CPUID feature flag name risks having management software enabling the flag by accident (as it will get included in query-cpu-model-* queries). A separate boolean flag would make this clearer.
Quoted 5 lines
Quoted 1 line
Can we remove all hints from query-cpu-model queries?
We already do (see usage of
EatureWordInfo::no_autoenable_flags). This is just a matter of making the configuration option decoupled from the CPUID code, to avoid surprises elsewhere.
It it too late to drop the hint flag and rename to a -realtime option?
Quoted 2 lines
Signature · 1 line
Eduardo
Quoted 72 lines · Michael S. Tsirkin
Quoted 71 lines · Eduardo Habkost
Quoted 70 lines · Michael S. Tsirkin
Quoted 68 lines · Eduardo Habkost
Quoted 54 lines · Michael S. Tsirkin
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Paolo Bonzini
Quoted 36 lines · Eduardo Habkost
Quoted 22 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (disable_exits) { + disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + if (env->user_features[FEAT_KVM] & KVM_PV_UNHALT) { + disable_exits &= ~KVM_X86_DISABLE_EXITS_HLT; + }Quoted 4 lines
In the future, if we decide to enable kvm-pv-unhalt by default, should "-cpu ...,kvm-hint-dedicated=on" disable kvm-pv-unhalt automatically, or should we require an explicit "kvm-hint-dedicated=on,kvm-pv-unhalt=off" option?
It should be automatic.
Quoted 5 lines
For today's defaults, this patch solves the problem, only one thing is missing before I give my R-b: we need to clearly document what exactly are the consequences and requirements of setting kvm-hint-dedicated=on (I'm not sure if the best place for this is qemu-options.hx,
x86_cpu_list(), or somewhere else).Quoted 3 lines
I don't think we have a good place for this kind of documentation, unfortunately. Right now it is mentioned in
Documentation/virtual/kvm/cpuid.txt.With this patch, the QEMU option will do more than just setting the CPUID bit, that's why I miss more detailed documentation on the QEMU side. But I agree we have no obvious place for that documentation.
In the worst case we can just add a code comment on top of feature_word_info[FEAT_KVM_HINTS].feat_names warning that kvm-hint-dedicated won't just enable the flag on CPUID and has other side-effects.
Quoted 5 lines
Quoted 2 lines
Maybe we should use "-realtime dedicated=on" instead of, or in addition to kvm-hint-dedicated=on?
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
Quoted 7 lines
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Using a boolean flag that is _not_ considered a CPUID feature flag would be better. Using the CPUID feature flag name risks having management software enabling the flag by accident (as it will get included in query-cpu-model-* queries). A separate boolean flag would make this clearer.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Can we remove all hints from query-cpu-model queries?
We already do (see usage of
EatureWordInfo::no_autoenable_flags). This is just a matter of making the configuration option decoupled from the CPUID code, to avoid surprises elsewhere.It it too late to drop the hint flag and rename to a -realtime option?
We can't remove support for "-cpu ...,kvm-pv-dedicated=on" without a deprecation notice, as it's already in v2.12.0.
But it's not too late to make other side-effects (e.g. disabling VM exits) be controlled by -realtime or other command-line option. It's also not too late to move kvm-pv-dedicated from the feat_names array to x86_cpu_properties to avoid confusion.
The existing behavior of "-cpu ...,kvm-hint-dedicated=on" is to only set the CPUID bit and do nothing else that could have unwanted side-effects (like disabling VM exits).
Do you see a problem in simply keeping the existing behavior?
Signature · 1 line
Eduardo
Paolo Bonzini
maintainerQuoted 4 lines · Michael S. Tsirkin
Quoted 2 lines
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
Currently, the only suboption of "-realtime" is mlock, which means that the only three valid uses of it are
-realtime mlock=on
-realtime mlock=off
-realtime ''
We can change the default, I think. Only the third would change meaning, and it's a slightly crazy way to use the option.
Quoted 9 lines
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
Thanks,
Paolo
Quoted 3 lines
So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Quoted 21 lines · Paolo Bonzini
Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines
Maybe it's a better idea than overloading an option that is only expected to control a CPUID bit.
Well -realtime would be a bit confusing in that it enables mlock by default.
Currently, the only suboption of "-realtime" is mlock, which means that the only three valid uses of it are
-realtime mlock=on
-realtime mlock=off
-realtime ''We can change the default, I think. Only the third would change meaning, and it's a slightly crazy way to use the option.
Quoted 5 lines
From pure API point of view, hint-dedicated looks good since it seems to say "optimize for a dedicated host CPU" and it's a hint in that guests keep working if you violate this slightly once in a while.
Quoted 8 lines
Quoted 4 lines
But I agree there's a problem: right now "kvm-" means "KVM PV" as opposed to e.g. HV enlightened gusts.
So if you enable hyperv and also want to disable halt existing, what then? What should kvm-hint-dedicated=on do?kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
Quoted 7 lines
Thanks,
Paolo
Quoted 3 lines
So how about a new hint-dedicated=on cpu flag? We can have that set kvm-hint-dedicated if kvm PV is enabled.
Paolo Bonzini
maintainerQuoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
1) For testing
2) When some of your QEMUs are too old to support kvm-hint-dedicated=on, you may still want to use -realtime dedicated-cpus=on to get better performance on the new one.
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
Quoted 7 lines
1) For testing
2) When some of your QEMUs are too old to support kvm-hint-dedicated=on, you may still want to use -realtime dedicated-cpus=on to get better performance on the new one.
Paolo
For the second purpose, can't we handle this using machine types?
Signature · 1 line
MST
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
1) For testing
Quoted 7 lines
Quoted 5 lines
2) When some of your QEMUs are too old to support kvm-hint-dedicated=on, you may still want to use -realtime dedicated-cpus=on to get better performance on the new one.
Paolo
For the second purpose, can't we handle this using machine types?
Machine-type compatibility code deals with defaults when options are omitted, not for making the meaning of explicit options depend on the machine-type.
e.g. having "-machine pc-q35-2.11 -cpu ...,+kvm-hint-dedicated=on" not expose the CPUID bit that was explicitly requested in the command-line would be a bad idea.
Signature · 1 line
Eduardo
Quoted 19 lines · Eduardo Habkost
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
1) For testing
Quoted 7 lines
Quoted 5 lines
2) When some of your QEMUs are too old to support kvm-hint-dedicated=on, you may still want to use -realtime dedicated-cpus=on to get better performance on the new one.
Paolo
For the second purpose, can't we handle this using machine types?
Quoted 7 lines
Machine-type compatibility code deals with defaults when options are omitted, not for making the meaning of explicit options depend on the machine-type.
e.g. having "-machine pc-q35-2.11 -cpu ...,+kvm-hint-dedicated=on" not expose the CPUID bit that was explicitly requested in the command-line would be a bad idea.
Why? We have machine type affecting guest visible device behaviours for years.
Quoted 2 lines
Signature · 1 line
Eduardo
Quoted 24 lines · Michael S. Tsirkin
Quoted 23 lines · Eduardo Habkost
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
kvm-hint-dedicated=on only sets the CPUID bit, which Linux for example uses that to disable pv spinlocks. "-realtime dedicated-cpus=on" only disables the vmexits. You can use the two independently.
But when would you want to use the two independently?
1) For testing
Quoted 7 lines
Quoted 5 lines
2) When some of your QEMUs are too old to support kvm-hint-dedicated=on, you may still want to use -realtime dedicated-cpus=on to get better performance on the new one.
Paolo
For the second purpose, can't we handle this using machine types?
Machine-type compatibility code deals with defaults when options are omitted, not for making the meaning of explicit options depend on the machine-type.
Quoted 6 lines
Quoted 3 lines
e.g. having "-machine pc-q35-2.11 -cpu ...,+kvm-hint-dedicated=on" not expose the CPUID bit that was explicitly requested in the command-line would be a bad idea.
Why? We have machine type affecting guest visible device behaviours for years.
Do you have an example where a machine-type overrides an option explicitly set by the user?
Signature · 1 line
Eduardo