All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/7] x86/idle: add halt poll support
@ 2017-08-29 11:46 Yang Zhang
  2017-08-29 11:46   ` Yang Zhang
                   ` (12 more replies)
  0 siblings, 13 replies; 47+ messages in thread
From: Yang Zhang @ 2017-08-29 11:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: kvm, wanpeng.li, mst, pbonzini, tglx, rkrcmar, dmatlack, agraf,
	peterz, linux-doc, Yang Zhang

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

Here is the data we get when running benchmark netperf:

   1. w/o patch:
      14556.8 bits/s  -- 144.2 %CPU

   2. w/ patch:
      halt_poll_threshold=10000 -- 15803.89 bits/s -- 159.5 %CPU
      halt_poll_threshold=20000 -- 15899.04 bits/s -- 161.5 %CPU
      halt_poll_threshold=30000 -- 15642.38 bits/s -- 161.8 %CPU
      halt_poll_threshold=40000 -- 18040.76 bits/s -- 184.0 %CPU
      halt_poll_threshold=50000 -- 18877.61 bits/s -- 197.3 %CPU

   3. kvm dynamic poll
      halt_poll_ns=10000 -- 15876.00 bits/s -- 172.2 %CPU
      halt_poll_ns=20000 -- 15602.58 bits/s -- 185.4 %CPU
      halt_poll_ns=30000 -- 15930.69 bits/s -- 194.4 %CPU
      halt_poll_ns=40000 -- 16413.09 bits/s -- 195.3 %CPU
      halt_poll_ns=50000 -- 16417.42 bits/s -- 196.3 %CPU

   4. idle=poll in guest
      18441.3bit/s -- 1003 %CPU

   5. idle=mwait in guest
      15760.6  bits/s  -- 157.6 %CPU

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)

Yang Zhang (7):
  x86/paravirt: Add pv_idle_ops to paravirt ops
  KVM guest: register kvm_idle_poll for pv_idle_ops
  sched/idle: Add poll before enter real idle path
  x86/paravirt: Add update in x86/paravirt pv_idle_ops
  Documentation: Add three sysctls for smart idle poll
  KVM guest: introduce smart idle poll algorithm
  sched/idle: update poll time when wakeup from idle

 Documentation/sysctl/kernel.txt       | 25 +++++++++++++
 arch/x86/include/asm/paravirt.h       | 10 ++++++
 arch/x86/include/asm/paravirt_types.h |  7 ++++
 arch/x86/kernel/kvm.c                 | 67 +++++++++++++++++++++++++++++++++++
 arch/x86/kernel/paravirt.c            | 11 ++++++
 arch/x86/kernel/process.c             |  7 ++++
 include/linux/kernel.h                |  6 ++++
 include/linux/sched/idle.h            |  4 +++
 kernel/sched/core.c                   |  4 +++
 kernel/sched/idle.c                   |  9 +++++
 kernel/sysctl.c                       | 23 ++++++++++++
 11 files changed, 173 insertions(+)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2017-09-29 10:40 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [RFC PATCH v2 0/7] x86/idle: add halt poll support Alexander Graf
2017-09-01  6:21   ` 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

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.