All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Yang Zhang <yang.zhang.wz@gmail.com>, linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, wanpeng.li@hotmail.com, mst@redhat.com,
	pbonzini@redhat.com, tglx@linutronix.de, rkrcmar@redhat.com,
	dmatlack@google.com, peterz@infradead.org,
	linux-doc@vger.kernel.org
Subject: Re: [RFC PATCH v2 0/7] x86/idle: add halt poll support
Date: Tue, 29 Aug 2017 13:58:12 +0200	[thread overview]
Message-ID: <6ba7f198-4403-c9d1-f0be-7069cc8cd421@suse.de> (raw)
In-Reply-To: <1504007201-12904-1-git-send-email-yang.zhang.wz@gmail.com>

On 08/29/2017 01:46 PM, Yang Zhang wrote:
> Some latency-intensive workload will see obviously performance
> drop when running inside VM. The main reason is that the overhead
> is amplified when running inside VM. The most cost i have seen is
> inside idle path.
>
> This patch introduces a new mechanism to poll for a while before
> entering idle state. If schedule is needed during poll, then we
> don't need to goes through the heavy overhead path.
>
> Here is the data we get when running benchmark contextswitch to measure
> the latency(lower is better):
>
>     1. w/o patch:
>        2493.14 ns/ctxsw -- 200.3 %CPU
>     
>     2. w/ patch:
>        halt_poll_threshold=10000 -- 1485.96ns/ctxsw -- 201.0 %CPU
>        halt_poll_threshold=20000 -- 1391.26 ns/ctxsw -- 200.7 %CPU
>        halt_poll_threshold=30000 -- 1488.55 ns/ctxsw -- 200.1 %CPU
>        halt_poll_threshold=500000 -- 1159.14 ns/ctxsw -- 201.5 %CPU
>     
>     3. kvm dynamic poll
>        halt_poll_ns=10000 -- 2296.11 ns/ctxsw -- 201.2 %CPU
>        halt_poll_ns=20000 -- 2599.7 ns/ctxsw -- 201.7 %CPU
>        halt_poll_ns=30000 -- 2588.68 ns/ctxsw -- 211.6 %CPU
>        halt_poll_ns=500000 -- 2423.20 ns/ctxsw -- 229.2 %CPU
>     
>     4. idle=poll
>        2050.1 ns/ctxsw -- 1003 %CPU
>     
>     5. idle=mwait
>        2188.06 ns/ctxsw -- 206.3 %CPU

Could you please try to create another metric for guest initiated, host 
aborted mwait?

For a quick benchmark, reserve 4 registers for a magic value, set them 
to the magic value before you enter MWAIT in the guest. Then allow 
native MWAIT execution on the host. If you see the guest wants to enter 
with the 4 registers containing the magic contents and no events are 
pending, directly go into the vcpu block function on the host.

That way any time a guest gets naturally aborted while in mwait, it will 
only reenter mwait when an event actually occured. While the guest is 
normally running (and nobody else wants to run on the host), we just 
stay in guest context, but with a sleeping CPU.

Overall, that might give us even better performance, as it allows for 
turbo boost and HT to work properly.


Alex

  parent reply	other threads:[~2017-08-29 11:58 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 11:46 [RFC PATCH v2 0/7] x86/idle: add halt poll support Yang Zhang
2017-08-29 11:46 ` [RFC PATCH v2 1/7] x86/paravirt: Add pv_idle_ops to paravirt ops Yang Zhang
2017-08-29 11:46   ` Yang Zhang
2017-08-29 13:55   ` Konrad Rzeszutek Wilk
2017-08-29 13:55     ` Konrad Rzeszutek Wilk
2017-08-30  7:33     ` Juergen Gross
2017-08-30  7:33     ` Juergen Gross
2017-09-01  6:50     ` Yang Zhang
2017-09-01  6:50     ` Yang Zhang
2017-08-29 11:46 ` [RFC PATCH v2 2/7] KVM guest: register kvm_idle_poll for pv_idle_ops Yang Zhang
2017-08-29 11:46 ` [RFC PATCH v2 3/7] sched/idle: Add poll before enter real idle path Yang Zhang
2017-08-29 12:45   ` Peter Zijlstra
2017-09-01  5:57     ` Quan Xu
2017-09-14  8:41       ` Quan Xu
2017-09-14  9:18         ` Borislav Petkov
2017-08-29 14:39   ` Borislav Petkov
2017-09-01  6:49     ` Quan Xu
2017-09-29 10:39       ` Quan Xu
2017-08-29 11:46 ` [RFC PATCH v2 4/7] x86/paravirt: Add update in x86/paravirt pv_idle_ops Yang Zhang
2017-08-29 11:46 ` Yang Zhang
2017-08-29 11:46 ` [RFC PATCH v2 5/7] Documentation: Add three sysctls for smart idle poll Yang Zhang
2017-08-29 11:46 ` Yang Zhang
2017-08-29 11:46   ` Yang Zhang
2017-08-29 17:20   ` Luis R. Rodriguez
2017-08-29 17:20   ` Luis R. Rodriguez
2017-08-29 17:20     ` Luis R. Rodriguez
2017-08-29 11:46 ` [RFC PATCH v2 6/7] KVM guest: introduce smart idle poll algorithm Yang Zhang
2017-08-29 11:46 ` [RFC PATCH v2 7/7] sched/idle: update poll time when wakeup from idle Yang Zhang
2017-08-29 12:46   ` Peter Zijlstra
2017-09-01  7:30     ` Yang Zhang
2017-09-29 10:29     ` Quan Xu
2017-08-29 11:58 ` Alexander Graf [this message]
2017-09-01  6:21   ` [RFC PATCH v2 0/7] x86/idle: add halt poll support Yang Zhang
2017-08-29 13:03 ` Andi Kleen
2017-08-29 14:02 ` Wanpeng Li
2017-08-29 14:27   ` Konrad Rzeszutek Wilk
2017-08-29 14:36   ` Michael S. Tsirkin
2017-09-01  6:32   ` Yang Zhang
2017-09-01  6:52     ` Wanpeng Li
2017-09-01  6:44   ` Yang Zhang
2017-09-01  6:58     ` Wanpeng Li
2017-09-01  7:53       ` Yang Zhang
2017-08-29 14:56 ` Michael S. Tsirkin
2017-09-13 11:56   ` Yang Zhang
2017-09-14  8:36     ` Quan Xu
2017-09-14  9:19       ` Wanpeng Li
2017-09-14  9:40         ` Quan Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ba7f198-4403-c9d1-f0be-7069cc8cd421@suse.de \
    --to=agraf@suse.de \
    --cc=dmatlack@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=wanpeng.li@hotmail.com \
    --cc=yang.zhang.wz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.