From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F01D6C4345F for ; Wed, 1 May 2024 00:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LElUEBtaVkBdeyrv5WoTpS/ToNx8/oyIjr4AfXanBrw=; b=ZSFBt8zwleFkgH RLVmpp+5+RuCMJYHn67yKLJAlNPySUVnLTl1akqSrmUKthrrrpnDJMH+dsXMrNyxx8lpNP1fVKnpl W/YSutsPXgytL4N/fer+Awez2shWKhN3F0kUPUYWWwmQ4LgdYzWXtX+jpV2bQFx/7zP9ED1mAcJ/S leH9EJIEpD4PAvUXfHJ17yH0CBXiTpXvlg5Ce7etiJv1I75lF1bLlT6/wDP5u6+aBZ+EXoppGl3kM t2cm3shXtbKo1EPV/3SeE1+whRkWpG9W4/wmWfJyZGYYUNb5MacYqi0PUqCweNEkIOBBkeavyOl54 sdg+67wcVBYG9+e/udAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1xpy-00000008FjS-3Cjf; Wed, 01 May 2024 00:28:42 +0000 Received: from out-180.mta1.migadu.com ([2001:41d0:203:375::b4]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1xpt-00000008Fei-4AQ1 for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2024 00:28:40 +0000 Date: Wed, 1 May 2024 00:28:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714523303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ioXgnZIoOxV6Gom6pZgkz9FqddFwrAkScDhYF7eexw0=; b=jt/Q3cVCB5txoE/zQITpY+KTWb0keYgIpc0qkzhVQFsJAZZR5RjRVVdyLf1AD37xVVVKy5 AjuiDAvL2nLBEHIqEzLFqT7OazbzMr6NRwDmnhYgDnVnteqZKpKfa3eZfPYr7Wncyk+0Tk iJCFdMrcVNqaWoqklmPV1Wqci3CPJlw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sean Christopherson Cc: Marc Zyngier , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/4] KVM: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Message-ID: References: <20240430193157.419425-1-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240430193157.419425-1-seanjc@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_172838_192113_E5169CB9 X-CRM114-Status: GOOD ( 17.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Apr 30, 2024 at 12:31:53PM -0700, Sean Christopherson wrote: > Drop kvm_arch_sched_in() and instead pass a @sched_in boolean to > kvm_arch_vcpu_load(). > > While fiddling with an idea for optimizing state management on AMD CPUs, > I wanted to skip re-saving certain host state when a vCPU is scheduled back > in, as the state (theoretically) shouldn't change for the task while it's > scheduled out. Actually doing that was annoying and unnecessarily brittle > due to having a separate API for the kvm_sched_in() case (the state save > needed to be in kvm_arch_vcpu_load() for the common path). > > E.g. I could have set a "temporary"-ish flag somewhere in kvm_vcpu, but (a) > that's gross and (b) it would rely on the arbitrary ordering between > sched_in() and vcpu_load() staying the same. Another option would be to change the rules around kvm_arch_sched_in() where the callee is expected to load the vCPU context. The default implementation could just call kvm_arch_vcpu_load() directly and the x86 implementation can order things the way it wants before kvm_arch_vcpu_load(). I say this because ... > The only real downside I see is that arm64 and riscv end up having to pass > "false" for their direct usage of kvm_arch_vcpu_load(), and passing boolean > literals isn't ideal. But that can be solved by adding an inner helper that > omits the @sched_in param (I almost added a patch to do that, but I couldn't > convince myself it was necessary). Needing to pass @sched_in for other usage of kvm_arch_vcpu_load() hurts readability, especially when no other architecture besides x86 cares about it. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel