Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp415982lqp; Wed, 22 May 2024 08:16:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGGVIitCcoTFAhjsHu1ljsOKxXsNGXOrpplSfoP6ScPjYfOGEpHIocoeMnrNRidCYOF2u5ZvbFE5IT8zoTz4z05y23CP7EonVzJfG0eQ== X-Google-Smtp-Source: AGHT+IGQyUI6f5vLfuRDKqdD1/rB8ML287rsU/SyqLZDl+RR/pj7hnyooI2SgZou5cBSfxNE6yII X-Received: by 2002:a50:9b08:0:b0:574:ebf4:f786 with SMTP id 4fb4d7f45d1cf-57831140502mr2014478a12.16.1716390992960; Wed, 22 May 2024 08:16:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716390992; cv=pass; d=google.com; s=arc-20160816; b=HM2B31lPQtcu1EKT7RQXUsx39DiU/glXCHEQGWHmZMjyKXQDcrilUrqN86S3RQc+On vkM7jh+eqW2aELDIeix8jW4LcTAF8iQ2VUinfUBOIoKBwYvFnkxCec4FWbzXbiUDkKMc AujmKQVhzZJqwZzuj8idyw995yoLDkxgUzCDrueTRfgtq8604rCdig0WO7X3V5rotZcB yN2EuqK+dlJiPS+LI+DtjFIEqVI3N2f2Vjy/FuKcakZob4mWPo+54RDt+anbzbST064q BrqODATXmXwIq6Ab40xMlN2/GG1ACm59NyWnVCW9OaczFyjbrg9P/HS6VaqegvVhb/kL 3Evw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qPx5VBeAtVusPub5h8jjoS2Zp/k7LiSDo3T23EUz3Cc=; fh=j3GB/m7NbW+xI2Q6rSwMt0ZZ5txZtE2iyXMuuS2qupY=; b=orKuxqMI5PEYv2U+2+1rCcQPOxY4JIVDDn0VCyj2FSvdIjQsm8WQL9r5iK36K+uczh OHM5JV6Rt3HXqzG76qnPymDIsAOaZyYZ3jsYI77+wXQR92mHbtqh4HveM6XuYa97HrHG UYwEN9zhtL6RFBrfeqEq8G2ddbsWvLCBuTbYf0Bh+HhYApoiLAPC6xjqJ2JLDzU74fPw I0/ImrnVuFpe7smQi2w7UXjmOLa7FsW+E43lYlXTrwyX98f83DCqD4FF4dB3hCzUfsac LzYuEt36E+onj3D5VarOIKVfhF5mCkfiSs+LQ4XPELmfoemG6fjHJ8/FjLpW7CR2/7nY 56PA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="MR8HfGt/"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-186418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c3272b7si16009141a12.398.2024.05.22.08.16.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 08:16:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="MR8HfGt/"; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-186418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AC1511F214BE for ; Wed, 22 May 2024 15:16:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9998677116; Wed, 22 May 2024 15:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MR8HfGt/" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEC5A2B9CD for ; Wed, 22 May 2024 15:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716390982; cv=none; b=P0rJ9iAqtSW38wow7AQc2+GaRW9EKQ0Hm51Jlp/iWgpaaCqy6xRtsVyHqyq+K9TuaX9WzUwEUyD2nK1Rvqky5NrIHJvdSRobndl+8psk9dv8F5KvtpN9mGzZ+d+hQ52F6qGdZZzlGf+XV53eaPFo+Q6+i+EV5oqIKbRvmrjTjFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716390982; c=relaxed/simple; bh=LBsuxRIt25iSTct1CaOFF4pb8q9+nLplzWcPNkULdk8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p5YhSkKWqejiee7ekEq0w6WzHFDzfu3lzmJKx11i1PMD9gzUzIslBqv2onzQ7A7gB/842jXc0Jrib0LSDUMWv1ABPeZLJLENWGpikZtIWQ4n/QB05S6Gie5oO66LG1qYEREiTU93ei6MGy9usbrgdt9/zP2b2cMmXgTVc/eZ+Hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MR8HfGt/; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: seanjc@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716390977; 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=qPx5VBeAtVusPub5h8jjoS2Zp/k7LiSDo3T23EUz3Cc=; b=MR8HfGt/7NWj1OeZKFuwxnVF9+ndS7xCoaOY+r1JI2bWBzf2MynLiEMDjC1DrcozAH8hei TUnFiYL5Pyj+E10/+shwWi4h/9LVvu0Mc6mkr1yRH6n++3msAFiuDQVzo86zkrGkaVb0hH 6NbyKC1AGLafKPP8z0hv7d6a9IuqBaQ= X-Envelope-To: maz@kernel.org X-Envelope-To: zhaotianrui@loongson.cn X-Envelope-To: maobibo@loongson.cn X-Envelope-To: chenhuacai@kernel.org X-Envelope-To: mpe@ellerman.id.au X-Envelope-To: anup@brainfault.org X-Envelope-To: paul.walmsley@sifive.com X-Envelope-To: palmer@dabbelt.com X-Envelope-To: aou@eecs.berkeley.edu X-Envelope-To: borntraeger@linux.ibm.com X-Envelope-To: frankja@linux.ibm.com X-Envelope-To: imbrenda@linux.ibm.com X-Envelope-To: pbonzini@redhat.com X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: kvmarm@lists.linux.dev X-Envelope-To: kvm@vger.kernel.org X-Envelope-To: loongarch@lists.linux.dev X-Envelope-To: linux-mips@vger.kernel.org X-Envelope-To: linuxppc-dev@lists.ozlabs.org X-Envelope-To: kvm-riscv@lists.infradead.org X-Envelope-To: linux-riscv@lists.infradead.org X-Envelope-To: linux-kernel@vger.kernel.org Date: Wed, 22 May 2024 08:16:07 -0700 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 v2 1/6] KVM: Add a flag to track if a loaded vCPU is scheduled out Message-ID: References: <20240522014013.1672962-1-seanjc@google.com> <20240522014013.1672962-2-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240522014013.1672962-2-seanjc@google.com> X-Migadu-Flow: FLOW_OUT On Tue, May 21, 2024 at 06:40:08PM -0700, Sean Christopherson wrote: > Add a kvm_vcpu.scheduled_out flag to track if a vCPU is in the process of > being scheduled out (vCPU put path), or if the vCPU is being reloaded > after being scheduled out (vCPU load path). In the short term, this will > allow dropping kvm_arch_sched_in(), as arch code can query scheduled_out > during kvm_arch_vcpu_load(). > > Longer term, scheduled_out opens up other potential optimizations, without > creating subtle/brittle dependencies. E.g. it allows KVM to keep guest > state (that is managed via kvm_arch_vcpu_{load,put}()) loaded across > kvm_sched_{out,in}(), if KVM knows the state isn't accessed by the host > kernel. Forcing arch code to coordinate between kvm_arch_sched_{in,out}() > and kvm_arch_vcpu_{load,put}() is awkward, not reusable, and relies on the > exact ordering of calls into arch code. > > Adding scheduled_out also obviates the need for a kvm_arch_sched_out() > hook, e.g. if arch code needs to do something novel when putting vCPU > state. > > And even if KVM never uses scheduled_out for anything beyond dropping > kvm_arch_sched_in(), just being able to remove all of the arch stubs makes > it worth adding the flag. > > Link: https://lore.kernel.org/all/20240430224431.490139-1-seanjc@google.com > Cc: Oliver Upton > Signed-off-by: Sean Christopherson Reviewed-by: Oliver Upton -- Thanks, Oliver