Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1573449rwb; Thu, 15 Dec 2022 11:47:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CgCrVeUHYUSl50j+p5vjIDZFaIZvDTxbSDuLOw2vzBFilons08AIsRJSyrJGntKepFdqm X-Received: by 2002:a05:6a20:9595:b0:a3:ff0b:d1bc with SMTP id iu21-20020a056a20959500b000a3ff0bd1bcmr32134801pzb.62.1671133651254; Thu, 15 Dec 2022 11:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671133651; cv=none; d=google.com; s=arc-20160816; b=IbxG6wFZC9HN5inPfhC/DBJgocUNV7zZEUrDcQDVlhtaAX7lPTLKm7L+i0kB2AZ5Bm WOp6ga23Xqj5x76F+ox3WcGDC+UGP+gank0vo8DPoQvB2sINF5zb0+c377uDaeJApzqk 7dhCv6RZ5YPok3IKHwuGqHHWtit3k6tjWjleZRoYIiMSFLBZMJ6WWskAYRqHhGqngkrw GKpEd8GZyhnhbWBNYf+tg6whx+2sdjX/QJ9VMI3cogpUXcbb87iQ/eRVvuThTcDhHlB3 N+EJH/gFOke0i05py6aJsjSVIA+/gI/vs4lu5A9efNvJLQc0VtvKAYVPp2JDnI10rolf hK4A== 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=+8kdbca7RYmzghu3wrDFH9WKgOWAt7+jGRtzBcbGXvg=; b=biMfyUJ1sa7ahsVRUsAua3d1G0d6EIbeVXPrickMufm5aItf1eOVnCfeiRHaVOOUWT LhcQikIbKrwiYHXXCCWyJ4W7lAYXUCv4kYiN2IsaVPZ7BZ4BJMykmEXzG52jqUuQGovn uaWTQcsVcsByJVe6CEcWbc3Kgru5FjYyK+ZBq+KAKHrlciy9pivjytMyGX8oMHBUL3eD OtMlCRQukbZt4Hy2792mStqtEYnqbct35jjhOQKLJ0bvTDri6I6VkuAOl36tGYnRDzas d7bfpprSkqHfxqM9toavXPSE697B24pVjsRhDjs41APvMm8jfV7qkf7G8Ct0RUN5bzwz GCWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=RDxuf4vW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q73-20020a17090a1b4f00b002189516ee01si67865pjq.100.2022.12.15.11.47.20; Thu, 15 Dec 2022 11:47:31 -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=@joelfernandes.org header.s=google header.b=RDxuf4vW; 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 S230337AbiLOSqB (ORCPT + 68 others); Thu, 15 Dec 2022 13:46:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiLOSpm (ORCPT ); Thu, 15 Dec 2022 13:45:42 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B08260B for ; Thu, 15 Dec 2022 10:45:39 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id a16so263083qtw.10 for ; Thu, 15 Dec 2022 10:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+8kdbca7RYmzghu3wrDFH9WKgOWAt7+jGRtzBcbGXvg=; b=RDxuf4vWN8ZO5ssFcc25XiKKo/4GxNXFK5YWWvzMeoCeWVtkwg58xezK7KBo9Ss9xz cRmdZLa3PiR4GXoO+r7xTAIKFue3kCyWjSE9qpLAFUpETnMGbso2nsUUG+D7ToOMdWMt aeuSy8tbFKDtZg9a5LPo8i60QdC0Nq7oz1EM8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+8kdbca7RYmzghu3wrDFH9WKgOWAt7+jGRtzBcbGXvg=; b=PwnO5Ms5wJsS72r7+h7Awuw0HxOdJg0m0ercigQKAIUGUzS5x8NJoBlJIYrlRERtdR ylcTg9ZCgWluTG6gG4QP25LG6CFF3spxaKoIQzOobDF5M4NU+lvOOQqNO5pfAwnk25Ko FESEkKXmckzLDv4B+p2i+95DyBhb15itYLCVC2Nc4BuiPSIlunCEN3zQA6J6hwPbik1b jr0schNscN4yPpeFacEyBt157Z8L1uxKbM4cLSp6VcJBELCQ9JI5eqCk3rd+MkZDh31V 4qe4Dq1xZ6JM7+Vu+lS7ilRWz6CVVldg0Em8+Sb6hxwVYE1+gU94DDpCY+vVqI1k0OX7 ig7Q== X-Gm-Message-State: AFqh2konzVna+7Nw/hNqUn8BG5Rntk0BpPKOu28soZzt2UmemK88FE+E yDBsnOiJ/CuathpeG0JdO6cavQ== X-Received: by 2002:ac8:668d:0:b0:3a9:1ada:930f with SMTP id d13-20020ac8668d000000b003a91ada930fmr4932696qtp.23.1671129938658; Thu, 15 Dec 2022 10:45:38 -0800 (PST) Received: from localhost (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id w5-20020a05620a444500b006eed75805a2sm13009205qkp.126.2022.12.15.10.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 10:45:37 -0800 (PST) Date: Thu, 15 Dec 2022 18:45:37 +0000 From: Joel Fernandes To: Steven Rostedt Cc: LKML , Linux Trace Kernel , linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , Masami Hiramatsu , Brian Norris , Ross Zwisler , Ching-lin Yu Subject: Re: [RFC][PATCH] ACPI: tracing: Have ACPI debug go to tracing ring buffer Message-ID: References: <20221214233106.69b2c01b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221214233106.69b2c01b@gandalf.local.home> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Hi Steve, On Wed, Dec 14, 2022 at 11:31:06PM -0500, Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > While debugging some firmware that was taking a bit of time to initialize, > I enabled ACPI_DEBUG and added a bit too much info to the debug_layer and > debug_level acpi command line options, and it made the computer not be > able to boot (too much info! or too much printk). > > I decided that this would be easier to handle if the acpi output was > written instead into the trace buffer. This also has the added benefit of > adding other trace events and seeing how ACPI interacts with the rest of > the system. > > Ideally, the ACPI trace should have proper trace events where data can be > stored more efficiently and be filtered and parsed better. But for now, > just writing the debug string into the buffer will suffice. This makes it > possible to enable all ACPI output (setting triggers on other events to > stop tracing, to not lose the data you are looking for). > > Even with all APCI debugging enable, the system continues to run perfectly > fine. > > Signed-off-by: Steven Rostedt (Google) > --- > > drivers/acpi/Kconfig | 13 +++++++++++++ > drivers/acpi/osl.c | 9 ++++++++- > include/trace/events/acpi.h | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 51 insertions(+), 1 deletion(-) > create mode 100644 include/trace/events/acpi.h > > diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig > index 473241b5193f..2dfeb3bf79a7 100644 > --- a/drivers/acpi/Kconfig > +++ b/drivers/acpi/Kconfig > @@ -389,6 +389,19 @@ config ACPI_DEBUG > Documentation/admin-guide/kernel-parameters.rst to control the type and > amount of debug output. > > +config ACPI_TRACE_PRINT > + bool "Write debug into trace buffer" > + depends on ACPI_DEBUG > + help > + Instead of writing to the console, write to the trace ring buffer. > + This is much faster than writing to the console, and can handle > + all events. > + > + Use the acpi.debug_layer and acpi.debug_level kernel command-line > + parameters documented in Documentation/firmware-guide/acpi/debug.rst and > + Documentation/admin-guide/kernel-parameters.rst to control the type and > + amount of debug output. > + > config ACPI_PCI_SLOT > bool "PCI slot detection driver" > depends on SYSFS && PCI > diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c > index 3269a888fb7a..eeed5fd782ab 100644 > --- a/drivers/acpi/osl.c > +++ b/drivers/acpi/osl.c > @@ -35,6 +35,9 @@ > #include > #include > > +#define CREATE_TRACE_POINTS > +#include > + > #include "acpica/accommon.h" > #include "internal.h" > > @@ -158,6 +161,8 @@ void acpi_os_vprintf(const char *fmt, va_list args) > #ifdef ENABLE_DEBUGGER > if (acpi_in_debugger) { > kdb_printf("%s", buffer); > + } else if (IS_ENABLED(CONFIG_ACPI_TRACE_PRINT)) { > + trace_acpi_print(buffer); Wouldn't it be better to also check trace_acpi_print_enabled() here in the else if() condition, along with IS_ENABLED()? That way if the CONFIG is enabled but the tracepoint is not enabled, at least the messages will go to dmesg instead of skipped. > } else { > if (printk_get_level(buffer)) > printk("%s", buffer); > @@ -165,7 +170,9 @@ void acpi_os_vprintf(const char *fmt, va_list args) > printk(KERN_CONT "%s", buffer); > } > #else > - if (acpi_debugger_write_log(buffer) < 0) { > + if (IS_ENABLED(CONFIG_ACPI_TRACE_PRINT)) { > + trace_acpi_print(buffer); > + } else if (acpi_debugger_write_log(buffer) < 0) { Ditto. Reviewed-by: Joel Fernandes (Google) thanks, - Joel > if (printk_get_level(buffer)) > printk("%s", buffer); > else > diff --git a/include/trace/events/acpi.h b/include/trace/events/acpi.h > new file mode 100644 > index 000000000000..dab4dd42b5d7 > --- /dev/null > +++ b/include/trace/events/acpi.h > @@ -0,0 +1,30 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM acpi > + > +#if !defined(_TRACE_ACPI_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_ACPI_H > + > +#include > + > +TRACE_EVENT(acpi_print, > + > + TP_PROTO(const char *buffer), > + > + TP_ARGS(buffer), > + > + TP_STRUCT__entry( > + __string(buffer, buffer) > + ), > + > + TP_fast_assign( > + __assign_str(buffer, buffer); > + ), > + > + TP_printk("%s", __get_str(buffer)) > +); > + > +#endif /* _TRACE_SOCK_H */ > + > +/* This part must be outside protection */ > +#include > -- > 2.35.1 >