Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1162079pxb; Fri, 21 Jan 2022 11:10:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr61INtBVqc1oiFkGA1+rLGKRgan2IRgFtzVxfOMOZGXWhIhHu3LhE+6acKE5jSZBvOkL4 X-Received: by 2002:a17:902:b489:b0:14a:4747:9917 with SMTP id y9-20020a170902b48900b0014a47479917mr4936537plr.26.1642792205487; Fri, 21 Jan 2022 11:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642792205; cv=none; d=google.com; s=arc-20160816; b=dWJQY1uCqhFg3nVB3h1JxXUz+UILQWbyoI3uUJBZbVYGN0Y6haBZHQ8bgkJ6nSIfEl Q27tPwsR5fTNkwfAOPVqr5dotzCjhKZ9hirVvxlRrLDeZCf8C2W9w07vJO8CyCPC5T8S 4MgDCuWWf+dubBp0W3TjLewI6mcbJdrau5VrrmEqxgb/M6ZTVdFb40sAktWTlBTFLGVJ DgLkGXicbDz+Y15pBvStHO87F5dl5YXMct6hyxeWUHkz/5h/u/CmgLOyXkKWpyXk3MoU VZU6ZZwfuV45aiB5noptCujgl0JN8D8r718hTo7msqLUbtxePC+O/1lt2NXG+DEEMF7W q9Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NprqOsooGZakUfmirU2KCcr7V442MEZUlFOq0d8oAOc=; b=qnQHFUSaphlW97YB7kC7qCq3ydwGBzeT1QizxzfhmXDLav+Vv+14pVkY8pnOU6saO8 gIvGcD2u36KLr+G1fmCt6pXf9gcC2+OZPIQvh8hD2xWRbR4jrG23mr+m2NQqDn6GingE 0adsigMSgtLtoY2fXv0w4gSwi3nPc/Y3IS+eMWk+A2/Pq4a20fhRUZ32cijodMpTmD3M 2g5/Ur7haHIDSuEBtn0cMXTdXva0/QUuS0bjRvhZHRxKlMnZjmBbHa56KllBOtEApcDD ICbETcST4NUxnNPDqbsmRtrK5lxKJvluMINRKDGr+jn7jxKRMk2UD813FBMvkOHgbLUS rhhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si5688828pls.565.2022.01.21.11.09.53; Fri, 21 Jan 2022 11:10:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353921AbiASK7L (ORCPT + 99 others); Wed, 19 Jan 2022 05:59:11 -0500 Received: from foss.arm.com ([217.140.110.172]:53438 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353857AbiASK7L (ORCPT ); Wed, 19 Jan 2022 05:59:11 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A3C44101E; Wed, 19 Jan 2022 02:59:10 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E038F3F73D; Wed, 19 Jan 2022 02:59:05 -0800 (PST) From: Mark Rutland To: linux-kernel@vger.kernel.org, Andy Lutomirski , Peter Zijlstra , Thomas Gleixner Cc: aleksandar.qemu.devel@gmail.com, alexandru.elisei@arm.com, anup.patel@wdc.com, aou@eecs.berkeley.edu, atish.patra@wdc.com, borntraeger@linux.ibm.com, bp@alien8.de, catalin.marinas@arm.com, chenhuacai@kernel.org, dave.hansen@linux.intel.com, frankja@linux.ibm.com, frederic@kernel.org, gor@linux.ibm.com, hca@linux.ibm.com, james.morse@arm.com, jmattson@google.com, joro@8bytes.org, mark.rutland@arm.com, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, nsaenzju@redhat.com, palmer@dabbelt.com, paulmck@kernel.org, paul.walmsley@sifive.com, pbonzini@redhat.com, seanjc@google.com, suzuki.poulose@arm.com, svens@linux.ibm.com, tsbogend@alpha.franken.de, vkuznets@redhat.com, wanpengli@tencent.com, will@kernel.org Subject: [PATCH v2 1/7] entry: add arch_in_rcu_eqs() Date: Wed, 19 Jan 2022 10:58:48 +0000 Message-Id: <20220119105854.3160683-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220119105854.3160683-1-mark.rutland@arm.com> References: <20220119105854.3160683-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All architectures have an interruptible RCU extended quiescent state (EQS) as part of their idle sequences, where interrupts can occur without RCU watching. Entry code must account for this and wake RCU as necessary; the common entry code deals with this in irqentry_enter() by treating any interrupt from an idle thread as potentially having occurred with an EQS and waking RCU for the duration of the interrupt via rcu_irq_enter() .. rcu_irq_exit(). Some architectures may have other interruptible EQSs which require similar treatment. For example, on s390 is it necessary to enable interrupts around guest entry in the middle of a period where core KVM code has entered an EQS. So that architectueres can wake RCU in these cases, this patch adds a new arch_in_rcu_eqs() hook to the common entry code which is checked in addition to the existing is_idle_thread() check, with RCU woken if either returns true. A default implementation is provided which always returns false, which suffices for most architectures. As no architectures currently implement arch_in_rcu_eqs(), there should be no functional change as a result of this patch alone. A subsequent patch will add an s390 implementation to fix a latent bug with missing RCU wakeups. Signed-off-by: Mark Rutland Cc: Andy Lutomirski Cc: Christian Borntraeger Cc: Heiko Carstens Cc: Paolo Bonzini Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Sven Schnelle Cc: Thomas Gleixner --- include/linux/entry-common.h | 16 ++++++++++++++++ kernel/entry/common.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 2e2b8d6140ed4..f1b91a13a15a6 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -99,6 +99,22 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs } #endif +/** + * arch_in_rcu_eqs - Architecture specific check for RCU extended quiescent + * states. + * + * Returns: true if the CPU is potentially in an RCU EQS, false otherwise. + * + * Architectures only need to define this if threads other than the idle thread + * may have an interruptible EQS. This does not need to handle idle threads. It + * is safe to over-estimate at the cost of redundant RCU management work. + * + * Invoked from irqentry_enter() + */ +#ifndef arch_in_rcu_eqs +static __always_inline bool arch_in_rcu_eqs(void) { return false; } +#endif + /** * enter_from_user_mode - Establish state when coming from user mode * diff --git a/kernel/entry/common.c b/kernel/entry/common.c index d5a61d565ad5d..b13d4e0b0b643 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -349,7 +349,8 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) * TINY_RCU does not support EQS, so let the compiler eliminate * this part when enabled. */ - if (!IS_ENABLED(CONFIG_TINY_RCU) && is_idle_task(current)) { + if (!IS_ENABLED(CONFIG_TINY_RCU) && + (is_idle_task(current) || arch_in_rcu_eqs())) { /* * If RCU is not watching then the same careful * sequence vs. lockdep and tracing is required -- 2.30.2