Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp264852imn; Wed, 3 Aug 2022 02:56:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vMfQe1g7BQLvfVQmZNt35ugShBcfHEseOIYXmwYj27jLDPVqOKQlo3oTSiz3Cicy0Csyj X-Received: by 2002:a17:907:2c42:b0:730:aacf:1b69 with SMTP id hf2-20020a1709072c4200b00730aacf1b69mr3138909ejc.381.1659520602960; Wed, 03 Aug 2022 02:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659520602; cv=none; d=google.com; s=arc-20160816; b=UYSgYFqtsPlwGA/sCN2Az5Jlmrf5TOloO2hYLmQlIyHGoRQg9ystl5fBXg3EjQDzm/ Gg0y1ALKY4xOJsK2GamV0vsuae0VANXAbeQ8jd0reyGZY6kasN3prAjDzAsYyH8LzDoV NkDo9Wfar0mF8XDKPV+xIdC8O+bjWmxTyZ1aWsVwobOR/c1ORV5XIhQN+GB3eh54CN+P taaoXcA9vBeNqNrEPOkjigDOq24WGQDtJOEQHDw21uFmi4EAKZgEaAt4HWqTShf8PjNz siiekU0zZKmDO0QJrze3e88GwIAX+oVWs5qvYkvuToF83TDB2EoORis7ozPzcq1uWSnf 1wNg== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=kc/D6eFmNXdc/PlI526NFHqk9sVSNen1MCJD2u5ZFKQ=; b=kPoU3pSmNqLUWy5Y6BS+MoiCEikC2uFhJ3uJRnYHQUmduUPdDfZ6m/5pqrJPJRsECC ZiZzOyF7wNWtKsmkmIkUEItrEyZ6ZhYOtG1SQzLBYQT5ZmsExmsWYXWlgaBtDXC60kqX 06JSt3HZ+pgTCCI+ptQsmuz+aHUk/vGulFvHJVCZCEUutOLHKrPiICZJkQRqe9rnQVci 2jwTlCYUZGoMMO50XsMCbZZN1c85KRLINIGN1ngVdoJVAsLVcUfwCuo0lZbgIt1Eq+ty eUTjrKTtVinwKFpfhGISvuwviWl3NWIfLI3JEaqFM1dui9z/WWBDyo1Igm9c9rneI/PO gkaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QqawPrTO; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg6-20020a170907a40600b007307d1063besi4983335ejc.89.2022.08.03.02.56.18; Wed, 03 Aug 2022 02:56:42 -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=@redhat.com header.s=mimecast20190719 header.b=QqawPrTO; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237737AbiHCJxw (ORCPT + 99 others); Wed, 3 Aug 2022 05:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237511AbiHCJxb (ORCPT ); Wed, 3 Aug 2022 05:53:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2950746D8D for ; Wed, 3 Aug 2022 02:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659520389; h=from:from:reply-to:subject:subject: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=kc/D6eFmNXdc/PlI526NFHqk9sVSNen1MCJD2u5ZFKQ=; b=QqawPrTOQznULcwRmjh0WvDTrRFKIjlPGHJ8jkQtPOAr8yMKH4Cgt5ynCUwEoAZ3vWAvZ2 AUP6VbU4duxLSoTU24WyHf3rRzNFUwtLeYQG8hMYa6Z9ckD2mvEPFuAmKNyO9pBb5U7IX6 5+9V5DfXCWyCdJHT+1kq2mYhZRAXLxc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-VvdGeYMLPhaxQBkXtxi7Zw-1; Wed, 03 Aug 2022 05:53:03 -0400 X-MC-Unique: VvdGeYMLPhaxQBkXtxi7Zw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A5E185A584; Wed, 3 Aug 2022 09:53:01 +0000 (UTC) Received: from localhost (ovpn-13-216.pek2.redhat.com [10.72.13.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F5EC2166B26; Wed, 3 Aug 2022 09:53:00 +0000 (UTC) Date: Wed, 3 Aug 2022 17:52:57 +0800 From: Baoquan He To: "Guilherme G. Piccoli" Cc: akpm@linux-foundation.org, pmladek@suse.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, x86@kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, halves@canonical.com, fabiomirmar@gmail.com, alejandro.j.jimenez@oracle.com, andriy.shevchenko@linux.intel.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, d.hatayama@jp.fujitsu.com, dave.hansen@linux.intel.com, dyoung@redhat.com, feng.tang@intel.com, gregkh@linuxfoundation.org, mikelley@microsoft.com, hidehiro.kawai.ez@hitachi.com, jgross@suse.com, john.ogness@linutronix.de, keescook@chromium.org, luto@kernel.org, mhiramat@kernel.org, mingo@redhat.com, paulmck@kernel.org, peterz@infradead.org, rostedt@goodmis.org, senozhatsky@chromium.org, stern@rowland.harvard.edu, tglx@linutronix.de, vgoyal@redhat.com, vkuznets@redhat.com, will@kernel.org, Sergei Shtylyov Subject: Re: [PATCH v2 08/13] tracing: Improve panic/die notifiers Message-ID: References: <20220719195325.402745-1-gpiccoli@igalia.com> <20220719195325.402745-9-gpiccoli@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 08/03/22 at 05:36pm, Baoquan He wrote: > On 07/19/22 at 04:53pm, Guilherme G. Piccoli wrote: > > Currently the tracing dump_on_oops feature is implemented > > through separate notifiers, one for die/oops and the other > > for panic - given they have the same functionality, let's > > unify them. > > > > Also improve the function comment and change the priority of > > the notifier to make it execute earlier, avoiding showing useless > > trace data (like the callback names for the other notifiers); > > finally, we also removed an unnecessary header inclusion. > > > > Cc: Petr Mladek > > Cc: Sergei Shtylyov > > Cc: Steven Rostedt > > Signed-off-by: Guilherme G. Piccoli > > > > --- > > > > V2: > > - Different approach; instead of using IDs to distinguish die and > > panic events, rely on address comparison like other notifiers do > > and as per Petr's suggestion; > > > > - Removed ACK from Steven since the code changed. > > > > kernel/trace/trace.c | 55 ++++++++++++++++++++++---------------------- > > 1 file changed, 27 insertions(+), 28 deletions(-) > > > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > > index b8dd54627075..2a436b645c70 100644 > > --- a/kernel/trace/trace.c > > +++ b/kernel/trace/trace.c > > @@ -19,7 +19,6 @@ > > #include > > #include > > #include > > -#include > > #include > > #include > > #include > > @@ -9777,40 +9776,40 @@ static __init int tracer_init_tracefs(void) > > > > fs_initcall(tracer_init_tracefs); > > > > -static int trace_panic_handler(struct notifier_block *this, > > - unsigned long event, void *unused) > > -{ > > - if (ftrace_dump_on_oops) > > - ftrace_dump(ftrace_dump_on_oops); > > - return NOTIFY_OK; > > -} > > +static int trace_die_panic_handler(struct notifier_block *self, > > + unsigned long ev, void *unused); > > > > static struct notifier_block trace_panic_notifier = { > > - .notifier_call = trace_panic_handler, > > - .next = NULL, > > - .priority = 150 /* priority: INT_MAX >= x >= 0 */ > > + .notifier_call = trace_die_panic_handler, > > + .priority = INT_MAX - 1, > > }; > > > > -static int trace_die_handler(struct notifier_block *self, > > - unsigned long val, > > - void *data) > > -{ > > - switch (val) { > > - case DIE_OOPS: > > - if (ftrace_dump_on_oops) > > - ftrace_dump(ftrace_dump_on_oops); > > - break; > > - default: > > - break; > > - } > > - return NOTIFY_OK; > > -} > > - > > static struct notifier_block trace_die_notifier = { > > - .notifier_call = trace_die_handler, > > - .priority = 200 > > + .notifier_call = trace_die_panic_handler, > > + .priority = INT_MAX - 1, > > }; > > > > +/* > > + * The idea is to execute the following die/panic callback early, in order > > + * to avoid showing irrelevant information in the trace (like other panic > > + * notifier functions); we are the 2nd to run, after hung_task/rcu_stall > > + * warnings get disabled (to prevent potential log flooding). > > + */ > > +static int trace_die_panic_handler(struct notifier_block *self, > > + unsigned long ev, void *unused) > > +{ > > + if (!ftrace_dump_on_oops) > > + goto out; > > + > > + if (self == &trace_die_notifier && ev != DIE_OOPS) > > + goto out; > > Although the switch-case code of original trace_die_handler() is werid, > this unification is not much more comfortable. Just personal feeling > from code style, not strong opinion. Leave it to trace reviewers. Please ignore this comment. I use b4 to grab this patchset and applied, and started to check patch one by one. Then I realize it's all about cleanups which have got consensus in earlier rounds. Hope it can be merged when other people's concern is addressed, the whole series looks good to me, I have no strong concern to them. > > > + > > + ftrace_dump(ftrace_dump_on_oops); > > + > > +out: > > + return NOTIFY_DONE; > > +} > > + > > /* > > * printk is set to max of 1024, we really don't need it that big. > > * Nothing should be printing 1000 characters anyway. > > -- > > 2.37.1 > > >