From patchwork Tue Jan 31 14:22:28 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: 50887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2778969wrn; Tue, 31 Jan 2023 06:25:27 -0800 (PST) X-Google-Smtp-Source: AK7set97KAH67gmeAdHEasWu3+VTx5tGxhnq+MQPrRud2uYFYzzTU062YmDIRiFU0ZpPM5A/LKMl X-Received: by 2002:a17:907:7da3:b0:86e:eccd:ba61 with SMTP id oz35-20020a1709077da300b0086eeccdba61mr4282401ejc.66.1675175127647; Tue, 31 Jan 2023 06:25:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675175127; cv=none; d=google.com; s=arc-20160816; b=xHwEX/SiO1IsrYJbh/SPxP35NadU93filRA+iBAyNF1vZPNt5c52hTJFevob++xjrn EZ4l5xdQg2O9AKUcVwlP0zisiLdt+nEl1YgThTpKegvQUSoMIkNa7g3NoINA7Na7CueO 5jUNHgP8eW/rteqNoOAm5JxMk48C0y2zsoRCjjOxkw+03DuubdI1MUKXiU/ItojqPWvv grexD39xHDlUXQvFWV5h/Rew4Q5n+c5aztSvzUlMyNw2/NYJg/OM3JKipaWiRn++3pvL sB55dR0tJMrfcgw1APaaHXx8XfSLmEUig2FMUGdNrB4agWtpBB9F640iDZpZErYqjAVR SacQ== 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=hmgUg3DQLqg4fvnfMUqWBH4m/OU8I4dYexk9IZKQyec=; b=Vhn/TFydiWO2HPx8FBH4kAF0V+P6za1q/tP8Znb8KD4hx3OUKKV3qMr+pzjtRRqmgY FzB5yVxYgRz1ZJ4kCmgZ7CQI0V3qhp8qb0LeHS1ZDeEmH85Bt0UGS8zlhcO5k40OM/vx rrp0F4sd0JSL2XjtQQSGkQcsg2wF1vtysV+PaHUhsK92Z29xcALfcQGNz4X4wXwUe8Ol NRJWXOjiTrSDgFhF6ZiMLhon4i96Ve+E50tYC0M0dkzmiJLtDZt5KgunJk5m+CriQpmu Z73RYSLoi5gyHeeWdoB+fDRTIi1TVSlFK6dZMpqPVeClxTCqvr4p2LMJEY/tJ9w+qqDR D13g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qIOMTmIY; dkim=neutral (no key) header.i=@linutronix.de; 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 ka6-20020a170907920600b0087bd4e90784si14425873ejb.850.2023.01.31.06.25.02; Tue, 31 Jan 2023 06:25:27 -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=qIOMTmIY; dkim=neutral (no key) header.i=@linutronix.de; 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 S229930AbjAaOWt (ORCPT + 99 others); Tue, 31 Jan 2023 09:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbjAaOWb (ORCPT ); Tue, 31 Jan 2023 09:22:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E405614229; Tue, 31 Jan 2023 06:22:30 -0800 (PST) Date: Tue, 31 Jan 2023 14:22:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1675174948; 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=hmgUg3DQLqg4fvnfMUqWBH4m/OU8I4dYexk9IZKQyec=; b=qIOMTmIYf9c9AiitJnmIkJA5TaLBIE23Gy9Qq5Hc8kdjzM7TxwZ9Yhdl1nJB0tLmuSe59J ZsJQcFjjgpVst3REbAQ8XsI3rSAF7cC56eO1jyn6hYLscKY4qYHgeBUlzHaSwH9mke8f55 0isr5gRhxxr7SwlP0O6As1+m9DKkXCDg4pNVD4lakgivHb+VBHHlAVBsLRFxHNMiqgkaDy d+xLvwlK2Yal6sMPozyhGQNEnsfiT+LoDE0fKJrO4aXfIbD6/zv6uy+qiXwfpeInJLKbBd dbOTFPCUU19eZRXgnYmKhtLzAKHBeuadkkzUsWMBa9Ik4CYEWUoynpdN0PbUmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1675174948; 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=hmgUg3DQLqg4fvnfMUqWBH4m/OU8I4dYexk9IZKQyec=; b=r2hCytEd9n7Q7ejywZk8dVZ6acVWs3fgJTwpMsUq8v7Us3hTtAsM98DN6vj7W5LjASg+sY th/o67KJU1ErrhCA== 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] cpuidle: tracing: Warn about !rcu_is_watching() Cc: "Steven Rostedt (Google)" , "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230126151323.466670589@infradead.org> References: <20230126151323.466670589@infradead.org> MIME-Version: 1.0 Message-ID: <167517494816.4906.10276554313364667528.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?1756548434647011003?= X-GMAIL-MSGID: =?utf-8?q?1756548434647011003?= The following commit has been merged into the sched/core branch of tip: Commit-ID: d099dbfd330686a8c09cd8944bcc77a56f9e7815 Gitweb: https://git.kernel.org/tip/d099dbfd330686a8c09cd8944bcc77a56f9e7815 Author: Peter Zijlstra AuthorDate: Thu, 26 Jan 2023 16:08:32 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 31 Jan 2023 15:01:46 +01:00 cpuidle: tracing: Warn about !rcu_is_watching() When using noinstr, WARN when tracing hits when RCU is disabled. Suggested-by: Steven Rostedt (Google) Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230126151323.466670589@infradead.org --- include/linux/trace_recursion.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h index c303f7a..d48cd92 100644 --- a/include/linux/trace_recursion.h +++ b/include/linux/trace_recursion.h @@ -135,6 +135,21 @@ extern void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip); # define do_ftrace_record_recursion(ip, pip) do { } while (0) #endif +#ifdef CONFIG_ARCH_WANTS_NO_INSTR +# define trace_warn_on_no_rcu(ip) \ + ({ \ + bool __ret = !rcu_is_watching(); \ + if (__ret && !trace_recursion_test(TRACE_RECORD_RECURSION_BIT)) { \ + trace_recursion_set(TRACE_RECORD_RECURSION_BIT); \ + WARN_ONCE(true, "RCU not on for: %pS\n", (void *)ip); \ + trace_recursion_clear(TRACE_RECORD_RECURSION_BIT); \ + } \ + __ret; \ + }) +#else +# define trace_warn_on_no_rcu(ip) false +#endif + /* * Preemption is promised to be disabled when return bit >= 0. */ @@ -144,6 +159,9 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign unsigned int val = READ_ONCE(current->trace_recursion); int bit; + if (trace_warn_on_no_rcu(ip)) + return -1; + bit = trace_get_context_bit() + start; if (unlikely(val & (1 << bit))) { /*