Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp248311lqo; Tue, 7 May 2024 20:22:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuR+T1fe8YxJw4hXZYsRk0q3Uz0LUFSnbOOfDIE3dcQWMP2ixk5cmhLkpqPlagCONgsoPf3bC7GcW0ZSJ1bz/LkSCAgcmGW6/IrWvt7A== X-Google-Smtp-Source: AGHT+IG6ttASSwgbIaGwPzNs1XzgkKtpAw33mwfebqYqDUAY8V39SabmtKiWmXT51u+taKdDU2n0 X-Received: by 2002:ac8:5e06:0:b0:43a:f821:c042 with SMTP id d75a77b69052e-43dbf4e91edmr19290811cf.9.1715138572189; Tue, 07 May 2024 20:22:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715138572; cv=pass; d=google.com; s=arc-20160816; b=KBo1OxLoira7GXMaFKOy54BiAZOK/7n+Wk0IOidPJilm0H5B7ophvibFFNNmJmE/EY iCtGdf7FOe4REBJIPIihFFqfw0ZqAy/b2GKbcEaOWHwkHp1YQDhSeBjrvP4B3rA+kByA ox+JEw227BdDsytvmeKbJ8qRAybrUsBfAWMmqOff4qOEf2am2eiFVW88PKrjzJxm0PB8 b1BNOpa0xaNkr6aa+u+iAnxtenBQJMjdiqwRXKi1P2NutLD/tg+tGb/RGC0w9hVm6tpd L+/oeLPIiLy23N/syHrCGNViso0ADa6w1zubFpck4a45Jdsr1R+2jfOkiZK/jA0+w6ge goqg== 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=uNFqba4sK6kWC9ZmXwM4LeyJx5CE33+ZoxN4cf0ual8=; fh=yDU2+iXlDWgRe/lodS9pc3TCp7MwbWCh+sAsvtQndUU=; b=XBwsPhEJV3Cvajhqr9SQe/GDw8LP5xgLjRBS2tizOv+E0hgv47yg2pb/dwxxi+L1cf 4DoYkzNfDky5ld0h3h/a0qWWZpyzKM5IMHNw7X0z1hO3nu5flp8GqhO6NYeg7qpqYv91 2+84lBYzsH9lLL5Iu82vzjAGE36WOE2cNdMlb9ZBmJmKanTdJJSRuVwgt9Wzr009Cxtr cNS29u9Dc8E21i2W4AYMrgvql5Rdqkd5PMYq0gj+b1AppOpmLi2XkKMVw2MKw/2YQChc IxLEFu6l/qIyZ+GxB3k3QcP+qJ/bum40iMkwH2m+mBNWmda8Dt40lpB+ZQKtE+XI0J+s magA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VmJj1Tjs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s13-20020a05622a1a8d00b00439f676f48csi13425669qtc.355.2024.05.07.20.22.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 20:22:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VmJj1Tjs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172650-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E4A3B1C22345 for ; Wed, 8 May 2024 03:22:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6E4114A8C; Wed, 8 May 2024 03:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VmJj1Tjs" 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 15D2AEAFA; Wed, 8 May 2024 03:22:42 +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=1715138563; cv=none; b=hFvIEYxB/1nS9werXcoZlxHMrF6kS0BhTFyZmwceaJQL+eC9j5BxvAjy+QDboakpL9gpFyh8NeD+a2vj7XyBnpKBsPR/XrEFHE1UdzYu4iHRT0x0B14KVC3PJfW47fLD744M86m9qWCJkDyQBhUwFVYgGVsu94xcrQhfJEYSWX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715138563; c=relaxed/simple; bh=Bo0TxYWQZo+xruw6iLSuspPwh3c8wpp/I0KvRvyz+sg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iLmeMc5NW61YhbkerWCgmXLULejGWalqPlAo5LCAOOuQ2FuB/sf9YknVO67lNXxPnIwkHVaYlIVGYKKwSNxVrI8AkfdDGuP9IgUpidIA3QFyLkC0G8s10Kc8NqIe8b5uWgXPA4acGri3XrpZbJfyHeK6jRKKLC9Ao9A6hcecKew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VmJj1Tjs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9686CC2BBFC; Wed, 8 May 2024 03:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715138562; bh=Bo0TxYWQZo+xruw6iLSuspPwh3c8wpp/I0KvRvyz+sg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=VmJj1Tjs+s+zsKEfPnJBiDbACAQY9Ya+d7MO6Hcx0FU4S4lGeX14qoBMwOFvcX9c3 TIZjxpsGAzybxt9hEVSm8NvWVX8z1O++Qi0XSougis9+r3/Mbq11cvUAca903XQ8SD l72KYu9eaPU1D2pcKXAcUMWD036iAZVEKMyHvViz1iJtDB69WwMBy28KShWGiupXVk Ds6Xm5fN6GxMVOFBsGkmKUQ+rqLkmR8/8KbqW5fDsnOkWBFBXK20bclAveuRlHEwD6 Xyoz5XnA8yRC18H4UfBwRarXgY5l9aPl4PxFQVBhK31aYiEcCaQ1fLko44tht6yyMK Jh054ghMCXGJQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4691ACE0FF3; Tue, 7 May 2024 20:22:42 -0700 (PDT) Date: Tue, 7 May 2024 20:22:42 -0700 From: "Paul E. McKenney" To: Leonardo Bras Cc: Sean Christopherson , Paolo Bonzini , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Marcelo Tosatti , 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: <3b2c222b-9ef7-43e2-8ab3-653a5ee824d4@paulmck-laptop> <663a659d-3a6f-4bec-a84b-4dd5fd16c3c1@paulmck-laptop> <0e239143-65ed-445a-9782-e905527ea572@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 Tue, May 07, 2024 at 11:51:15PM -0300, Leonardo Bras wrote: > On Tue, May 07, 2024 at 05:08:54PM -0700, Sean Christopherson wrote: > > On Tue, May 07, 2024, Sean Christopherson wrote: > > > On Tue, May 07, 2024, Paul E. McKenney wrote: [ . . . ] > > > > But if we do need RCU to be more aggressive about treating guest execution as > > > > an RCU quiescent state within the host, that additional check would be an > > > > excellent way of making that happen. > > > > > > It's not clear to me that being more agressive is warranted. If my understanding > > > of the existing @user check is correct, we _could_ achieve similar functionality > > > for vCPU tasks by defining a rule that KVM must never enter an RCU critical section > > > with PF_VCPU set and IRQs enabled, and then rcu_pending() could check PF_VCPU. > > > On x86, this would be relatively straightforward (hack-a-patch below), but I've > > > no idea what it would look like on other architectures. > > > > > > But the value added isn't entirely clear to me, probably because I'm still missing > > > something. KVM will have *very* recently called __ct_user_exit(CONTEXT_GUEST) to > > > note the transition from guest to host kernel. Why isn't that a sufficient hook > > > for RCU to infer grace period completion? > > This is one of the solutions I tested when I was trying to solve the bug: > - Report quiescent state both in guest entry & guest exit. > > It improves the bug, but has 2 issues compared to the timing alternative: > 1 - Saving jiffies to a per-cpu local variable is usually cheaper than > reporting a quiescent state > 2 - If we report it on guest_exit() and some other cpu requests a grace > period in the next few cpu cycles, there is chance a timer interrupt > can trigger rcu_core() before the next guest_entry, which would > introduce unnecessary latency, and cause be the issue we are trying to > fix. > > I mean, it makes the bug reproduce less, but do not fix it. OK, then it sounds like something might be needed, but again, I must defer to you guys on the need. If there is a need, what are your thoughts on the approach that Sean suggested? Thanx, Paul