Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3766259ybb; Mon, 13 Apr 2020 15:07:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKQe8baDabT+cmYEWuh8U8eEdOrJFUv2rmaquOaOUMB62fsxEso26lj0y/7P1juTeNDyQlr X-Received: by 2002:a05:6402:28b:: with SMTP id l11mr12176625edv.156.1586815665834; Mon, 13 Apr 2020 15:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586815665; cv=none; d=google.com; s=arc-20160816; b=pqVJlgZnTBBeIqC13pTUbYcUXOtzBnfKwCjd6l4ZDTIjqY+ABMCmEeWZIBrUFjnW9k Olln8hSTcH1zDxE01B+VfCJX7VEevf5ZvTQdRcjYC4BJqPBjgCqwrlOrsMKW3EbkhMB4 BdSVjkpKOcRsrknWI/xVuc12UGe9z2Z4Bw5f6H2LOfK8qNXB672FNXPuDJVvZ3pfDn6q w2yOUTYNRe2CQWUuiRPMK8cIQ8+X7GCAkdhcXSxxttOWHZuo3y4XzpOIUI1z12YuY9U1 2LIayD20EXjTsuEkZN2vAEKTLppsyMWUMVND/+c2x+eQAzjJm2q9sejcPjr/SIM+uhvd fRlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=BGlF0WfC+RYGs4HgML64SNvpvQq6C8DXB9bnEMyoYbg=; b=dRouj/VMj/DB6wPdN++eH4kzoURR41p+h9FNohI0e26A46HSEeAl1m7dQLTEy4Uf8f 1xifYvHt2aLNZJ2TpW3DhePybzp0yIXGGJVNP+uulJVMeMKE3elDShqPxSlCOPTECvoX dbdO9QTm+/KU5l/7V5MYz98WWd+1SsyiroIWa/VED9sDOW+Az5TZ8oBnBVQ2mn4Ez932 YJRx9hntLRTKOSPlWpqfi+OMNRi4KJGwI6IGTd81Yprh3eFYMn6Ntpo+NKu1CjQHEIvO +bMefIb20v/HC8oxcYHSOSY/qFsAZ93ctv444DmST4TTRC+iaVdRNIxJpiuufs6+Uyxm fgyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si3373239ejb.405.2020.04.13.15.07.22; Mon, 13 Apr 2020 15:07:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbgDMJHq (ORCPT + 99 others); Mon, 13 Apr 2020 05:07:46 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:52908 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728150AbgDMJHp (ORCPT ); Mon, 13 Apr 2020 05:07:45 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R671e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0TvMk-zp_1586768848; Received: from 30.27.118.45(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0TvMk-zp_1586768848) by smtp.aliyun-inc.com(127.0.0.1); Mon, 13 Apr 2020 17:07:29 +0800 Subject: Re: [PATCH] KVM: Optimize kvm_arch_vcpu_ioctl_run function To: Marc Zyngier Cc: pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org References: <20200413034523.110548-1-tianjia.zhang@linux.alibaba.com> <17097df45c7fe76ee3c09ac180b844d2@kernel.org> From: Tianjia Zhang Message-ID: Date: Mon, 13 Apr 2020 17:07:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <17097df45c7fe76ee3c09ac180b844d2@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/13 16:56, Marc Zyngier wrote: > Tianjia, > > On 2020-04-13 04:45, Tianjia Zhang wrote: >> kvm_arch_vcpu_ioctl_run() is only called in the file kvm_main.c, >> where vcpu->run is the kvm_run parameter, so it has been replaced. >> >> Signed-off-by: Tianjia Zhang >> --- >>  arch/x86/kvm/x86.c | 8 ++++---- >>  virt/kvm/arm/arm.c | 2 +- >>  2 files changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 3bf2ecafd027..70e3f4abbd4d 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -8726,18 +8726,18 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >> *vcpu, struct kvm_run *kvm_run) >>          r = -EAGAIN; >>          if (signal_pending(current)) { >>              r = -EINTR; >> -            vcpu->run->exit_reason = KVM_EXIT_INTR; >> +            kvm_run->exit_reason = KVM_EXIT_INTR; >>              ++vcpu->stat.signal_exits; >>          } >>          goto out; >>      } >> >> -    if (vcpu->run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) { >> +    if (kvm_run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) { >>          r = -EINVAL; >>          goto out; >>      } >> >> -    if (vcpu->run->kvm_dirty_regs) { >> +    if (kvm_run->kvm_dirty_regs) { >>          r = sync_regs(vcpu); >>          if (r != 0) >>              goto out; >> @@ -8767,7 +8767,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >> *vcpu, struct kvm_run *kvm_run) >> >>  out: >>      kvm_put_guest_fpu(vcpu); >> -    if (vcpu->run->kvm_valid_regs) >> +    if (kvm_run->kvm_valid_regs) >>          store_regs(vcpu); >>      post_kvm_run_save(vcpu); >>      kvm_sigset_deactivate(vcpu); >> diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c >> index 48d0ec44ad77..ab9d7966a4c8 100644 >> --- a/virt/kvm/arm/arm.c >> +++ b/virt/kvm/arm/arm.c >> @@ -659,7 +659,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, >> struct kvm_run *run) >>          return ret; >> >>      if (run->exit_reason == KVM_EXIT_MMIO) { >> -        ret = kvm_handle_mmio_return(vcpu, vcpu->run); >> +        ret = kvm_handle_mmio_return(vcpu, run); >>          if (ret) >>              return ret; >>      } > > Do you have any number supporting the idea that you are optimizing anything > here? Performance, code size, register pressure or any other relevant > metric? > > Thanks, > >         M. This is only a simplified implementation of the function, the impact on performance and register pressure can be ignored. Thanks, Tianjia