Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp22082lqo; Tue, 7 May 2024 10:56:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/2FMnd4IbJT3TIO+KSx2nSlpMR/c/xbvmzfyaLe9Fhn7/ryiRkP53dwtnx9Nm21XpdEPs8eX3zQKOgYbp0HayxinIiRzXg3dy2K/g3g== X-Google-Smtp-Source: AGHT+IG/CwHc24EOYW9O6WRgHRkLL84oPtLpKyDe2HhLp2MhTmluToRvm9yudn503j/WpmufnSHA X-Received: by 2002:a17:906:b20c:b0:a59:c963:82c with SMTP id a640c23a62f3a-a59fb9676f4mr12934366b.33.1715104568614; Tue, 07 May 2024 10:56:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715104568; cv=pass; d=google.com; s=arc-20160816; b=zuXZZ6161Y+E24s7syTdzXpP5ZU7x8RO9Qif9gOdqVwjM5pOlWCXSa0loz8FUK4cg+ C/yLA/TWg3wusCMjb+CMf+NLrZzai2w8w5KzDb+PdP87KshBs8dUdXM0Q1OUIRCZRU5U Q+ehf6Ba+A/rXotiDo0AfI1+fCyLfDLMBtXcUcqBSVrStzeJ/MjEXPdqE//Qt9TK/pB2 4+fKZZcahWYJ2x2x4Ypgq9+zHAXSWtdhcjEIP18sUSawZkrY29blrH6a6/4ohL2Be/QX XEn2LRlyJ7OZAWqA25fBDqcBP0sE3Io5WtZnE7z0/aRDJPllVtP+BVijNMKkJ7OmVuPq 7KUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=U/zdljaT58TeUovqBD+WPeAJgx4d8t4+C/lLtRXXISU=; fh=9G9gctjXJMSH4NXoG2Nii2jy0K9PSuGIUFLAZIsFhPQ=; b=WJVmxyR40u5LVJKad6XitTfS6WEVhSb2e0ZsYdF9XGdg7xT6019DLUUNYhOdMgy73G cbd/QYQz9XC3qBETbsiij536tGOb7Riown4ZpGi41DfjWKTmTquQvdmpMPK60JWzxsl3 m+OE1ACBzCFeAzAbb6oH0LiQzr4xdDh6jX2f7Sj4zhUtx6p5yTc/tiszzKasMWnA868A whOMqZ7geRZXeW0ymoeuQ9VwOTguHDQmGGljOryjZS1OSL/Ruepc4PLPlTelO8foFXST JeOlMXGHt5JwsZrokPl6rI6bBVvDwy+HZqFa758rmft0wAw6uThU1XogJH1jz5iEHPEo Zz9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="WGKgC/qL"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-171935-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a7-20020a1709062b0700b00a59a6113ec0si4475295ejg.549.2024.05.07.10.56.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 10:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171935-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=@google.com header.s=20230601 header.b="WGKgC/qL"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-171935-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 5AFF11F22824 for ; Tue, 7 May 2024 17:56:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6111516C87D; Tue, 7 May 2024 17:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WGKgC/qL" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E22715D5BB for ; Tue, 7 May 2024 17:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715104558; cv=none; b=lTqo4pRdCocV5PliaCUcU4y6Ma0Kh8k/7b7tTIdWIgo4o09l0pPkxgdxuJgi4DYZD9kAi7sdDBB5L9yJ7CO/zgE2E+REsxkG1E2i+WGW4u5xOUSOW0q2m/iCj8jQc/V3e5LJwQvBOrd+a051an8YGdDoNfYpUBAIqOZeBaxxvB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715104558; c=relaxed/simple; bh=i1B0BczLSo3SWF7MKkmZ007UspXePFGAXjtEUDsAbtE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kMJ3yrVhElhjd7SAxsBi239phZ8Q+GYIgL31clJlk0DovMpS+p3I4QEYt6UvKXz8G/oNdqrGbNicFYgDpt5pZKSVWys4tbvLJE2/gT1thMq9poHoEKNdsGC0AAurSNiBdXbg7PKBcGEnyGMGnT4JGS9qhBfZ2AV9/MqegZ4x1YU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WGKgC/qL; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5d8dd488e09so4193866a12.2 for ; Tue, 07 May 2024 10:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715104557; x=1715709357; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=U/zdljaT58TeUovqBD+WPeAJgx4d8t4+C/lLtRXXISU=; b=WGKgC/qLLGDzqckkvrqP7f1LsoRyBJ91zHpkQ75EQG/sElibpIdyYY7zGP23rKsK7X YbR1/n4r2qJjORhPoCGFAC+WoMhQUStqt68dt0l8U0LwkDQGz3yHS4eWHGuqTGG2B72k NL4OhYBy0Imjefoo9mC7p/5hEIF2yzH8HWGmD6Fjfv4tcLpe5lwGlnera88zxYWyRUs6 M1BS2OtHx23GDzJ1Z3/0kh9zRX3kaP+UD9rO4MycvZYvzPHeVJdTmwxIQcmXCsfWE+RC 1yM39swBkFGQpZ0iorAU7aWCQR5TRwUbCetfw7VkWGNYP28f7Bklsu657QI+9vL1GLWy t4oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715104557; x=1715709357; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U/zdljaT58TeUovqBD+WPeAJgx4d8t4+C/lLtRXXISU=; b=hwd9LTMmH9a+8WuTkbJasuRXl2iBwWdKkpBsosn+QlbNzKRTBXql2mUNayE8LfV9aT STHo6Wmm71cRvzMZ5XRzso1uvjKUYgK2rheNNTILhFM4JqWiwhR/DGW/q3GRmzT/bUZL YkCyVF+GAO5qzfDCULwlq1Jv3qQt7AgXZwjIKEsayXrXZ8T6kBo1gRZb75VaY0+A+dnv sV6cEo+VEsvzxTlsmQHwhdpz+DifuAXDGAw3qkYQgvxtVaFFc9op1khtOfV0gHcSrU9l FT5dhu2eAa8jnm/bLvRcrZfFPHIwpu6XGwlEUIXr0O1oaY8QvWtAB8VxBjqKaLKzG7kj tWSw== X-Forwarded-Encrypted: i=1; AJvYcCWzwKD+NWUexZsdw+M00wlJWKbydd0/UQj8RJ0riRv+O0KN/ddUqTKQzJ8VZmZCQ/D6GbF7WvT+oqaSOEMtvirxH/sbEJdIIBLNi/+N X-Gm-Message-State: AOJu0YwpO3RzO8Sb1P/FEN2Ax52kFrJIBuh6mCsGNqCv0nSVX21l0FtY bCmEsuWMZ/4+UFCXPwXAbdfLX8x3RIypZccLQlWPJQN8VeU8U62h0/2oBvFylXZB9lWMIGixXFO eHA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:3ecb:0:b0:5f7:fca4:6d2f with SMTP id 41be03b00d2f7-62f24b1978bmr1264a12.7.1715104556721; Tue, 07 May 2024 10:55:56 -0700 (PDT) Date: Tue, 7 May 2024 10:55:54 -0700 In-Reply-To: <3b2c222b-9ef7-43e2-8ab3-653a5ee824d4@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240328171949.743211-1-leobras@redhat.com> <3b2c222b-9ef7-43e2-8ab3-653a5ee824d4@paulmck-laptop> Message-ID: Subject: Re: [RFC PATCH v1 0/2] Avoid rcu_core() if CPU just left guest vcpu From: Sean Christopherson To: "Paul E. McKenney" Cc: Leonardo Bras , 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 Content-Type: text/plain; charset="us-ascii" On Fri, May 03, 2024, Paul E. McKenney wrote: > On Fri, May 03, 2024 at 02:29:57PM -0700, Sean Christopherson wrote: > > So if we're comfortable relying on the 1 second timeout to guard against a > > misbehaving userspace, IMO we might as well fully rely on that guardrail. I.e. > > add a generic PF_xxx flag (or whatever flag location is most appropriate) to let > > userspace communicate to the kernel that it's a real-time task that spends the > > overwhelming majority of its time in userspace or guest context, i.e. should be > > given extra leniency with respect to rcuc if the task happens to be interrupted > > while it's in kernel context. > > But if the task is executing in host kernel context for quite some time, > then the host kernel's RCU really does need to take evasive action. Agreed, but what I'm saying is that RCU already has the mechanism to do so in the form of the 1 second timeout. And while KVM does not guarantee that it will immediately resume the guest after servicing the IRQ, neither does the existing userspace logic. E.g. I don't see anything that would prevent the kernel from preempting the interrupt task. > On the other hand, if that task is executing in guest context (either > kernel or userspace), then the host kernel's RCU can immediately report > that task's quiescent state. > > Too much to ask for the host kernel's RCU to be able to sense the > difference? ;-) KVM already notifies RCU when its entering/exiting an extended quiescent state, via __ct_user_{enter,exit}(). When handling an IRQ that _probably_ triggered an exit from the guest, the CPU has already exited the quiescent state. And AFAIK, that can't be safely changed, i.e. KVM must note the context switch before enabling IRQs.