From patchwork Fri Jan 13 12:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 43233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp243187wrt; Fri, 13 Jan 2023 04:35:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXtpvj0mMqVmGWDo823j7xqz9Kfgb13Ri3YRjcoOjPdZ1/Sz9iVYsBTEP67yDPsulNqKKdHS X-Received: by 2002:a17:906:9f0a:b0:7c0:e302:b523 with SMTP id fy10-20020a1709069f0a00b007c0e302b523mr86630186ejc.59.1673613321982; Fri, 13 Jan 2023 04:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673613321; cv=none; d=google.com; s=arc-20160816; b=Z0XRz6xAuNBB/QTwUpEbVc2C7SJa4Ljo4MXmQ3tL0X1IzoP+VIFD7Jc04BrYBEHVay ygVdA9ARwGis114ff+ngke8OcODzdNhm6W3vwoNVdHFUEAqTrBbYF0D8oMnF3mjeE2eV Jm+aA2iE9dg+pMW7GpTVS3d4Fz3KMQTvbZ44SCOdpxYi4AjpFvHwU/NEfSk7KhegvQA3 WVDmTqklode8RfwmKsXIIVJt0JkaRCYRXGR+vmliE5YubJKXUvOGwBYD33YMDQPKIKk0 /QOWP3gLY7Y11W4rRGjIjBL+YRubT8dNOxRBhTfX1z4remlA6Vet0FN9qBb05BShUIvK SVYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=B8W9VgYMwyJ7o4FzoZE/YYmq/7I6X546PhnibH4LBLo=; b=aMEaJfspxpkaMJfJfzLI84sg18Xt5sP7HpjtevgQg6Ik7BMVyok1Vur6bOCsFqy0Hy m9XWHJNEdJjFxe538JjpxCICubxxHv4tAb6Yi/nIw9f43RySHcfwg7hpuaFkswQMUrtU g21y5JdXToBQUzZXmKzb85lNCehfijdDLWZ9WfhCj9lBOx7yTlyVexM2EnnFYHh7N0VM pBiKuq1lSJwf/65IMspblsuIQbgVFzp1D7dlq8Ap454TrFeTYi8CFmsShuOWKMCpib0S 2ZUA3ztOVvrpDBKsXjza7EJKuelbFeG9KJS4D4ehL5TI28a+m1LOsdvxkeSqyOQwNCW1 K6Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=m0HCAdQC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="aKpAhI/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs40-20020a1709073ea800b007413f3cdd18si23304728ejc.238.2023.01.13.04.34.57; Fri, 13 Jan 2023 04:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=m0HCAdQC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="aKpAhI/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233010AbjAMMeK (ORCPT + 99 others); Fri, 13 Jan 2023 07:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241313AbjAMMcO (ORCPT ); Fri, 13 Jan 2023 07:32:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B5BC544EE; Fri, 13 Jan 2023 04:31:12 -0800 (PST) Date: Fri, 13 Jan 2023 12:31:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673613068; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B8W9VgYMwyJ7o4FzoZE/YYmq/7I6X546PhnibH4LBLo=; b=m0HCAdQCEguf39lX/MGQfnfRWoMNK0ICTOKHQZAQUnH2VqP8LlvrSqPWLjQ1w2k/I31LRR 9dkvUHO5BJa8VggIjfHZUGz1EyfThQ0FgntW2ucggDYQDqpQMVycMG198b5aI/m0a8R7vu /XAkGYdgMbKUSP0sqLTSPhSm97AGExYV/3CsAmjHplDlyKIJFHdTVSnmTDUGYHhsF7fmNK XuevKCupsE4yAtiGeXcqHJxObIN/w6evK0WqWd5ZNnpb6RCIOSX5PXktppvElLUIaGy24J 7tizgovXswWSUhb9QwLnlalVcp8zyrw3EjbbCz01XzZlp1K8AQJKX7TnJeTH4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673613068; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B8W9VgYMwyJ7o4FzoZE/YYmq/7I6X546PhnibH4LBLo=; b=aKpAhI/T5TfpUch7Vq4NlaPGb7hVn/5PuqEs6HkX4puiYiiQMIMcLA7PzgSsm8NBWdSFuA An4nlLZp+Ht9FGBA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] tracing: WARN on rcuidle Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , Tony Lindgren , Ulf Hansson , "Rafael J. Wysocki" , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195541.416110581@infradead.org> References: <20230112195541.416110581@infradead.org> MIME-Version: 1.0 Message-ID: <167361306830.4906.9126654515923168078.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754910762875575295?= X-GMAIL-MSGID: =?utf-8?q?1754910762875575295?= The following commit has been merged into the sched/core branch of tip: Commit-ID: 408b961146be4c1a776ce285c3c289afab15298a Gitweb: https://git.kernel.org/tip/408b961146be4c1a776ce285c3c289afab15298a Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:43:48 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:48:16 +01:00 tracing: WARN on rcuidle ARCH_WANTS_NO_INSTR (a superset of CONFIG_GENERIC_ENTRY) disallows any and all tracing when RCU isn't enabled. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Tested-by: Tony Lindgren Tested-by: Ulf Hansson Acked-by: Rafael J. Wysocki Acked-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230112195541.416110581@infradead.org --- include/linux/tracepoint.h | 15 +++++++++++++-- kernel/trace/trace.c | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 4b33b95..552f80b 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -178,6 +178,17 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) #endif /* CONFIG_HAVE_STATIC_CALL */ /* + * ARCH_WANTS_NO_INSTR archs are expected to have sanitized entry and idle + * code that disallow any/all tracing/instrumentation when RCU isn't watching. + */ +#ifdef CONFIG_ARCH_WANTS_NO_INSTR +#define RCUIDLE_COND(rcuidle) (rcuidle) +#else +/* srcu can't be used from NMI */ +#define RCUIDLE_COND(rcuidle) (rcuidle && in_nmi()) +#endif + +/* * it_func[0] is never NULL because there is at least one element in the array * when the array itself is non NULL. */ @@ -188,8 +199,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) if (!(cond)) \ return; \ \ - /* srcu can't be used from NMI */ \ - WARN_ON_ONCE(rcuidle && in_nmi()); \ + if (WARN_ON_ONCE(RCUIDLE_COND(rcuidle))) \ + return; \ \ /* keep srcu and sched-rcu usage consistent */ \ preempt_disable_notrace(); \ diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a555a86..54ec159 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3128,6 +3128,9 @@ void __trace_stack(struct trace_array *tr, unsigned int trace_ctx, return; } + if (WARN_ON_ONCE(IS_ENABLED(CONFIG_GENERIC_ENTRY))) + return; + /* * When an NMI triggers, RCU is enabled via ct_nmi_enter(), * but if the above rcu_is_watching() failed, then the NMI