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: 43234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp243242wrt; Fri, 13 Jan 2023 04:35:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXswPlKqorszyN0Tt4lR2iC9ocNJOy1a3iiH4DTCllsWt0VH41uaVncImg+yIviTZK6qdbCZ X-Received: by 2002:a17:906:8478:b0:84d:373b:39dc with SMTP id hx24-20020a170906847800b0084d373b39dcmr20073000ejc.25.1673613327406; Fri, 13 Jan 2023 04:35:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673613327; cv=none; d=google.com; s=arc-20160816; b=0rZel6oDZMhasXFd3l7vv9XiJjcvYBi28ikpND7Tb4XmFS/wuQ6CJj66Xg7FD5rNFn zC1hN6gxRhjOfZ9pxnVBIitrDsEtlA5U/TG34U2pcuFUX0DLKLPPr8VN6OkBX684Oq+a sduBaA4jnBXKd9EFv+rkdzaVjFSl08s2mmCK5pG9zgBUJBaODQ7GNkwxf/lsxFcc7ye9 8hQIjID4fvp4Ffh1aQc8Bt3lRpoYz/LYx9M2tUHnhQXx5mmYeZmNKrMmJLpyRkbx+eQQ 2MdWKWYJXaCDnSmi2qIYg2HAHtOE1HDngrdXI+gjBaGYrN6sK2yQk03jCzMFO80eVTMc GHpg== 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=ipI6Na/dKtZ5G5/1E9wGT/cSjq6yKn0f3P9gVwSH0LA=; b=FAfyIXwT7o02PxVE0HOl01fkPQcpqNLj/s3HWgJDIvau0gNFZsBrsLvuK53SP7z0+d dpnimdORpF/rSkcnen2XXm3diFPmkF4KDQy52wJXOFX3cK7LDwtBzA6YaxQcJm9RSw0G 9x3lhX9fNvKUxwGFqeEbic4H8JzURZKW4/ph8K1KfDXp0SvVQEIgMzLr4PpWgIJ40nOz lU4NRN8BobWAqR4vYJ3WCDUc1XxmF9g6fpQKRNXjK+lISDS5SsNbzY924zB+P6yN6Oxq ue409hSm1fy8PfEcSS+kv04ZwrKx+wOgJFbn23IKKGS4qsE7BXtsrYE8uU04XxXbxmhG phWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kID923T7; 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 xe6-20020a170907318600b0084cbde35b2fsi21803130ejb.465.2023.01.13.04.35.02; Fri, 13 Jan 2023 04:35: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=kID923T7; 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 S241311AbjAMMeR (ORCPT + 99 others); Fri, 13 Jan 2023 07:34:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241317AbjAMMcO (ORCPT ); Fri, 13 Jan 2023 07:32:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F374544E7; 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=ipI6Na/dKtZ5G5/1E9wGT/cSjq6yKn0f3P9gVwSH0LA=; b=kID923T7EOrB00m0brlWrWxjnETrqpY1FNE29VfzQt9nCyZtqDnLemSeEj6tuGEoGpqEuX wFaMLDXHgpQGOVTaY5FNwCila918sIu5dO59KC8Jf5HmkflnOB/mtJvFL7a2f6Wq6bB+Ni HI2h9MZn0s7DMuoK1Zhqwt1LjaG61KBzOuYIDmS5dp0BVKN3kYtpVtcVf6XW9vmoD/tcsF DLkHsuk1KI2PlrAXoBiSqZVn8fqv2TUe5Z9AzzaRQ7q+r/kSRlsk2rgDKigeoHkOMxdEK8 AXeq9KPPJlJyilwOwcPrY3eqK7iu6lkxwCbFb34gsRpZEpbnvGNBuc5NpD8gdQ== 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=ipI6Na/dKtZ5G5/1E9wGT/cSjq6yKn0f3P9gVwSH0LA=; b=v4+dK7EXo4eQG7WUcuSdUpLWjmXffTopWUP9DF6afSAIdzTnqeaHcurDygeCQejKdJPz3V /7W4iRaUeDa94GDQ== 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, hardirq: No moar _rcuidle() tracing Cc: kernel test robot , "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195541.477416709@infradead.org> References: <20230112195541.477416709@infradead.org> MIME-Version: 1.0 Message-ID: <167361306803.4906.14578212248675615041.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?1754910768848017065?= X-GMAIL-MSGID: =?utf-8?q?1754910768848017065?= The following commit has been merged into the sched/core branch of tip: Commit-ID: 9aedeaed6fc6fe8452b9b8225e95cc2b8631ff91 Gitweb: https://git.kernel.org/tip/9aedeaed6fc6fe8452b9b8225e95cc2b8631ff91 Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:43:49 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:48:16 +01:00 tracing, hardirq: No moar _rcuidle() tracing Robot reported that trace_hardirqs_{on,off}() tickle the forbidden _rcuidle() tracepoint through local_irq_{en,dis}able(). For 'sane' configs, these calls will only happen with RCU enabled and as such can use the regular tracepoint. This also means it's possible to trace them from NMI context again. Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230112195541.477416709@infradead.org --- kernel/trace/trace_preemptirq.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c index 629f285..f992444 100644 --- a/kernel/trace/trace_preemptirq.c +++ b/kernel/trace/trace_preemptirq.c @@ -20,6 +20,20 @@ static DEFINE_PER_CPU(int, tracing_irq_cpu); /* + * Use regular trace points on architectures that implement noinstr + * tooling: these calls will only happen with RCU enabled, which can + * use a regular tracepoint. + * + * On older architectures, use the rcuidle tracing methods (which + * aren't NMI-safe - so exclude NMI contexts): + */ +#ifdef CONFIG_ARCH_WANTS_NO_INSTR +#define trace(point) trace_##point +#else +#define trace(point) if (!in_nmi()) trace_##point##_rcuidle +#endif + +/* * Like trace_hardirqs_on() but without the lockdep invocation. This is * used in the low level entry code where the ordering vs. RCU is important * and lockdep uses a staged approach which splits the lockdep hardirq @@ -28,8 +42,7 @@ static DEFINE_PER_CPU(int, tracing_irq_cpu); void trace_hardirqs_on_prepare(void) { if (this_cpu_read(tracing_irq_cpu)) { - if (!in_nmi()) - trace_irq_enable(CALLER_ADDR0, CALLER_ADDR1); + trace(irq_enable)(CALLER_ADDR0, CALLER_ADDR1); tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1); this_cpu_write(tracing_irq_cpu, 0); } @@ -40,8 +53,7 @@ NOKPROBE_SYMBOL(trace_hardirqs_on_prepare); void trace_hardirqs_on(void) { if (this_cpu_read(tracing_irq_cpu)) { - if (!in_nmi()) - trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); + trace(irq_enable)(CALLER_ADDR0, CALLER_ADDR1); tracer_hardirqs_on(CALLER_ADDR0, CALLER_ADDR1); this_cpu_write(tracing_irq_cpu, 0); } @@ -63,8 +75,7 @@ void trace_hardirqs_off_finish(void) if (!this_cpu_read(tracing_irq_cpu)) { this_cpu_write(tracing_irq_cpu, 1); tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1); - if (!in_nmi()) - trace_irq_disable(CALLER_ADDR0, CALLER_ADDR1); + trace(irq_disable)(CALLER_ADDR0, CALLER_ADDR1); } } @@ -78,8 +89,7 @@ void trace_hardirqs_off(void) if (!this_cpu_read(tracing_irq_cpu)) { this_cpu_write(tracing_irq_cpu, 1); tracer_hardirqs_off(CALLER_ADDR0, CALLER_ADDR1); - if (!in_nmi()) - trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); + trace(irq_disable)(CALLER_ADDR0, CALLER_ADDR1); } } EXPORT_SYMBOL(trace_hardirqs_off);