From patchwork Wed Dec 14 14:01:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 33222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp241758wrn; Wed, 14 Dec 2022 06:10:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vkmsc8RAN5g9S0uPz1tueOsC2zkmv5YwtTebkCkuFj/HPxKq1SrH+7yZU9gaKxdHWqjWM X-Received: by 2002:a17:906:d90:b0:7c0:bbab:22ea with SMTP id m16-20020a1709060d9000b007c0bbab22eamr22162225eji.46.1671027000047; Wed, 14 Dec 2022 06:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671027000; cv=none; d=google.com; s=arc-20160816; b=et3h8wqgPiW25lkprJS6sEkIpR8qpS6Rix/3s3HFmH/Og+jdoa4K7nfljz/deGkClf 3TB4QiUZENxXQB95/UgF5t6+t70MllFB0zsQFT1KlW3HUF0f+ynu3v9gZAW1dwlCM8fw /+3/NzGYyz+vsJ+7xHMpiLONMT71IRF0FQGxSJAIq8s19h2zn0kCvQ2ydw1copd2MDfN qKA4BN8qVBvmTnTqyourlK4zAXJIBtfETLorNjSLIFY8yoZBJDkI6tFt4k/xtMLIfbqR Yujc/KNIP4TMSfhgInjsbXdrk5UlX1QzZOV83XhRIkW3M92wujWtxZyVjzIqYrNL/TKB gmdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=4U5a5JbYGzYBbJ9WbdMbd52e5sk0Ubf+CizYR14X9TY=; b=FOLGRWF66iwpptlFIBogZjxtcSonD0yFlqam0oI/h4PTVKZ2Wa9fJYpkU8wddE+DkH j8/JbVGVpIPA42ket2m8Ulx6oJhZ4XCW0xEttKyGDgpm0s+o5T+QUL30nWa3slIXj8c6 tlw4doHjy80rRz0zJi+VlyQpDwzwD76Eh/+u5d5/4XMTOAt8mieef+iGZ3F2u65HFMZ/ sJ19NCdFVR298jf6vJdjQBYehx/z25f3DVSCNP2TOTHixLvefUsNnKYseIABf3nqvBYq DbRe3e+ro262Udbv7PpWhh0+IWKUKMh8R/M57LLnINL6OpSBVqb3mUPhrFTW56rqlsnj CZfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv14-20020a17090760ce00b007ae24f28400si4049409ejc.247.2022.12.14.06.09.34; Wed, 14 Dec 2022 06:10:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238615AbiLNOCk (ORCPT + 99 others); Wed, 14 Dec 2022 09:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238533AbiLNOCP (ORCPT ); Wed, 14 Dec 2022 09:02:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8DA11C21 for ; Wed, 14 Dec 2022 06:02:13 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id B7AEFB818D3 for ; Wed, 14 Dec 2022 14:02:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8641EC433A7; Wed, 14 Dec 2022 14:02:10 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1p5SKn-000gvm-24; Wed, 14 Dec 2022 09:02:09 -0500 Message-ID: <20221214140209.502652192@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 14 Dec 2022 09:01:40 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Petr Mladek , Sergei Shtylyov , "Guilherme G. Piccoli" Subject: [for-next][PATCH 7/8] tracing: Improve panic/die notifiers References: <20221214140133.608431204@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1752198807876820944?= X-GMAIL-MSGID: =?utf-8?q?1752198807876820944?= From: "Guilherme G. Piccoli" 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. Link: https://lkml.kernel.org/r/20220819221731.480795-7-gpiccoli@igalia.com Cc: Petr Mladek Cc: Sergei Shtylyov Signed-off-by: Guilherme G. Piccoli Signed-off-by: Steven Rostedt (Google) --- 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 548890c7c0f5..6d7ef130f57e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -9876,40 +9875,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) + return NOTIFY_DONE; + + /* The die notifier requires DIE_OOPS to trigger */ + if (self == &trace_die_notifier && ev != DIE_OOPS) + return NOTIFY_DONE; + + ftrace_dump(ftrace_dump_on_oops); + + 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.