2020-12-10 11:10:05

by Stephen Zhang

[permalink] [raw]
Subject: [PATCH] kvm:vmx:code changes in handle_io() to save some CPU cycles.

code changes in handle_io() to save some CPU cycles.

Signed-off-by: Stephen Zhang <[email protected]>
---
arch/x86/kvm/vmx/vmx.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 47b8357..109bcf64 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -4899,15 +4899,14 @@ static int handle_triple_fault(struct kvm_vcpu *vcpu)
static int handle_io(struct kvm_vcpu *vcpu)
{
unsigned long exit_qualification;
- int size, in, string;
+ int size, in;
unsigned port;

exit_qualification = vmx_get_exit_qual(vcpu);
- string = (exit_qualification & 16) != 0;

++vcpu->stat.io_exits;

- if (string)
+ if (exit_qualification & 16)
return kvm_emulate_instruction(vcpu, 0);

port = exit_qualification >> 16;
--
1.8.3.1


2020-12-13 13:57:18

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH] kvm:vmx:code changes in handle_io() to save some CPU cycles.

On 10/12/20 09:15, Stephen Zhang wrote:
> code changes in handle_io() to save some CPU cycles.
>
> Signed-off-by: Stephen Zhang <[email protected]>
> ---
> arch/x86/kvm/vmx/vmx.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 47b8357..109bcf64 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -4899,15 +4899,14 @@ static int handle_triple_fault(struct kvm_vcpu *vcpu)
> static int handle_io(struct kvm_vcpu *vcpu)
> {
> unsigned long exit_qualification;
> - int size, in, string;
> + int size, in;
> unsigned port;
>
> exit_qualification = vmx_get_exit_qual(vcpu);
> - string = (exit_qualification & 16) != 0;
>
> ++vcpu->stat.io_exits;
>
> - if (string)
> + if (exit_qualification & 16)
> return kvm_emulate_instruction(vcpu, 0);
>
> port = exit_qualification >> 16;
>

I would be very surprised if there's any change in the assembly code
after this patch.

Paolo