mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
KVM: Introduce paravirtualization hints and KVM_HINTS_DEDICATED
This patch introduces kvm_para_has_hint() to query for hints about the configuration of the guests. The first hint KVM_HINTS_DEDICATED, is set if the guest has dedicated physical CPUs for each vCPU (i.e. pinning and no over-commitment). This allows optimizing spinlocks and tells the guest to avoid PV TLB flush. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Wanpeng Li <wanpengli@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
This commit is contained in:
parent
d4c67a7a54
commit
a4429e53c9
@ -23,8 +23,8 @@ This function queries the presence of KVM cpuid leafs.
|
|||||||
|
|
||||||
|
|
||||||
function: define KVM_CPUID_FEATURES (0x40000001)
|
function: define KVM_CPUID_FEATURES (0x40000001)
|
||||||
returns : ebx, ecx, edx = 0
|
returns : ebx, ecx
|
||||||
eax = and OR'ed group of (1 << flag), where each flags is:
|
eax = an OR'ed group of (1 << flag), where each flags is:
|
||||||
|
|
||||||
|
|
||||||
flag || value || meaning
|
flag || value || meaning
|
||||||
@ -66,3 +66,14 @@ KVM_FEATURE_CLOCKSOURCE_STABLE_BIT || 24 || host will warn if no guest-side
|
|||||||
|| || per-cpu warps are expected in
|
|| || per-cpu warps are expected in
|
||||||
|| || kvmclock.
|
|| || kvmclock.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
edx = an OR'ed group of (1 << flag), where each flags is:
|
||||||
|
|
||||||
|
|
||||||
|
flag || value || meaning
|
||||||
|
==================================================================================
|
||||||
|
KVM_HINTS_DEDICATED || 0 || guest checks this feature bit to
|
||||||
|
|| || determine if there is vCPU pinning
|
||||||
|
|| || and there is no vCPU over-commitment,
|
||||||
|
|| || allowing optimizations
|
||||||
|
----------------------------------------------------------------------------------
|
||||||
|
@ -94,6 +94,11 @@ static inline unsigned int kvm_arch_para_features(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MIPS_PARAVIRT
|
#ifdef CONFIG_MIPS_PARAVIRT
|
||||||
static inline bool kvm_para_available(void)
|
static inline bool kvm_para_available(void)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,11 @@ static inline unsigned int kvm_arch_para_features(void)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool kvm_check_and_clear_guest_paused(void)
|
static inline bool kvm_check_and_clear_guest_paused(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -193,6 +193,11 @@ static inline unsigned int kvm_arch_para_features(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool kvm_check_and_clear_guest_paused(void)
|
static inline bool kvm_check_and_clear_guest_paused(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,6 +88,7 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
|
|||||||
#ifdef CONFIG_KVM_GUEST
|
#ifdef CONFIG_KVM_GUEST
|
||||||
bool kvm_para_available(void);
|
bool kvm_para_available(void);
|
||||||
unsigned int kvm_arch_para_features(void);
|
unsigned int kvm_arch_para_features(void);
|
||||||
|
unsigned int kvm_arch_para_hints(void);
|
||||||
void kvm_async_pf_task_wait(u32 token, int interrupt_kernel);
|
void kvm_async_pf_task_wait(u32 token, int interrupt_kernel);
|
||||||
void kvm_async_pf_task_wake(u32 token);
|
void kvm_async_pf_task_wake(u32 token);
|
||||||
u32 kvm_read_and_reset_pf_reason(void);
|
u32 kvm_read_and_reset_pf_reason(void);
|
||||||
@ -115,6 +116,11 @@ static inline unsigned int kvm_arch_para_features(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 kvm_read_and_reset_pf_reason(void)
|
static inline u32 kvm_read_and_reset_pf_reason(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
*/
|
*/
|
||||||
#define KVM_CPUID_SIGNATURE 0x40000000
|
#define KVM_CPUID_SIGNATURE 0x40000000
|
||||||
|
|
||||||
/* This CPUID returns a feature bitmap in eax. Before enabling a particular
|
/* This CPUID returns two feature bitmaps in eax, edx. Before enabling
|
||||||
* paravirtualization, the appropriate feature bit should be checked.
|
* a particular paravirtualization, the appropriate feature bit should
|
||||||
|
* be checked in eax. The performance hint feature bit should be checked
|
||||||
|
* in edx.
|
||||||
*/
|
*/
|
||||||
#define KVM_CPUID_FEATURES 0x40000001
|
#define KVM_CPUID_FEATURES 0x40000001
|
||||||
#define KVM_FEATURE_CLOCKSOURCE 0
|
#define KVM_FEATURE_CLOCKSOURCE 0
|
||||||
@ -28,6 +30,8 @@
|
|||||||
#define KVM_FEATURE_PV_TLB_FLUSH 9
|
#define KVM_FEATURE_PV_TLB_FLUSH 9
|
||||||
#define KVM_FEATURE_ASYNC_PF_VMEXIT 10
|
#define KVM_FEATURE_ASYNC_PF_VMEXIT 10
|
||||||
|
|
||||||
|
#define KVM_HINTS_DEDICATED 0
|
||||||
|
|
||||||
/* The last 8 bits are used to indicate how to interpret the flags field
|
/* The last 8 bits are used to indicate how to interpret the flags field
|
||||||
* in pvclock structure. If no bits are set, all flags are ignored.
|
* in pvclock structure. If no bits are set, all flags are ignored.
|
||||||
*/
|
*/
|
||||||
|
@ -605,6 +605,11 @@ unsigned int kvm_arch_para_features(void)
|
|||||||
return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES);
|
return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return cpuid_edx(kvm_cpuid_base() | KVM_CPUID_FEATURES);
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t __init kvm_detect(void)
|
static uint32_t __init kvm_detect(void)
|
||||||
{
|
{
|
||||||
return kvm_cpuid_base();
|
return kvm_cpuid_base();
|
||||||
|
@ -19,6 +19,11 @@ static inline unsigned int kvm_arch_para_features(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int kvm_arch_para_hints(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool kvm_para_available(void)
|
static inline bool kvm_para_available(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,4 +9,9 @@ static inline bool kvm_para_has_feature(unsigned int feature)
|
|||||||
{
|
{
|
||||||
return !!(kvm_arch_para_features() & (1UL << feature));
|
return !!(kvm_arch_para_features() & (1UL << feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool kvm_para_has_hint(unsigned int feature)
|
||||||
|
{
|
||||||
|
return !!(kvm_arch_para_hints() & (1UL << feature));
|
||||||
|
}
|
||||||
#endif /* __LINUX_KVM_PARA_H */
|
#endif /* __LINUX_KVM_PARA_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user