Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3924760imw; Mon, 11 Jul 2022 20:02:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/bohh7LCpoDG7KqmqWZm3TCxuUnjQF9FfKe71LD3gIC+wDdaVx9Q9XHq5cSlPfmwcPfL5 X-Received: by 2002:a17:90a:bc95:b0:1ef:8b48:fa0b with SMTP id x21-20020a17090abc9500b001ef8b48fa0bmr1650937pjr.189.1657594932214; Mon, 11 Jul 2022 20:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657594932; cv=none; d=google.com; s=arc-20160816; b=SxmhTjPL0ThmEzcNnOuLJq11cqG1nzylrQ4e56XYEputrAoeVe9eTbzrHi82pf6ofE IRnYkIX/s02/0vPMlXtsgk1JVucRUTrl5/TRVbohKJipD7dX3vITBKc4VA0L9YwIrgTQ sDfExghOKz4ymXR+/9qORBG0z6a7YyxDJXRSlzyENYR8dKw6451Cu8rdTMYsZ5jd1xNC 4EwP/lGsgAVyCbhlvi8oS4d2ycF1K2bv/PaMKhMIeRoGGkGKlIPNIa3rX5B9EIyLvFxr 0g6cgrPUtEIxnE1zj+FH76VN6NGj4WohEbR8gm83a5U3jftAPLsZMJrayTdYa4avCvH5 t8Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=elXhnDHf5FTiWyLaSlNOh3WhuxkhpUE1KvIHEcUEopY=; b=F99P12+OAcg3oPAtBvn8vLra8QkRuCcScMsRr+L4OnkS6OclDU7uM7l4J31jEluc+0 FkglZRhrw/cRNQZAeEToNnxmQYJnDRQ5OHjM/U8xZeHRmwj+DIHkpqX4dkf65uDDXQ0+ R1lg24rDwsDVkok7Al1Bv6QPmkMI/ofde/JdOEovSJkao8fbGoKbcolxMo9/VdsIBm34 ncfBUiRDEop65MVAgD4C/hWScKMHoQmCbZ6gVdhlmeLIhfJtGVW04so4fFwcOUN6RR/w NeCq2kd8pd/KCDyxchiHes5OnxwDRJPljRnHlqSpabjvidk7TpU1jKIAmou+fE+Wbxrc RYSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TYwrnnIn; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a170902a5c500b0016a1ef12873si11602296plq.76.2022.07.11.20.01.59; Mon, 11 Jul 2022 20:02:12 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=TYwrnnIn; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231403AbiGLC5F (ORCPT + 99 others); Mon, 11 Jul 2022 22:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbiGLC5E (ORCPT ); Mon, 11 Jul 2022 22:57:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94E1A2B264 for ; Mon, 11 Jul 2022 19:57:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 20728616E2 for ; Tue, 12 Jul 2022 02:57:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EF84C341C8; Tue, 12 Jul 2022 02:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657594622; bh=1s0tBUcDXUvWcrI+5GwZsamW/tpS8Eb+RLz7f2OSl8U=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=TYwrnnIn7yCqCwO5s8NIXAqfZ+kRLGN1qwa4KzC/JxUgGfmY+NUZ4ANU6HWm3DfQ1 ZYHW/p34ftUSOgMFenTxENxJj2LsW9LXY1umrXkWBQ3dy4QKW63gPfohg1w+BDyPwL fpZYRv9ipzyOZt7jGAaRD8uk0DZDV3E0rvKP1gOkA9aHkusDbqTRtng5BJ+UujnPSP LMBiEf/TL1sv/2GIYi5rVJe47+P8VSG8oDvEtINM+GdvxfFWxMDS1rnx5uqLpv29xB 58xD/0+jENRt3AGG7Jkso9jRsRMdBXgwQCrX5Ducu/pRZSH+2fX2IHwvlctkJIKsAQ vbX2bgf7cLpEg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E86245C0741; Mon, 11 Jul 2022 19:57:01 -0700 (PDT) Date: Mon, 11 Jul 2022 19:57:01 -0700 From: "Paul E. McKenney" To: Steven Rostedt Cc: Marco Elver , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Thomas Gleixner , Johannes Berg , Alexander Potapenko , Dmitry Vyukov , Naresh Kamboju , Linux Kernel Functional Testing Subject: Re: [PATCH -printk] printk, tracing: fix console tracepoint Message-ID: <20220712025701.GS1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220503073844.4148944-1-elver@google.com> <20220711182918.338f000f@gandalf.local.home> <20220712002128.GQ1790663@paulmck-ThinkPad-P17-Gen-1> <20220711205319.1aa0d875@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220711205319.1aa0d875@gandalf.local.home> X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Mon, Jul 11, 2022 at 08:53:19PM -0400, Steven Rostedt wrote: > On Mon, 11 Jul 2022 17:21:28 -0700 > "Paul E. McKenney" wrote: > > > On x86, both srcu_read_lock() and srcu_read_unlock() should be OK from > > NMI context, give or take their use of lockdep. Which is why we have > > srcu_read_lock_notrace() and srcu_read_unlock_notrace(), which do not > > use lockdep. Which __DO_TRACE() does in fact invoke. Ah, but you have > > this: "WARN_ON_ONCE(rcuidle && in_nmi())". > > > > Because all the world is not an x86. > > But since NMIs are architecture specific, we could change that to: > > WARN_ON_ONCE(!srcu_nmi_safe && rcuidle && in_nmi()); > > and add a srcu_nmi_safe constant or macro that is 1 on architectures that > srcu is safe in NMI and 0 otherwise. > > Or do we care if a tracepoint happens in those architectures where it is > not safe. We could then just do: > > if (!srcu_nmi_safe && rcuidle && in_nmi()) > return; > > and just skip tracepoints that are marked rcu_idle and happen within NMI. More generally, this is this_cpu_nmi_safe rather than just SRCU. Or could be, depending on what the architecture guys would like to guarantee. SRCU is just passing through the this_cpu*() NMI-safety property. And in addition to in_nmi(), there is the HAVE_NMI Kconfig option: $ git grep -w HAVE_NMI arch/Kconfig:config HAVE_NMI arch/Kconfig: depends on HAVE_NMI arch/arm/Kconfig: select HAVE_NMI arch/arm64/Kconfig: select HAVE_NMI arch/loongarch/Kconfig: select HAVE_NMI arch/mips/Kconfig: select HAVE_NMI arch/powerpc/Kconfig: select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) arch/s390/Kconfig: select HAVE_NMI arch/sh/Kconfig: select HAVE_NMI arch/sparc/Kconfig: select HAVE_NMI arch/x86/Kconfig: select HAVE_NMI So if I understand correctly, arm, loongarch, mips, powerpc, sh, and sparc are the ones that have NMIs but don't have NMI-safe this_cpu*() operations. These are the ones that would need !srcu_nmi_safe. Or, longer term, I could make HAVE_NMI && !srcu_safe_nmi cause SRCU to use explicit atomics for srcu_read_lock_trace() and srcu_read_unlock_trace(). I am assuming that any NMI handler executing srcu_read_lock_trace() also executes the matching srcu_read_unlock_trace(). (Silly me, I know!) This assumption means that srcu_read_lock() and srcu_read_unlock() can continue with their non-atomic this_cpu_inc() ways. But a quick fix that stopped the bleeding and allowed printk() to progress would be useful in the short term, regardless of whether or not in the longer term it makes sense to make srcu_read_lock_trace() and srcu_read_unlock_trace() NMI-safe. Thoughts? Thanx, Paul