Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3333958ybb; Mon, 13 Apr 2020 06:00:53 -0700 (PDT) X-Google-Smtp-Source: APiQypJAnT8vL4Kl7E6L0rVmFqiK6AIPYt7GP4vzPH/XJ8qUfj/EncZrNoLNoh+9UUlrD+3i5NlC X-Received: by 2002:a50:c20a:: with SMTP id n10mr16350155edf.319.1586782853762; Mon, 13 Apr 2020 06:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586782853; cv=none; d=google.com; s=arc-20160816; b=J0MAoua4+cw83yvlwMI5SoRBB2YeDOkEZXWWkvnRW01ZojrheAaSRwN+i+HQZ3q7NV 4eUdguvn5SJu3SDjaFzE/Bers1OorLITzoNAd8Dt1BJpUf099RITYnJlDADiZMreIPhD j3NK+GiNresdtZDCEYsX/DgB0LbWZNTjMLFK47n89WHJRb6eeyec71tqu5ATn6Bwj1fJ LDJSN8TV7zYpvUUou/SupoaSbZnpdqna7bJFs3bzu4YHrPeGZRKT1M2k8g2kP8F7REja /ThcG505QW6GVm+EFhHiihsPX4klJZttM+NqSxh/G8EJm/mPfkfzy6a3wwlRhp1MYZQD UyqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=byOWZmSdjky6QR591xiPn8gDzdRRx7XHHkbnEBU7v5M=; b=Yr0uhm7twjlWNRHDij1wdBu7fbnupacyKwpsEcIA6oAJ4D1GDmtuEriN+Q1RVFvftT jhk8WPZDQ9iWYQ+3Avz59AnVhKzSVMksPB1sSzumg+SkLZsWQgSUQd6fCbQ37vuv53lW Rd9os2Ykw6HyybwVUSypotqhvCPKvZjvZOMxVGDe2MGXEuwTCWL2M8H/05xWCw6IWWyL o+e/OJNI7NO9U0BSDzsbwLZ3bA2imzB5bt/vocuzmn2n6Y6D/RbFQk9UHMfX9SGGPrCV hRCkwOjGT5zd1B17jbgolOZArbcbGBeHxXoLWgr1zkTUNjxY54YZFOAa/ujW12I3p1N6 UazA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AqkvWJwn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si6550609edt.382.2020.04.13.06.00.26; Mon, 13 Apr 2020 06:00:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=AqkvWJwn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727931AbgDMI4V (ORCPT + 99 others); Mon, 13 Apr 2020 04:56:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:55866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgDMI4U (ORCPT ); Mon, 13 Apr 2020 04:56:20 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46B5920692; Mon, 13 Apr 2020 08:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586768179; bh=GyaHe3+UWAOxENedBfck6FDz0o/OWfUlsXv987iJQNY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AqkvWJwnZMdH4yXR42mVJxFY/122uUYZTeh7KQvVG+ONwnyKmUxp9fytp/Gh8FWWT AI4cBPOoNZVA6p9TtCZIWKf00hKXhEUZB/OdlcC0LTrjyfenJ6jTsMxmZad3EKR4Ht PvT2YKdfwvlUky+dnidjFPIYDuwnuPS8JBFpAneI= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jNut7-002oec-J1; Mon, 13 Apr 2020 09:56:17 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 13 Apr 2020 09:56:17 +0100 From: Marc Zyngier To: Tianjia Zhang 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 Subject: Re: [PATCH] KVM: Optimize kvm_arch_vcpu_ioctl_run function In-Reply-To: <20200413034523.110548-1-tianjia.zhang@linux.alibaba.com> References: <20200413034523.110548-1-tianjia.zhang@linux.alibaba.com> Message-ID: <17097df45c7fe76ee3c09ac180b844d2@kernel.org> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/1.3.10 X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: tianjia.zhang@linux.alibaba.com, 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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Jazz is not dead. It just smells funny...