Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1656190lqe; Mon, 8 Apr 2024 16:20:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWAgSP3x+V0dd7opNV19N1aRiDHRiipVqqS87/HvElhNwyQBO9GesdK4lfen7WZHbMjotP0hGhGFDbGXnh4sMrq5U1tp2n0A6sCQlx5g== X-Google-Smtp-Source: AGHT+IG8ZVmxUA5zmzHP5IK6d3Pc30W/mo47qXFs9prCWFSI50riwVhpJZX/4s3LJrAQCjPFuu5+ X-Received: by 2002:a17:906:80c:b0:a4e:5540:7c0c with SMTP id e12-20020a170906080c00b00a4e55407c0cmr5121614ejd.70.1712618424211; Mon, 08 Apr 2024 16:20:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712618424; cv=pass; d=google.com; s=arc-20160816; b=SuTlNMIUnbU9aZUjGueJi4SzzT8SIrAM3jhufZgfBDabFeUHlYde8IfmjOpnui2zEF aJv68hM7YQ+ddTtrLcOmPonrxumLtJzegEvtXyEH5PLAOOE2uDQckZymK1E0gnRAug3B jmU5PYt0ivZbB2yXZXMFONeYPQDyzP/oFkoWYVJj5xswHqe3v5JDC/GZsM6s9pvRzAvj 7BYyd4jMxjK02qsmQDda3mxVO7uJBQWJqxUf8EoU5OGzd9y8XgN38Ihr3f0GlOeUi8Ur lMyB4BOGaf7SWBgRdIOrhGpy5jdn2+2pPXiQjRoZozN4LBQWxDDhiK1VenyyzbIN4Pbv ItoA== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=NGWHaR+3TgUwHw0nVyDwCIZGjQoolEYhmkCN07H267w=; fh=HNz1tHdKILwnXG2O+jlWrGRkzfX2nGaOnCTyzCbWmKY=; b=JJ9YZm1KNFAwyXFJRtQ41TvYsOM0iT/7Ee8L3Tn1FcwTtSIgo2WmTDulMpNhfYMRCc 08f3V1L2BSi369RywRDoBA8CSajEuwPEYT8fxtQ0wm9x4wVgl0LNyOAt994WM/RR1aX3 QdNn+CoAKuqzG1ktuOlXTEmfp4tgCSp00ackNGVBbPIn76TBi3uNTwpRtwgJRVi1nk8A YYzaeqAX+aIhIovUyNuLx4VYiorh7+xj4/9Of7GswVdBWI1wY8iz05ziUDD5BV4qRN1t Srpwss6ImBt31z58XeAUivRBSaASqbVC7ID4C/ogKC7RBxAPK7YnwXQHVJgAuQOIAVGk Joiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a5YgRo2y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d23-20020a170906041700b00a51802f94dcsi3943158eja.812.2024.04.08.16.20.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 16:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a5YgRo2y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 EE4301F24C7F for ; Mon, 8 Apr 2024 23:20:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64611146A8C; Mon, 8 Apr 2024 23:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a5YgRo2y" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 858751DA5E; Mon, 8 Apr 2024 23:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712618414; cv=none; b=hKH/FlZmPvy/tMJfvMfXcozybPmLa2OkKQGSA8VgNztM/Y1GIobGrDDMGhDkI3bK+xyTSDK+sUrt7JbETxfYyN0Lg7ehbByg7DCg+3XqJeZs/0gwfulBGAweXGwCkgH9EYBrfjL5KXgoZ6gVM21M9TlUNkqU8SBZ0OVT1oVDSCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712618414; c=relaxed/simple; bh=IfEtQ3E4nR5vHQBjwqTMc8kDx61wvIKdmTWG7x7WHzY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o4Mq69s+nLWuWirVC3idNvbE5aySkBmh7mWej6QnKJNWSQwvrUJ3sZGZZg4PYUBOGaQMnmAKyV2IHaZ3E53jBfkTIhwbTidLTyvA9Gj73uMgyickLDHharB8lHG43a4mNG7gbN/laaiavH8wcHyAESEXm5Pg3P2djQV1tt4IMCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a5YgRo2y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DF53C433C7; Mon, 8 Apr 2024 23:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712618414; bh=IfEtQ3E4nR5vHQBjwqTMc8kDx61wvIKdmTWG7x7WHzY=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=a5YgRo2yr8x98V7V9NszagtKCxGxOsAZWMnB0RbGXRhbn8yfGJFvjL3quCjV6AbiE sDnGU10P5TunaqiS+WaJO84ONfyAI7MSzQ6+1KZvU9sfHQJlihy9llb5iPaAShOD6S zJs8+EoAXu4/wRBZIYlUXVk7LrpRYNov94dhvNhnANDUjKlVBQcdBbMhWNkdRLr6hM I2Ebz915JsAT4hXDxOPrWTwOJMXMz0jHPMkhAVX/uKA6IeHQ3/MjiA3C2tkA0cAimI 5cE009USFsi1FZTV4EJH6A8yEOOO0w5OInDwsKTheDXEGqxAe7Q65YKCJQLFWMvNt+ P7bcmKD9mazQg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F15DFCE118A; Mon, 8 Apr 2024 16:20:13 -0700 (PDT) Date: Mon, 8 Apr 2024 16:20:13 -0700 From: "Paul E. McKenney" To: Sean Christopherson Cc: Marcelo Tosatti , Leonardo Bras , Paolo Bonzini , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: Re: [RFC PATCH v1 0/2] Avoid rcu_core() if CPU just left guest vcpu Message-ID: Reply-To: paulmck@kernel.org References: <414eaf1e-ca22-43f3-8dfa-0a86f5b127f5@paulmck-laptop> <44eb0d36-7454-41e7-9a16-ce92a88e568c@paulmck-laptop> 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: On Mon, Apr 08, 2024 at 04:06:22PM -0700, Sean Christopherson wrote: > On Mon, Apr 08, 2024, Paul E. McKenney wrote: > > On Mon, Apr 08, 2024 at 02:56:29PM -0700, Sean Christopherson wrote: > > > > OK, then we can have difficulties with long-running interrupts hitting > > > > this range of code. It is unfortunately not unheard-of for interrupts > > > > plus trailing softirqs to run for tens of seconds, even minutes. > > > > > > Ah, and if that occurs, *and* KVM is slow to re-enter the guest, then there will > > > be a massive lag before the CPU gets back into a quiescent state. > > > > Exactly! > > ... > > > OK, then is it possible to get some other indication to the > > rcu_sched_clock_irq() function that it has interrupted a guest OS? > > It's certainly possible, but I don't think we want to go down that road. > > Any functionality built on that would be strictly limited to Intel CPUs, because > AFAIK, only Intel VMX has the mode where an IRQ can be handled without enabling > IRQs (which sounds stupid when I write it like that). > > E.g. on AMD SVM, if an IRQ interrupts the guest, KVM literally handles it by > doing: > > local_irq_enable(); > ++vcpu->stat.exits; > local_irq_disable(); > > which means there's no way for KVM to guarantee that the IRQ that leads to > rcu_sched_clock_irq() is the _only_ IRQ that is taken (or that what RCU sees was > even the IRQ that interrupted the guest, though that probably doesn't matter much). > > Orthogonal to RCU, I do think it makes sense to have KVM VMX handle IRQs in its > fastpath for VM-Exit, i.e. handle the IRQ VM-Exit and re-enter the guest without > ever enabling IRQs. But that's purely a KVM optimization, e.g. to avoid useless > work when the host has already done what it needed to do. > > But even then, to make it so RCU could safely skip invoke_rcu_core(), KVM would > need to _guarantee_ re-entry to the guest, and I don't think we want to do that. > E.g. if there is some work that needs to be done on the CPU, re-entering the guest > is a huge waste of cycles, as KVM would need to do some shenanigans to immediately > force a VM-Exit. It'd also require a moderate amount of complexity that I wouldn't > want to maintain, particularly since it'd be Intel-only. Thank you for the analysis! It sounds like the current state, imperfect though it might be, is the best of the known possible worlds at the moment. But should anyone come up with something better, please do not keep it a secret! Thanx, Paul > > Not an emergency, and maybe not even necessary, but it might well be > > one hole that would be good to stop up. > > > > Thanx, Paul