From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE660C6377D for ; Wed, 21 Jul 2021 13:09:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0917461175 for ; Wed, 21 Jul 2021 13:09:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0917461175 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GVGBY3vsCz3bg5 for ; Wed, 21 Jul 2021 23:09:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=G6EwJTzi; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=suse.com (client-ip=195.135.220.28; helo=smtp-out1.suse.de; envelope-from=pmladek@suse.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=G6EwJTzi; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GVGB174Dsz2yL6 for ; Wed, 21 Jul 2021 23:08:56 +1000 (AEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 828A4224F6; Wed, 21 Jul 2021 13:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1626872933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GSrlf3q3DEPrwUFBKoxlkF494RI/UIwOR7Ygj8r1Z1I=; b=G6EwJTziyXxCA+fg3DWxGGqC6bJ5d6YHoubZTuX+dk4mMy0FOCGMjTx3IJ1hddInQatreK Yaj8KfzN1A/0NV6hbqhJ0Jy5681vupjvfb0tY5E7ZqPMou4fI4ZBAqrL27ofRjXF+kzKeF buFz9KxxpTVmzNwwVbkvdFcTrfVsfoc= Received: from suse.cz (pathway.suse.cz [10.100.12.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 1864FA3B8A; Wed, 21 Jul 2021 13:08:53 +0000 (UTC) Date: Wed, 21 Jul 2021 15:08:53 +0200 From: Petr Mladek To: John Ogness Subject: Re: [PATCH printk v4 4/6] printk: remove NMI tracking Message-ID: <20210721130852.zrjnti6b3fwjgdzj@pathway.suse.cz> References: <20210715193359.25946-1-john.ogness@linutronix.de> <20210715193359.25946-5-john.ogness@linutronix.de> <20210721120026.y3dqno24ahw4sazy@pathway.suse.cz> <877dhjygvc.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877dhjygvc.fsf@jogness.linutronix.de> User-Agent: NeoMutt/20170912 (1.9.0) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Rasmus Villemoes , "Wolfram Sang \(Renesas\)" , Paul Mackerras , Daniel Borkmann , Marc Zyngier , Masahiro Yamada , Russell King , Ingo Molnar , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, Valentin Schneider , Kees Cook , Anshuman Khandual , Vipin Sharma , Frederic Weisbecker , Steven Rostedt , Nathan Chancellor , Nick Terrell , Thomas Gleixner , Vlastimil Babka , Xiongwei Song , Nick Desaulniers , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed 2021-07-21 14:52:15, John Ogness wrote: > On 2021-07-21, Petr Mladek wrote: > >> --- a/kernel/trace/trace.c > >> +++ b/kernel/trace/trace.c > >> @@ -9647,7 +9647,7 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) > >> tracing_off(); > >> > >> local_irq_save(flags); > >> - printk_nmi_direct_enter(); > >> + printk_deferred_enter(); > > > > I would prefer to do not manipulate the printk context here anymore, > > as it was done in v3. > > > > printk_nmi_direct_enter() was added here by the commit the commit > > 03fc7f9c99c1e7ae2925d4 ("printk/nmi: Prevent deadlock when > > accessing the main log buffer in NMI"). It was _not_ about console > > handling. The reason was to modify the default behavior under NMI > > and store the messages directly into the main log buffer. > > > > When I think about it. The original fix was not correct. We should have > > modified the context only when ftrace_dump() was really called under NMI: > > > > if (in_nmi()) > > printk_nmi_direct_enter(); > > > > By other words. We should try to show the messages on the console > > when ftrace_dump()/panic() is not called from NMI. It will help > > to see all messages even when the ftrace buffers are bigger > > than printk() ones. > > > > And we do not need any special handling here for NMI. vprintk() > > in printk/printk_safe.c will do the right thing for us. > > Agreed. We need to mention this behavior change in the commit > message. Perhaps this as the commit message: > > All NMI contexts are handled the same as the safe context: store the > message and defer printing. There is no need to have special NMI > context tracking for this. Using in_nmi() is enough. > > There are several parts of the kernel that are manually calling into > the printk NMI context tracking in order to cause general printk > deferred printing: > > arch/arm/kernel/smp.c > arch/powerpc/kexec/crash.c > kernel/trace/trace.c > > For arm/kernel/smp.c and powerpc/kexec/crash.c, provide a new > function pair printk_deferred_enter/exit that explicitly achieves the > same objective. > > For ftrace, remove general printk deferring. This general deferrment > was added in commit 03fc7f9c99c1 ("printk/nmi: Prevent deadlock when > accessing the main log buffer in NMI"), but really should have only > been deferred when in NMI context. Since vprintk() now checks for > NMI context when deciding to defer, ftrace does not need any special > handling. I would make it less focused on the deferring part and try to explain the original purpose here, something like: "For ftrace, remove the printk context manipulation completely. It was added in commit 03fc7f9c99c1 ("printk/nmi: Prevent deadlock when accessing the main log buffer in NMI"). The purpose was to enforce storing messages directly into the ring buffer even in NMI context. It really should have only modified the behavior in NMI context. There is no need for a special behavior any longer. All messages are always stored directly now. The console deferring is handled transparently in vprintk()." But I do not resist on it. And feel free to make it shorter. Best Regards, Petr