Re: [PATCH v2] KVM: Optimize kvm_arch_vcpu_ioctl_run function

From: Cornelia Huck
Date: Thu Apr 16 2020 - 05:00:18 EST


On Thu, 16 Apr 2020 16:45:33 +0800
Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx> wrote:

> On 2020/4/16 16:28, Marc Zyngier wrote:
> > On 2020-04-16 08:03, Vitaly Kuznetsov wrote:
> >> Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx> writes:
> >>
> >>> In earlier versions of kvm, 'kvm_run' is an independent structure
> >>> and is not included in the vcpu structure. At present, 'kvm_run'
> >>> is already included in the vcpu structure, so the parameter
> >>> 'kvm_run' is redundant.
> >>>
> >>> This patch simplify the function definition, removes the extra
> >>> 'kvm_run' parameter, and extract it from the 'kvm_vcpu' structure
> >>> if necessary.
> >>>
> >>> Signed-off-by: Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx>
> >>> ---
> >>>
> >>> v2 change:
> >>> Â remove 'kvm_run' parameter and extract it from 'kvm_vcpu'
> >>>
> >>> Âarch/mips/kvm/mips.cÂÂÂÂÂÂ |Â 3 ++-
> >>> Âarch/powerpc/kvm/powerpc.c |Â 3 ++-
> >>> Âarch/s390/kvm/kvm-s390.cÂÂ |Â 3 ++-
> >>> Âarch/x86/kvm/x86.cÂÂÂÂÂÂÂÂ | 11 ++++++-----
> >>> Âinclude/linux/kvm_host.hÂÂ |Â 2 +-
> >>> Âvirt/kvm/arm/arm.cÂÂÂÂÂÂÂÂ |Â 6 +++---
> >>> Âvirt/kvm/kvm_main.cÂÂÂÂÂÂÂ |Â 2 +-
> >>> Â7 files changed, 17 insertions(+), 13 deletions(-)

> > Overall, there is a large set of cleanups to be done when both the vcpu
> > and the run
> > structures are passed as parameters at the same time. Just grepping the
> > tree for
> > kvm_run is pretty instructive.
> >
> > ÂÂÂÂÂÂÂ M.
>
> Sorry, it's my mistake, I only compiled the x86 platform, I will submit
> patch again.

I think it's completely fine (and even preferable) to do cleanups like
that on top.

[FWIW, I compiled s390 here.]