Re: [PATCH v1 0/7] KVM: Hyper-V SynIC timers

2015-12-01 Thread Wanpeng Li
2015-11-26 16:34 GMT+08:00 Andrey Smetanin : > > > On 11/26/2015 08:28 AM, Wanpeng Li wrote: >> >> 2015-11-25 23:20 GMT+08:00 Andrey Smetanin : >>> >>> Per Hyper-V specification (and as required by Hyper-V-aware guests), >>> SynIC provides 4 per-v

Re: [PATCH v1 0/7] KVM: Hyper-V SynIC timers

2015-11-26 Thread Wanpeng Li
2015-11-26 16:34 GMT+08:00 Andrey Smetanin : > > > On 11/26/2015 08:28 AM, Wanpeng Li wrote: >> >> 2015-11-25 23:20 GMT+08:00 Andrey Smetanin : >>> >>> Per Hyper-V specification (and as required by Hyper-V-aware guests), >>> SynIC provides 4 per-v

Re: [PATCH v1 0/7] KVM: Hyper-V SynIC timers

2015-11-25 Thread Wanpeng Li
ynIC message slot and triggering the corresponding > synthetic interrupt. Could you post a link for this specification? Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info a

Re: [PATCH] KVM: x86: don't expose syscall/sysret to intel 32-bit guest

2015-11-25 Thread Wanpeng Li
xposes LM bit to 32 bit guest(however it doesn't expose syscall/sysret), so maybe we can't depend on F(LM). Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at htt

Re: [PATCH] KVM: x86: emulate: correct page fault error code for NoWrite instructions

2015-11-19 Thread Wanpeng Li
2015-11-20 10:52 GMT+08:00 Wanpeng Li : > Hi Paolo, > 2015-02-09 17:03 GMT+08:00 Paolo Bonzini : >> NoWrite instructions (e.g. cmp or test) never set the "write access" >> bit in the error code, even if one of the operands is treated as a >> destination. > &

Re: [PATCH] KVM: x86: emulate: correct page fault error code for NoWrite instructions

2015-11-19 Thread Wanpeng Li
SDM describe above? Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH] KVM: x86: don't expose syscall/sysret to intel 32-bit guest

2015-11-19 Thread Wanpeng Li
2015-11-19 19:05 GMT+08:00 Paolo Bonzini : > > > On 19/11/2015 11:45, Wanpeng li wrote: >> Intel cpu doesn't support syscall/sysret in non 64-bit mode which >> is different from AMD. Expose syscall/sysret to intel 32-bit guest >> just makes no sense and leads to

Re: [PATCH kvm-unit-tests] x86: tsc: add test for RDTSCP

2015-11-12 Thread Wanpeng Li
test_rdtscp(10); > + test_rdtscp(0x100); > + } else > + printf("rdtscp not supported\n"); > return 0; > } > diff --git a/x86/unittests.cfg b/x86/unittests.cfg > index ac652fc..fd7e9b2 100644 > --- a/x86/unittests.cf

Re: [PATCH kvm-unit-tests] x86: tsc: add test for RDTSCP

2015-11-12 Thread Wanpeng Li
+ test_rdtscp(10); > + test_rdtscp(0x100); > + } else > + printf("rdtscp not supported\n"); > return 0; > } > diff --git a/x86/unittests.cfg b/x86/unittests.cfg > index ac652fc..fd7e9b2 100644 > --- a/x86/unitt

Re: [PATCH] KVM: x86: fix eflags state following processor init/reset

2015-11-10 Thread Wanpeng Li
modifies the existing call to vmcs_writel? If there is a > bug, can you write a unit test for it? It should be possible to test > for the problem using INIT+SIPI on an AP. You are right, I write a INIT+SIPI kvm-unit-test and didn't trigger any bug. Please ignore the patch. Regards,

[PATCH v2] KVM: x86: Reset RFLAGS state following processor init/reset

2015-11-03 Thread Wanpeng Li
reset eflags register to 0002H following initialization of the processor. Signed-off-by: Wanpeng Li --- v1 -> v2: * use vmcs_writel arch/x86/kvm/vmx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b680c2e..1a95ef7 100644 --- a/arch/x86/

Re: Steal time accounting in KVM. Benchmark.

2015-10-29 Thread Wanpeng Li
(with 2:1 cpu overcommit). irq time accounting gets crazy. Even 'top' shows weird statistic: 50% hi, 50% st, ~0% user, spinning processes use ~0% cpu - that is not correct. If this is the desired behavior or something need to improve? Regards, Wanpeng Li -- To unsubscribe from this list

Re: [PATCH] KVM: x86: fix eflags state following processor init/reset

2015-10-27 Thread Wanpeng Li
Ping, :-) On 10/21/15 2:28 PM, Wanpeng Li wrote: Reference SDM 3.4.3: Following initialization of the processor (either by asserting the RESET pin or the INIT pin), the state of the EFLAGS register is 0002H. However, the eflags fixed bit is not set and other bits are also not cleared

Re: Difference between vcpu_load and kvm_sched_in ?

2015-10-22 Thread Wanpeng Li
On 10/21/15 2:46 PM, Paolo Bonzini wrote: On 21/10/2015 00:57, Wanpeng Li wrote: kvm_sched_out and kvm_sched_in are part of KVM's preemption hooks. The hooks are registered only between vcpu_load and vcpu_put, therefore they know that the mutex is taken. The sequence will go like

[PATCH] KVM: x86: fix eflags state following processor init/reset

2015-10-20 Thread Wanpeng Li
set eflags register to 0002H following initialization of the processor. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b680c2e..326f6ea 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

Re: Steal time accounting in KVM. Benchmark.

2015-10-20 Thread Wanpeng Li
or worse. It prefers to stuck at quarters (100% 75% 50% 25%) Output is attached. If the output in attachment is for VM2 only? Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at

Re: Difference between vcpu_load and kvm_sched_in ?

2015-10-20 Thread Wanpeng Li
out kvm_sched_in kvm_sched_out ... vcpu_put Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH v3 0/5] KVM: nVMX: nested VPID emulation

2015-10-16 Thread Wanpeng Li
Ping, :-) On 10/14/15 12:12 AM, Wanpeng Li wrote: v2 -> v3: * separate nested_vmx_vpid_caps and move checks to patch 3/5, only rejoin them when reading the MSR. v1 -> v2: * set bit 32 of the VMX_EPT_VPID_CAP MSR * check against the supported types in the implementation of

[PATCH v3 5/5] KVM: nVMX: expose VPID capability to L1

2015-10-14 Thread Wanpeng Li
L2's vCPUs not sched in/out on L1. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2a54cc7..0b558ae 100644 --- a/arch/x86/kvm/vmx.c +++ b/ar

[PATCH v3 4/5] KVM: nVMX: nested VPID emulation

2015-10-14 Thread Wanpeng Li
nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Reviewed-by: Jan Kiszka Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 39 --- 1 file changed, 32 insertions(+), 7 deletions(-) diff

[PATCH v3 3/5] KVM: nVMX: emulate the INVVPID instruction

2015-10-14 Thread Wanpeng Li
Add the INVVPID instruction emulation. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 61 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm

[PATCH v3 2/5] KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid

2015-10-14 Thread Wanpeng Li
Introduce __vmx_flush_tlb() to handle specific vpid. It will be used by later patches, note that the "all context" variant can be mapped to vpid_sync_vcpu_single with vpid02 as the argument (a nice side effect of vpid02 design). Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li ---

[PATCH v3 1/5] KVM: VMX: adjust interface to allocate/free_vpid

2015-10-14 Thread Wanpeng Li
Adjust allocate/free_vid so that they can be reused for the nested vpid. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c5c2283

[PATCH v3 0/5] KVM: nVMX: nested VPID emulation

2015-10-14 Thread Wanpeng Li
2.3300 5.6 2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Wanpeng Li (5): KVM: VMX: adjust interface to allocate/free_vpid KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid KVM: nVMX: emulate the INVVPID instruction K

Re: [PATCH v2 5/5] KVM: nVMX: expose VPID capability to L1

2015-10-13 Thread Wanpeng Li
On 10/13/15 10:44 PM, Paolo Bonzini wrote: On 08/10/2015 07:57, Wanpeng Li wrote: Expose VPID capability to L1. For nested guests, we don't do anything specific for single context invalidation. Hence, only advertise support for global context invalidation. The major benefit of nested

Re: [PATCH v2] KVM: nVMX: expose VPID capability to L1

2015-10-08 Thread Wanpeng Li
On 9/29/15 6:39 PM, Paolo Bonzini wrote: On 29/09/2015 04:55, Wanpeng Li wrote: Expose VPID capability to L1. Signed-off-by: Wanpeng Li --- v1 -> v2: * set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT Thanks. I've checked more thoroughly your implementation against the SDM now, and the

[PATCH v2 2/5] KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid

2015-10-08 Thread Wanpeng Li
Introduce __vmx_flush_tlb() to handle specific vpid. It will be used by later patches, note that the "all context" variant can be mapped to vpid_sync_vcpu_single with vpid02 as the argument (a nice side effect of vpid02 design). Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li ---

[PATCH v2 0/5] KVM: nVMX: nested VPID emulation

2015-10-08 Thread Wanpeng Li
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw - - -- -- -- -- -- --- --- kernelLinux 3.5.0-1 1.2200 1.3700 1.4500 4.7800 2.3300 5.6 2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla

[PATCH v2 1/5] KVM: VMX: adjust interface to allocate/free_vpid

2015-10-08 Thread Wanpeng Li
Adjust allocate/free_vid so that they can be reused for the nested vpid. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 6407674

[PATCH v2 3/5] KVM: nVMX: emulate the INVVPID instruction

2015-10-08 Thread Wanpeng Li
Add the INVVPID instruction emulation. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/include/asm/vmx.h | 3 +++ arch/x86/kvm/vmx.c | 49 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm

[PATCH v2 4/5] KVM: nVMX: nested VPID emulation

2015-10-08 Thread Wanpeng Li
nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Reviewed-by: Jan Kiszka Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 39 --- 1 file changed, 32 insertions(+), 7 deletions(-) diff

[PATCH v2 5/5] KVM: nVMX: expose VPID capability to L1

2015-10-08 Thread Wanpeng Li
L2's vCPUs not sched in/out on L1. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 31d272e..22b4dc7 100644 ---

Re: [PATCH v2] KVM: nVMX: expose VPID capability to L1

2015-09-29 Thread Wanpeng Li
On 9/29/15 6:39 PM, Paolo Bonzini wrote: On 29/09/2015 04:55, Wanpeng Li wrote: Expose VPID capability to L1. Signed-off-by: Wanpeng Li --- v1 -> v2: * set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT Thanks. I've checked more thoroughly your implementation against the SDM now, and the

[PATCH v2] KVM: nVMX: expose VPID capability to L1

2015-09-29 Thread Wanpeng Li
Expose VPID capability to L1. Signed-off-by: Wanpeng Li --- v1 -> v2: * set only VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT arch/x86/kvm/vmx.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 75f3ee0..c4ea

Re: [PATCH] KVM: nVMX: expose VPID capability to L1

2015-09-28 Thread Wanpeng Li
On 9/28/15 8:05 PM, Paolo Bonzini wrote: On 24/09/2015 08:51, Wanpeng Li wrote: /* * For nested guests, we don't do anything specific * for single context invalidation. Hence, only advertise * support for global co

Re: [PATCH 1/2] KVM: introduce __vmx_flush_tlb to handle specific vpid

2015-09-24 Thread Wanpeng Li
On 9/25/15 12:12 AM, Bandan Das wrote: Wanpeng Li writes: Introduce __vmx_flush_tlb() to handle specific vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm

[PATCH] KVM: nVMX: expose VPID capability to L1

2015-09-24 Thread Wanpeng Li
Expose VPID capability to L1. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f9219ad..866045c 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH 1/2] KVM: introduce __vmx_flush_tlb to handle specific vpid

2015-09-23 Thread Wanpeng Li
Introduce __vmx_flush_tlb() to handle specific vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 794c529..7188c5e 100644 --- a/arch/x86/kvm/vmx.c +++ b

Re: [PATCH] KVM: nVMX: emulate the INVVPID instruction

2015-09-23 Thread Wanpeng Li
On 9/23/15 4:39 PM, Paolo Bonzini wrote: On 23/09/2015 09:59, Wanpeng Li wrote: Add the INVVPID instruction emulation. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 23 ++- 2 files changed, 23

[PATCH 2/2] KVM: nVMX: fix flush vpid01 during nested vmentry/vmexit

2015-09-23 Thread Wanpeng Li
vpid_sync_vcpu_single() still handles vpid01 during nested vmentry/vmexit since vmx->vpid is used for invvpid. This patch fix it by specific the vpid02 through __vmx_flush_tlb() to flush the right vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 4 ++-- 1 file changed, 2 inserti

[PATCH] KVM: nVMX: emulate the INVVPID instruction

2015-09-23 Thread Wanpeng Li
Add the INVVPID instruction emulation. Reviewed-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 23 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include

Re: [edk2] KVM: MTRR: fix memory type handling if MTRR is completely disabled

2015-09-20 Thread Wanpeng Li
On 9/21/15 10:51 AM, Xiao Guangrong wrote: Thanks for your report and analysis, Janusz! On 09/19/2015 01:48 AM, Janusz wrote: W dniu 18.09.2015 o 12:07, Laszlo Ersek pisze: On 09/18/15 11:37, Janusz wrote: Hello, I am writting about this patch that was posted by Xiao: http://www.spinics.net

Re: [PATCH] KVM: vmx: fix VPID is 0000H in non-root operation

2015-09-16 Thread Wanpeng Li
eused while the value of Looks good to me. Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH] KVM: add halt_attempted_poll to VCPU stats

2015-09-16 Thread Wanpeng Li
ems to work (goes back to 1 cpu). The proper way might be to feedback the result of the interrupt dequeue into the heuristics. Don't know yet how to handle that properly. If this can be reproduced on x86 platform? Regards, Wanpeng Li -- To unsubscribe from this list: send the line "unsubsc

[PATCH] KVM: vmx: fix VPID is 0000H in non-root operation

2015-09-16 Thread Wanpeng Li
eserve H for VMX root operation. This patch fix it by reintroducing reserve H for VMX root operation. Reported-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9ff6a3f..

Re: [PATCH v5 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-16 Thread Wanpeng Li
On 9/16/15 6:04 PM, Paolo Bonzini wrote: On 16/09/2015 11:30, Wanpeng Li wrote: Enhance allocate/free_vid to handle shadow vpid. Adjusting the commit message: KVM: nVMX: adjust interface to allocate/free_vpid Adjust allocate/free_vid so that they can be reused for the nested

[PATCH v5 0/2] KVM: nested VPID emulation

2015-09-16 Thread Wanpeng Li
0-1 1.2200 1.3700 1.4500 4.7800 2.3300 5.6 2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Wanpeng Li (2): KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid KVM: nVMX: nested VPID emulation arch/x

[PATCH v5 2/2] KVM: nVMX: nested VPID emulation

2015-09-16 Thread Wanpeng Li
2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Reviewed-by: Jan Kiszka Suggested-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 37 +++-- 1 file changed, 31 insertions(+), 6 deletions

[PATCH v5 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-16 Thread Wanpeng Li
Enhance allocate/free_vid to handle shadow vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9ff6a3f..f8d704d 100644 --- a/arch/x86/kvm/vmx.c +++ b

Re: [PATCH v4 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-16 Thread Wanpeng Li
On 9/16/15 5:11 PM, Jan Kiszka wrote: On 2015-09-16 09:19, Wanpeng Li wrote: Enhance allocate/free_vid to handle shadow vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/vmx.c b

[PATCH v4 0/2] KVM: nested VPID emulation

2015-09-16 Thread Wanpeng Li
.6 2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Wanpeng Li (2): KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid KVM: nVMX: nested VPID emulation arch/x86/kvm/vmx.c | 60 ++--

[PATCH v4 2/2] KVM: nVMX: nested VPID emulation

2015-09-16 Thread Wanpeng Li
2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Reviewed-by: Jan Kiszka Suggested-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 37 +++-- 1 file changed, 31 insertions(+), 6 deletions

[PATCH v4 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-16 Thread Wanpeng Li
Enhance allocate/free_vid to handle shadow vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9ff6a3f..c5222b8 100644 --- a/arch/x86/kvm/vmx.c +++ b

Re: [PATCH v3 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-15 Thread Wanpeng Li
On 9/16/15 2:42 PM, Jan Kiszka wrote: On 2015-09-16 05:51, Wanpeng Li wrote: Enhance allocate/free_vid to handle shadow vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b

Re: [PATCH] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
On 9/16/15 1:20 PM, Jan Kiszka wrote: On 2015-09-16 04:36, Wanpeng Li wrote: On 9/16/15 1:32 AM, Jan Kiszka wrote: On 2015-09-15 12:14, Wanpeng Li wrote: On 9/14/15 10:54 PM, Jan Kiszka wrote: Last but not least: the guest can now easily exhaust the host's pool of vpid by simply spa

Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-15 Thread Wanpeng Li
On 9/15/15 8:54 PM, Paolo Bonzini wrote: On 15/09/2015 12:30, Wanpeng Li wrote: + if (!nested) { + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS); + if (vpid < VMX_NR_VPIDS) { vmx->vpid = vpid; __set_bi

[PATCH v3 0/2] KVM: nested VPID emulation

2015-09-15 Thread Wanpeng Li
12.7 12.9 3.49000 7.46000 vanilla Wanpeng Li (2): KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid KVM: nVMX: nested VPID emulation arch/x86/kvm/vmx.c | 61 +- 1 file changed, 42 insertions(+), 19 deletions(-) -- 1

[PATCH v3 2/2] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Suggested-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 37 +++-- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm

[PATCH v3 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-15 Thread Wanpeng Li
Enhance allocate/free_vid to handle shadow vpid. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9ff6a3f..4956081 100644 --- a/arch/x86/kvm/vmx.c +++ b

Re: [PATCH] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
On 9/16/15 1:32 AM, Jan Kiszka wrote: On 2015-09-15 12:14, Wanpeng Li wrote: On 9/14/15 10:54 PM, Jan Kiszka wrote: Last but not least: the guest can now easily exhaust the host's pool of vpid by simply spawning plenty of VCPUs for L2, no? Is this acceptable or should there be some limi

Re: Questions about KVM TSC trapping

2015-09-15 Thread Wanpeng Li
On 9/16/15 6:00 AM, David Matlack wrote: On Tue, Sep 15, 2015 at 12:04 AM, Oliver Yang wrote: Hi Guys, I found below patch for KVM TSC trapping / migration support, https://lkml.org/lkml/2011/1/6/90 It seemed the patch were not merged in Linux mainline. So I have 3 questions here, 1. Can

[PATCH v2 0/2] KVM: nested VPID emulation

2015-09-15 Thread Wanpeng Li
xsw - - -- -- -- -- -- --- --- kernelLinux 3.5.0-1 1.2200 1.3700 1.4500 4.7800 2.3300 5.6 2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Wanpeng Li (2): KVM: nVMX: enhance allocate/free_vpid

[PATCH v2 2/2] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
2.88000 nested VPID kernelLinux 3.5.0-1 1.2600 1.4300 1.5600 12.7 12.9 3.49000 7.46000 vanilla Suggested-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 25 ++--- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch

[PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid

2015-09-15 Thread Wanpeng Li
Enhance allocate/free_vid to handle shadow vpid. Suggested-by: Wincy Van Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 33 +++-- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index da1590e..bd07d88 100644

Re: [PATCH] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
On 9/15/15 12:08 AM, Bandan Das wrote: Wanpeng Li writes: VPID is used to tag address space and avoid a TLB flush. Currently L0 use the same VPID to run L1 and all its guests. KVM flushes VPID when switching between L1 and L2. This patch advertises VPID to the L1 hypervisor, then address

Re: [PATCH] KVM: nVMX: nested VPID emulation

2015-09-15 Thread Wanpeng Li
On 9/14/15 10:54 PM, Jan Kiszka wrote: On 2015-09-14 14:52, Wanpeng Li wrote: VPID is used to tag address space and avoid a TLB flush. Currently L0 use the same VPID to run L1 and all its guests. KVM flushes VPID when switching between L1 and L2. This patch advertises VPID to the L1 hypervisor

[PATCH] KVM: nVMX: nested VPID emulation

2015-09-14 Thread Wanpeng Li
flush when swithing between L1 and L2. This patch gets ~3x performance improvement for lmbench 8p/64k ctxsw. Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 39 --- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86

[PATCH] KVM: fix polling for guest halt continued even if disable it

2015-09-14 Thread Wanpeng Li
ng when polling is disabled. Reported-by: Christian Borntraeger Signed-off-by: Wanpeng Li --- virt/kvm/kvm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 4662a88..f756cac0 100644 --- a/virt/kvm/kvm_main.c +++ b/

Re: [PATCH v7 0/3] KVM: Dynamic Halt-Polling

2015-09-14 Thread Wanpeng Li
On 9/10/15 3:13 PM, Christian Borntraeger wrote: Am 10.09.2015 um 03:55 schrieb Wanpeng Li: On 9/9/15 9:39 PM, Christian Borntraeger wrote: Am 03.09.2015 um 16:07 schrieb Wanpeng Li: v6 -> v7: * explicit signal (set a bool) * fix the tracepoint v5 -> v6: * fix wait_ns and p

Re: [PATCH v7 0/3] KVM: Dynamic Halt-Polling

2015-09-09 Thread Wanpeng Li
On 9/9/15 9:39 PM, Christian Borntraeger wrote: Am 03.09.2015 um 16:07 schrieb Wanpeng Li: v6 -> v7: * explicit signal (set a bool) * fix the tracepoint v5 -> v6: * fix wait_ns and poll_ns v4 -> v5: * set base case 10us and max poll time 500us * handle short/long halt,

Re: [PATCH v7 2/3] KVM: dynamic halt-polling

2015-09-06 Thread Wanpeng Li
On 9/6/15 10:32 PM, Paolo Bonzini wrote: On 05/09/2015 00:38, Wanpeng Li wrote: @@ -1940,11 +1975,16 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) * arrives. */ if (kvm_vcpu_check_block(vcpu) < 0) { +polled = t

Re: [PATCH v7 2/3] KVM: dynamic halt-polling

2015-09-04 Thread Wanpeng Li
Hi Paolo, On 9/3/15 10:07 PM, Wanpeng Li wrote: [...] static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu) { if (kvm_arch_vcpu_runnable(vcpu)) { @@ -1928,7 +1962,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) { ktime_t start, cur; DEFINE_WAIT(wait); - bool

Re: [PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-03 Thread Wanpeng Li
On 9/4/15 9:16 AM, Wanpeng Li wrote: [...] + static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu) { if (kvm_arch_vcpu_runnable(vcpu)) { @@ -1929,6 +1963,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) ktime_t start, cur; DEFINE_WAIT(wait); bool waited

Re: [PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-03 Thread Wanpeng Li
On 9/3/15 2:09 AM, David Matlack wrote: On Wed, Sep 2, 2015 at 12:29 AM, Wanpeng Li wrote: There is a downside of always-poll since poll is still happened for idle vCPUs which can waste cpu usage. This patch adds the ability to adjust halt_poll_ns dynamically, to grow halt_poll_ns when shot

Re: [PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-03 Thread Wanpeng Li
On 9/4/15 12:07 AM, David Matlack wrote: On Thu, Sep 3, 2015 at 2:23 AM, Wanpeng Li wrote: How about something like: @@ -1941,10 +1976,14 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) */ if (kvm_vcpu_check_block(vcpu) < 0) { ++v

[PATCH v7 3/3] KVM: trace kvm_halt_poll_ns grow/shrink

2015-09-03 Thread Wanpeng Li
Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li --- include/trace/events/kvm.h | 30 ++ virt/kvm/kvm_main.c| 8 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/trace/events

[PATCH v7 2/3] KVM: dynamic halt-polling

2015-09-03 Thread Wanpeng Li
ggested-by: David Matlack Signed-off-by: Wanpeng Li --- virt/kvm/kvm_main.c | 63 + 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c06e57c..d5e07e9 100644 --- a/virt/kvm/kvm_main.c +++

[PATCH v7 1/3] KVM: make halt_poll_ns per-vCPU

2015-09-03 Thread Wanpeng Li
Change halt_poll_ns into per-VCPU variable, seeded from module parameter, to allow greater flexibility. Signed-off-by: Wanpeng Li --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b

[PATCH v7 0/3] KVM: Dynamic Halt-Polling

2015-09-03 Thread Wanpeng Li
sing the dynamic-poll. The savings should be even higher for higher frequency ticks. Wanpeng Li (3): KVM: make halt_poll_ns per-vCPU KVM: dynamic halt-polling KVM: trace kvm_halt_poll_ns grow/shrink include/linux/kvm_host.h | 1 + include/trace/eve

Re: [PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-03 Thread Wanpeng Li
you want, you can leave this if() out and save some indentation. Then we will miss the tracepoint. Regards, Wanpeng Li + if (block_ns <= vcpu->halt_poll_ns) + ; + /* we had a long block, shrink polling */ + else if (vcpu->

Re: [PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-03 Thread Wanpeng Li
us to loop calling kvm_vcpu_block and starve the waiting task (at least until need_resched()), which would break the "only hog the cpu when idle" aspect of halt-polling. That's definitely a bug, yes. Ok, I will send out v7 to fix this in this sunday since there is vacation in my country

Re: [PATCH v6 3/3] KVM: trace kvm_halt_poll_ns grow/shrink

2015-09-02 Thread Wanpeng Li
On 9/3/15 2:09 AM, David Matlack wrote: On Wed, Sep 2, 2015 at 12:42 AM, Wanpeng Li wrote: Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li --- include/trace/events/kvm.h | 30 ++ virt/kvm/kvm_main.c| 8

[PATCH v6 3/3] KVM: trace kvm_halt_poll_ns grow/shrink

2015-09-02 Thread Wanpeng Li
Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li --- include/trace/events/kvm.h | 30 ++ virt/kvm/kvm_main.c| 8 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/trace/events

[PATCH v6 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-02 Thread Wanpeng Li
Suggested-by: David Matlack Signed-off-by: Wanpeng Li --- virt/kvm/kvm_main.c | 61 ++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c06e57c..3cff02f 100644 --- a/virt/kvm/kvm_ma

[PATCH v6 0/3] KVM: Dynamic Halt-Polling

2015-09-02 Thread Wanpeng Li
s. (250HZ) means the guest was ticking at 250HZ. The big win is with ticking operating systems. Running the linux guest with nohz=off (and HZ=250), we save 3.4%~12.8% CPUs/second and get close to no-polling overhead levels by using the dynamic-poll. The savings should be even higher for higher fre

[PATCH v6 1/3] KVM: make halt_poll_ns per-vCPU

2015-09-02 Thread Wanpeng Li
Change halt_poll_ns into per-vCPU variable, seeded from module parameter, to allow greater flexibility. Signed-off-by: Wanpeng Li --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b

[PATCH v5 0/3] KVM: Dynamic Halt-Polling

2015-09-01 Thread Wanpeng Li
The savings should be even higher for higher frequency ticks. Wanpeng Li (3): KVM: make halt_poll_ns per-VCPU KVM: dynamic halt_poll_ns adjustment KVM: trace kvm_halt_poll_ns grow/shrink include/linux/kvm_host.h | 1 + include/trac

[PATCH v5 2/3] KVM: dynamic halt_poll_ns adjustment

2015-09-01 Thread Wanpeng Li
frequency ticks. Suggested-by: David Matlack Signed-off-by: Wanpeng Li --- virt/kvm/kvm_main.c | 60 ++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c06e57c..2206cb0 10

[PATCH v5 3/3] KVM: trace kvm_halt_poll_ns grow/shrink

2015-09-01 Thread Wanpeng Li
Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li --- include/trace/events/kvm.h | 30 ++ virt/kvm/kvm_main.c| 8 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/trace/events

[PATCH v5 1/3] KVM: make halt_poll_ns per-VCPU

2015-09-01 Thread Wanpeng Li
Change halt_poll_ns into per-vCPU variable, seeded from module parameter, to allow greater flexibility. Signed-off-by: Wanpeng Li --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-09-01 Thread Wanpeng Li
On 9/2/15 9:49 AM, David Matlack wrote: On Tue, Sep 1, 2015 at 5:29 PM, Wanpeng Li wrote: On 9/2/15 7:24 AM, David Matlack wrote: On Tue, Sep 1, 2015 at 3:58 PM, Wanpeng Li wrote: Why this can happen? Ah, probably because I'm missing 9c8fd1ba220 (KVM: x86: optimize delivery o

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-09-01 Thread Wanpeng Li
On 9/2/15 7:24 AM, David Matlack wrote: On Tue, Sep 1, 2015 at 3:58 PM, Wanpeng Li wrote: On 9/2/15 6:34 AM, David Matlack wrote: On Tue, Sep 1, 2015 at 3:30 PM, Wanpeng Li wrote: On 9/2/15 5:45 AM, David Matlack wrote: On Thu, Aug 27, 2015 at 2:47 AM, Wanpeng Li wrote: v3 ->

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-09-01 Thread Wanpeng Li
On 9/2/15 6:34 AM, David Matlack wrote: On Tue, Sep 1, 2015 at 3:30 PM, Wanpeng Li wrote: On 9/2/15 5:45 AM, David Matlack wrote: On Thu, Aug 27, 2015 at 2:47 AM, Wanpeng Li wrote: v3 -> v4: * bring back grow vcpu->halt_poll_ns when interrupt arrives and shrinks when idle V

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-09-01 Thread Wanpeng Li
On 9/2/15 5:45 AM, David Matlack wrote: On Thu, Aug 27, 2015 at 2:47 AM, Wanpeng Li wrote: v3 -> v4: * bring back grow vcpu->halt_poll_ns when interrupt arrives and shrinks when idle VCPU is detected v2 -> v3: * grow/shrink vcpu->halt_poll_ns by *halt_pol

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-08-31 Thread Wanpeng Li
On 8/31/15 3:44 PM, Wanpeng Li wrote: On 8/30/15 6:26 AM, Peter Kieser wrote: Thanks, Wanpeng. Applied this to Linux 3.18 and seeing much higher CPU usage (200%) for qemu 2.4.0 process on a Windows 10 x64 guest. qemu parameters: Interesting. I test this against latest kvm tree and stable qemu

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-08-31 Thread Wanpeng Li
% | +-++---+ Regards, Wanpeng Li qemu-system-x86_64 -enable-kvm -name arwan-20150704 -S -machine pc-q35-2.2,accel=kvm,usb=off -cpu Haswell,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1000 -m 8192 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 7c2fc02d-2798-4fc9-ad04-db5f1af92723

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-08-29 Thread Wanpeng Li
On 8/30/15 8:13 AM, Peter Kieser wrote: On 2015-08-29 4:55 PM, Wanpeng Li wrote: On 8/30/15 6:26 AM, Peter Kieser wrote: Thanks, Wanpeng. Applied this to Linux 3.18 and seeing much higher CPU usage (200%) for qemu 2.4.0 process on a Windows 10 x64 guest. qemu parameters: Thanks for the

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-08-29 Thread Wanpeng Li
applied on your 3.18? Btw, do you test the linux guest? Regards, Wanpeng Li qemu-system-x86_64 -enable-kvm -name arwan-20150704 -S -machine pc-q35-2.2,accel=kvm,usb=off -cpu Haswell,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1000 -m 8192 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1

Re: [PATCH v4 0/3] KVM: Dynamic Halt-Polling

2015-08-29 Thread Wanpeng Li
Hi Peter, On 8/30/15 5:18 AM, Peter Kieser wrote: Hi Wanpeng, Do I need to set any module parameters to use your patch, or should halt_poll_ns automatically tune with just your patch series applied? You don't need any module parameters. Regards, Wanpeng Li Thanks. On 2015-08-27 2:

Re: [PATCH v2 2/3] KVM: dynamic halt_poll_ns adjustment

2015-08-27 Thread Wanpeng Li
On 8/28/15 12:25 AM, David Matlack wrote: On Thu, Aug 27, 2015 at 2:59 AM, Wanpeng Li wrote: Hi David, On 8/26/15 1:19 AM, David Matlack wrote: Thanks for writing v2, Wanpeng. On Mon, Aug 24, 2015 at 11:35 PM, Wanpeng Li wrote: There is a downside of halt_poll_ns since poll is still happen

  1   2   3   4   >