qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] i386: Allow monitor / mwait cpuid override


From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [PATCH] i386: Allow monitor / mwait cpuid override
Date: Tue, 27 Feb 2018 09:52:56 +0000

Hi all,

Guests could achive good performance in 'Message Passing Workloads' 
scenarios when knowing the X86_FEATURE_MWAIT feature which is presented by 
qemu. 
the reason is that after knowing that feature, 
the guest could use mwait method, which saves VMEXIT, 
to do idle, and achives high performace in latency-sensitive scenario.

Is there any plan for this patch? 

Or May I send a updated version based on yours? @Alex?

Thanks,
-Gonglei


> -----Original Message-----
> From: Qemu-devel
> [mailto:address@hidden On
> Behalf Of Alexander Graf
> Sent: Monday, March 27, 2017 10:27 PM
> To: address@hidden
> Cc: Paolo Bonzini; Eduardo Habkost; Richard Henderson
> Subject: [Qemu-devel] [PATCH] i386: Allow monitor / mwait cpuid override
> 
> KVM allows trap and emulate (read: NOP) of the MONITOR and MWAIT
> instructions. There is work undergoing to enable actual execution
> of these inside of KVM, but nobody really wants to expose the feature
> to the guest by default, as it would eat up all of the host CPU.
> 
> So today there is no streamlined way to actually notify the guest that
> it's ok to execute MONITOR / MWAIT, even when we want to explicitly
> leave the guest in guest context.
> 
> This patch adds a new -cpu parameter called "mwait" which - when
> enabled - force enables the MONITOR / MWAIT CPUID flag, even when
> the underlying accel framework does not explicitly advertise support.
> 
> With that in place, we can explicitly allow users to specify that
> they want have the guest execute MONITOR / MWAIT in its idle loop.
> 
> Signed-off-by: Alexander Graf <address@hidden>
> ---
>  target/i386/cpu.c | 5 +++++
>  target/i386/cpu.h | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 7aa7622..c44020b 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -3460,6 +3460,10 @@ static int x86_cpu_filter_features(X86CPU *cpu)
>              x86_cpu_get_supported_feature_word(w, false);
>          uint32_t requested_features = env->features[w];
>          env->features[w] &= host_feat;
> +        if (cpu->expose_monitor && (w == FEAT_1_ECX)) {
> +            /* Force monitor feature in */
> +            env->features[w] |= CPUID_EXT_MONITOR;
> +        }
>          cpu->filtered_features[w] = requested_features &
> ~env->features[w];
>          if (cpu->filtered_features[w]) {
>              rv = 1;
> @@ -3988,6 +3992,7 @@ static Property x86_cpu_properties[] = {
>      DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true),
>      DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
>      DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true),
> +    DEFINE_PROP_BOOL("mwait", X86CPU, expose_monitor, false),
>      DEFINE_PROP_UINT32("phys-bits", X86CPU, phys_bits, 0),
>      DEFINE_PROP_BOOL("host-phys-bits", X86CPU, host_phys_bits, false),
>      DEFINE_PROP_BOOL("fill-mtrr-mask", X86CPU, fill_mtrr_mask, true),
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 07401ad..7400d00 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1214,6 +1214,7 @@ struct X86CPU {
>      bool check_cpuid;
>      bool enforce_cpuid;
>      bool expose_kvm;
> +    bool expose_monitor;
>      bool migratable;
>      bool max_features; /* Enable all supported features automatically */
>      uint32_t apic_id;
> --
> 1.8.5.6
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]