All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quan Xu <quan.xu03@gmail.com>
To: kvm@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org, x86@kernel.org,
	xen-devel@lists.xenproject.org
Cc: Yang Zhang <yang.zhang.wz@gmail.com>
Subject: [PATCH RFC v3 0/6] x86/idle: add halt poll support
Date: Mon, 13 Nov 2017 18:05:59 +0800	[thread overview]
Message-ID: <1510567565-5118-1-git-send-email-quan.xu0@gmail.com> (raw)

From: Yang Zhang <yang.zhang.wz@gmail.com>

Some latency-intensive workload have seen 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 and disable kvm dynamic poll (halt_poll_ns=0):
     3402.9 ns/ctxsw -- 199.8 %CPU

   2. w/ patch and disable kvm dynamic poll (halt_poll_ns=0):
      halt_poll_threshold=10000  -- 1151.4 ns/ctxsw -- 200.1 %CPU
      halt_poll_threshold=20000  -- 1149.7 ns/ctxsw -- 199.9 %CPU
      halt_poll_threshold=30000  -- 1151.0 ns/ctxsw -- 199.9 %CPU
      halt_poll_threshold=40000  -- 1155.4 ns/ctxsw -- 199.3 %CPU
      halt_poll_threshold=50000  -- 1161.0 ns/ctxsw -- 200.0 %CPU
      halt_poll_threshold=100000 -- 1163.8 ns/ctxsw -- 200.4 %CPU
      halt_poll_threshold=300000 -- 1159.4 ns/ctxsw -- 201.9 %CPU
      halt_poll_threshold=500000 -- 1163.5 ns/ctxsw -- 205.5 %CPU

   3. w/ kvm dynamic poll:
      halt_poll_ns=10000  -- 3470.5 ns/ctxsw -- 199.6 %CPU
      halt_poll_ns=20000  -- 3273.0 ns/ctxsw -- 199.7 %CPU
      halt_poll_ns=30000  -- 3628.7 ns/ctxsw -- 199.4 %CPU
      halt_poll_ns=40000  -- 2280.6 ns/ctxsw -- 199.5 %CPU
      halt_poll_ns=50000  -- 3200.3 ns/ctxsw -- 199.7 %CPU
      halt_poll_ns=100000 -- 2186.6 ns/ctxsw -- 199.6 %CPU
      halt_poll_ns=300000 -- 3178.7 ns/ctxsw -- 199.6 %CPU
      halt_poll_ns=500000 -- 3505.4 ns/ctxsw -- 199.7 %CPU

   4. w/patch and w/ kvm dynamic poll:

      halt_poll_ns=10000 & halt_poll_threshold=10000  -- 1155.5 ns/ctxsw -- 199.8 %CPU
      halt_poll_ns=10000 & halt_poll_threshold=20000  -- 1165.6 ns/ctxsw -- 199.8 %CPU
      halt_poll_ns=10000 & halt_poll_threshold=30000  -- 1161.1 ns/ctxsw -- 200.0 %CPU

      halt_poll_ns=20000 & halt_poll_threshold=10000  -- 1158.1 ns/ctxsw -- 199.8 %CPU
      halt_poll_ns=20000 & halt_poll_threshold=20000  -- 1161.0 ns/ctxsw -- 199.7 %CPU
      halt_poll_ns=20000 & halt_poll_threshold=30000  -- 1163.7 ns/ctxsw -- 199.9 %CPU

      halt_poll_ns=30000 & halt_poll_threshold=10000  -- 1158.7 ns/ctxsw -- 199.7 %CPU
      halt_poll_ns=30000 & halt_poll_threshold=20000  -- 1153.8 ns/ctxsw -- 199.8 %CPU
      halt_poll_ns=30000 & halt_poll_threshold=30000  -- 1155.1 ns/ctxsw -- 199.8 %CPU

   5. idle=poll
      3957.57 ns/ctxsw --  999.4%CPU

Here is the data we get when running benchmark netperf:

   1. w/o patch and disable kvm dynamic poll (halt_poll_ns=0):
      29031.6 bit/s -- 76.1 %CPU

   2. w/ patch and disable kvm dynamic poll (halt_poll_ns=0):
      halt_poll_threshold=10000  -- 29021.7 bit/s -- 105.1 %CPU
      halt_poll_threshold=20000  -- 33463.5 bit/s -- 128.2 %CPU
      halt_poll_threshold=30000  -- 34436.4 bit/s -- 127.8 %CPU
      halt_poll_threshold=40000  -- 35563.3 bit/s -- 129.6 %CPU
      halt_poll_threshold=50000  -- 35787.7 bit/s -- 129.4 %CPU
      halt_poll_threshold=100000 -- 35477.7 bit/s -- 130.0 %CPU
      halt_poll_threshold=300000 -- 35730.0 bit/s -- 132.4 %CPU
      halt_poll_threshold=500000 -- 34978.4 bit/s -- 134.2 %CPU

   3. w/ kvm dynamic poll:
      halt_poll_ns=10000  -- 28849.8 bit/s -- 75.2  %CPU
      halt_poll_ns=20000  -- 29004.8 bit/s -- 76.1  %CPU
      halt_poll_ns=30000  -- 35662.0 bit/s -- 199.7 %CPU
      halt_poll_ns=40000  -- 35874.8 bit/s -- 187.5 %CPU
      halt_poll_ns=50000  -- 35603.1 bit/s -- 199.8 %CPU
      halt_poll_ns=100000 -- 35588.8 bit/s -- 200.0 %CPU
      halt_poll_ns=300000 -- 35912.4 bit/s -- 200.0 %CPU
      halt_poll_ns=500000 -- 35735.6 bit/s -- 200.0 %CPU

   4. w/patch and w/ kvm dynamic poll:

      halt_poll_ns=10000 & halt_poll_threshold=10000  -- 29427.9 bit/s -- 107.8 %CPU
      halt_poll_ns=10000 & halt_poll_threshold=20000  -- 33048.4 bit/s -- 128.1 %CPU
      halt_poll_ns=10000 & halt_poll_threshold=30000  -- 35129.8 bit/s -- 129.1 %CPU

      halt_poll_ns=20000 & halt_poll_threshold=10000  -- 31091.3 bit/s -- 130.3 %CPU
      halt_poll_ns=20000 & halt_poll_threshold=20000  -- 33587.9 bit/s -- 128.9 %CPU
      halt_poll_ns=20000 & halt_poll_threshold=30000  -- 35532.9 bit/s -- 129.1 %CPU

      halt_poll_ns=30000 & halt_poll_threshold=10000  -- 35633.1 bit/s -- 199.4 %CPU
      halt_poll_ns=30000 & halt_poll_threshold=20000  -- 42225.3 bit/s -- 198.7 %CPU
      halt_poll_ns=30000 & halt_poll_threshold=30000  -- 42210.7 bit/s -- 200.3 %CPU

   5. idle=poll
      37081.7 bit/s -- 998.1 %CPU

---
V2 -> V3:
- move poll update into arch/. in v3, poll update is based on duration of the
  last idle loop which is from tick_nohz_idle_enter to tick_nohz_idle_exit,
  and try our best not to interfere with scheduler/idle code. (This seems
  not to follow Peter's v2 comment, however we had a f2f discussion about it
  in Prague.)
- enhance patch desciption.
- enhance Documentation and sysctls.
- test with IRQ_TIMINGS related code, which seems not working so far.

V1 -> V2:
- integrate the smart halt poll into paravirt code
- use idle_stamp instead of check_poll
- since it hard to get whether vcpu is the only task in pcpu, so we
  don't consider it in this series.(May improve it in future)

---
Quan Xu (4):
  x86/paravirt: Add pv_idle_ops to paravirt ops
  KVM guest: register kvm_idle_poll for pv_idle_ops
  Documentation: Add three sysctls for smart idle poll
  tick: get duration of the last idle loop

Yang Zhang (2):
  sched/idle: Add a generic poll before enter real idle path
  KVM guest: introduce smart idle poll algorithm

 Documentation/sysctl/kernel.txt       |   35 ++++++++++++++++
 arch/x86/include/asm/paravirt.h       |    5 ++
 arch/x86/include/asm/paravirt_types.h |    6 +++
 arch/x86/kernel/kvm.c                 |   73 +++++++++++++++++++++++++++++++++
 arch/x86/kernel/paravirt.c            |   10 +++++
 arch/x86/kernel/process.c             |    7 +++
 include/linux/kernel.h                |    6 +++
 include/linux/tick.h                  |    2 +
 kernel/sched/idle.c                   |    2 +
 kernel/sysctl.c                       |   34 +++++++++++++++
 kernel/time/tick-sched.c              |   11 +++++
 kernel/time/tick-sched.h              |    3 +
 12 files changed, 194 insertions(+), 0 deletions(-)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2017-11-13 10:05 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-13 10:05 Quan Xu [this message]
2017-11-13 10:06 ` [PATCH RFC v3 1/6] x86/paravirt: Add pv_idle_ops to paravirt ops Quan Xu
2017-11-13 10:53   ` Juergen Gross
2017-11-13 11:09     ` Wanpeng Li
2017-11-13 11:09       ` Wanpeng Li
2017-11-13 11:09     ` Wanpeng Li
2017-11-13 11:09     ` Wanpeng Li
2017-11-14  7:02     ` Quan Xu
2017-11-14  7:02     ` Quan Xu
2017-11-14  7:02     ` Quan Xu
2017-11-14  7:12       ` Wanpeng Li
2017-11-14  7:12         ` Wanpeng Li
2017-11-14  8:15         ` Quan Xu
2017-11-14  8:15         ` Quan Xu
2017-11-14  8:15           ` Quan Xu
2017-11-14  8:22           ` Wanpeng Li
2017-11-14  8:22             ` Wanpeng Li
2017-11-14  8:22             ` Wanpeng Li
2017-11-14  8:22             ` Wanpeng Li
2017-11-14 10:23             ` Quan Xu
2017-11-14 10:23               ` Quan Xu
2017-11-14 10:23             ` Quan Xu
2017-11-14 10:23             ` Quan Xu
2017-11-14  8:22           ` Wanpeng Li
2017-11-14  8:15         ` Quan Xu
2017-11-14  7:12       ` Wanpeng Li
2017-11-14  7:12       ` Wanpeng Li
2017-11-14  7:30       ` Juergen Gross
2017-11-14  7:30       ` Juergen Gross
2017-11-14  9:38         ` Quan Xu
2017-11-14 10:27           ` Juergen Gross
2017-11-14 11:43             ` Quan Xu
2017-11-14 11:43             ` Quan Xu
2017-11-14 11:43             ` Quan Xu
2017-11-14 11:58               ` Juergen Gross
2017-11-14 11:58               ` Juergen Gross
2017-11-14 11:58                 ` Juergen Gross
2017-11-14 10:27           ` Juergen Gross
2017-11-14 10:27           ` Juergen Gross
2017-11-14  9:38         ` Quan Xu
2017-11-14  9:38         ` Quan Xu
2017-11-14  7:30       ` Juergen Gross
2017-11-13 10:53   ` Juergen Gross
2017-11-13 10:53   ` Juergen Gross
2017-11-13 10:06 ` Quan Xu
2017-11-13 10:06 ` [PATCH RFC v3 2/6] KVM guest: register kvm_idle_poll for pv_idle_ops Quan Xu
2017-11-13 10:06 ` Quan Xu
2017-11-13 10:06 ` [PATCH RFC v3 3/6] sched/idle: Add a generic poll before enter real idle path Quan Xu
2017-11-15 12:11   ` Peter Zijlstra
2017-11-15 12:11     ` Peter Zijlstra
2017-11-15 22:03     ` Thomas Gleixner
2017-11-15 22:03     ` Thomas Gleixner
2017-11-15 22:03     ` Thomas Gleixner
2017-11-16  8:45       ` Peter Zijlstra
2017-11-16  8:45         ` Peter Zijlstra
2017-11-16  8:58         ` Thomas Gleixner
2017-11-16  8:58         ` Thomas Gleixner
2017-11-16  8:58         ` Thomas Gleixner
2017-11-16  9:29         ` Quan Xu
2017-11-16  9:29         ` Quan Xu
2017-11-16  9:47           ` Thomas Gleixner
2017-11-16  9:47           ` Thomas Gleixner
2017-11-16  9:47           ` Thomas Gleixner
2017-11-16  9:29         ` Quan Xu
2017-11-16  8:45       ` Peter Zijlstra
2017-11-16  9:12       ` Quan Xu
2017-11-16  9:45         ` Daniel Lezcano
2017-11-20  7:05           ` Quan Xu
2017-11-20  7:05           ` Quan Xu
2017-11-20 18:01             ` Daniel Lezcano
2017-11-20 18:01             ` Daniel Lezcano
2017-11-20 18:01             ` Daniel Lezcano
2017-11-20  7:05           ` Quan Xu
2017-11-16  9:45         ` Daniel Lezcano
2017-11-16  9:45         ` Daniel Lezcano
2017-11-16  9:53         ` Thomas Gleixner
2017-11-16  9:53         ` Thomas Gleixner
2017-11-17 11:23           ` Quan Xu
2017-11-17 11:23           ` Quan Xu
2017-11-17 11:23           ` Quan Xu
2017-11-17 11:36             ` Thomas Gleixner
2017-11-17 11:36             ` Thomas Gleixner
2017-11-17 11:36               ` Thomas Gleixner
2017-11-17 11:36               ` Thomas Gleixner
2017-11-17 12:21               ` Quan Xu
2017-11-17 12:21                 ` Quan Xu
2017-11-17 12:21               ` Quan Xu
2017-11-17 12:21               ` Quan Xu
2017-11-16  9:53         ` Thomas Gleixner
2017-11-16  9:12       ` Quan Xu
2017-11-16  9:12       ` Quan Xu
2017-11-15 12:11   ` Peter Zijlstra
2017-11-13 10:06 ` Quan Xu
2017-11-15 21:31 ` [PATCH RFC v3 0/6] x86/idle: add halt poll support Konrad Rzeszutek Wilk
2017-11-15 21:31 ` [Xen-devel] " Konrad Rzeszutek Wilk
2017-11-15 21:31   ` Konrad Rzeszutek Wilk
2017-11-20  7:18   ` Quan Xu
2017-11-20  7:18   ` Quan Xu
2017-11-20  7:18   ` Quan Xu
  -- strict thread matches above, loose matches on Subject: below --
2017-11-13 11:01 Quan Xu
2017-11-15 12:13 ` Peter Zijlstra
2017-11-15 12:13 ` Peter Zijlstra
2017-11-15 13:04   ` Xu Quan
2017-11-13 10:05 Quan Xu
2017-11-13  8:16 Quan Xu
2017-11-13  8:16 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=1510567565-5118-1-git-send-email-quan.xu0@gmail.com \
    --to=quan.xu03@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --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.