All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Yury Norov <ynorov@nvidia.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Ao Sun <ao.sun@transsion.com>, David Carlier <devnexen@gmail.com>,
	Karl Mehltretter <kmehltretter@gmail.com>,
	Martin Kaiser <martin@kaiser.cx>,
	Pengpeng Hou <pengpeng@iscas.ac.cn>,
	Qian-Yu Lin <tiffany019230@gmail.com>,
	Rik van Riel <riel@surriel.com>, Rosen Penev <rosenp@gmail.com>,
	Shuvam Pandey <shuvampandey1@gmail.com>,
	Vineeth Pillai <vineeth@bitbyteword.org>,
	Yash Suthar <yashsuthar983@gmail.com>,
	Yu Peng <pengyu@kylinos.cn>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [GIT PULL] tracing: Updates for 7.2
Date: Sat, 20 Jun 2026 18:19:57 -0400	[thread overview]
Message-ID: <20260620181957.115d662c@fedora> (raw)
In-Reply-To: <CAHk-=wiH8muwBL8FJ7iThgqvWY790ocWxPZ8tGtfQq=A3ErO3A@mail.gmail.com>

On Fri, 19 Jun 2026 07:35:15 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> The two are not the same:
> 
>   $ git grep -wl printk | wc -l
>   3212
>   $ git grep -wl trace_printk | wc -l
>   50
> 
> and making them sound remotely similar is just making you look dishonst.
> 
> Look, the attached patch makes my defconfig build cleanly, and makes a
> 
>   $ touch include/linux/trace_printk.h
> 
> cause my recompile to build just a handful of files. While touching
> linux/kernel.h causes thousands of files to be re-build.
> 
> That's a whopping
> 
>  6 files changed, 6 insertions(+), 1 deletion(-)
> 
> to make my tree build without including <linux/trace_printk.h> everywhere.
> 
> Now, that's _just_ my defconfig, and the full build clearly has a
> handful of other cases. From a quick look, mostly in the 'samples'
> directory.
> 
> But it looks like a *handful* of other cases.
> 
> Now, if the same was true for printk(), I'd happily split that into
> some other header too.

I totally agree that trace_printk.h should not be added to kernel.h for
debugging if printk.h is also not included for that purpose. But you
are stating that it is included because everything "uses" it. But
really, if we are worried about getting rid of adding headers that are
not used, I think it would be a worth while exercise to remove printk.h
from kernel.h to have it included only where it is used.

That said, I'm also happy to get rid of trace_printk.h from kernel.h if
there's an easy way to have it included for debugging purposes.

Are you OK with the following approach? Basically, it adds
"CONFIG_TRACE_PRINTK_DEBUGGING" config to be set by those that want to
use it for debugging. When set, it will add to KBUILD_CFLAGS:

  -include $(srctree)/include/linux/trace_printk.h

which is basically the same as having it in kernel.h but without adding
the "burden" to those that don't want it (like yourself).

This would allow the best of both words:

diff --git a/Makefile b/Makefile
index d33a7cadd237..84236890a806 100644
--- a/Makefile
+++ b/Makefile
@@ -839,6 +839,10 @@ ifdef CONFIG_FUNCTION_TRACER
   CC_FLAGS_FTRACE := -pg
 endif
 
+ifdef CONFIG_TRACE_PRINTK_DEBUGGING
+  LINUXINCLUDE += -include $(srctree)/include/linux/trace_printk.h
+endif
+
 ifdef CONFIG_TRACEPOINTS
 # To check for unused tracepoints (tracepoints that are defined but never
 # called), run with:
diff --git a/include/linux/trace_printk.h b/include/linux/trace_printk.h
index 2670ec7f4262..3fe5fc5c6a2a 100644
--- a/include/linux/trace_printk.h
+++ b/include/linux/trace_printk.h
@@ -1,11 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _LINUX_TRACE_PRINTK_H
 #define _LINUX_TRACE_PRINTK_H
+#if !defined(__ASSEMBLY__) && !defined(__GENKSYMS__) && !defined(BUILD_VDSO)
 
-#include <linux/compiler_attributes.h>
 #include <linux/instruction_pointer.h>
 #include <linux/stddef.h>
 #include <linux/stringify.h>
+#include <linux/stdarg.h>
 
 /*
  * General tracing related utility functions - trace_printk(),
@@ -199,5 +200,5 @@ ftrace_vprintk(const char *fmt, va_list ap)
 }
 static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 #endif /* CONFIG_TRACING */
-
+#endif /* !defined(__ASSEMBLY__) && !defined(__GENKSYMS__) */
 #endif
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index e130da35808f..e305b27ca029 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -210,6 +210,16 @@ menuconfig FTRACE
 
 if FTRACE
 
+config TRACE_PRINTK_DEBUGGING
+	bool "Debug with trace_printk()"
+	help
+	  If you need to debug with trace_printk(), instead of adding
+	  include <linux/trace_printk.h> to every file you add a trace_printk
+	  to, select this option and it will add trace_printk.h to all code
+	  to allow tracing with trace_printk() with.
+
+	  If in doubt, select N
+
 config TRACEFS_AUTOMOUNT_DEPRECATED
 	bool "Automount tracefs on debugfs [DEPRECATED]"
 	depends on TRACING


-- Steve

  parent reply	other threads:[~2026-06-20 22:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 22:01 [GIT PULL] tracing: Updates for 7.2 Steven Rostedt
2026-06-19  4:23 ` Linus Torvalds
2026-06-19 12:15   ` Steven Rostedt
2026-06-19 14:35     ` Linus Torvalds
2026-06-19 15:40       ` Sebastian Andrzej Siewior
2026-06-19 15:43         ` Linus Torvalds
2026-06-19 18:30           ` Sebastian Andrzej Siewior
2026-06-19 19:07             ` Linus Torvalds
2026-06-19 20:28               ` Thomas Gleixner
2026-06-19 20:55                 ` Linus Torvalds
2026-06-20  9:22                   ` Willy Tarreau
2026-06-19 22:28               ` Linus Torvalds
2026-06-19 15:54       ` Steven Rostedt
2026-06-19 16:29         ` Linus Torvalds
2026-06-20 20:24       ` Julia Lawall
2026-06-20 22:19       ` Steven Rostedt [this message]
2026-06-20 22:39         ` Linus Torvalds
2026-06-20 23:43           ` Steven Rostedt
2026-06-21  0:18             ` Linus Torvalds
2026-06-21  6:34               ` Steven Rostedt
2026-06-21  7:10               ` Steven Rostedt
2026-06-19 15:19   ` Yury Norov
2026-06-19 15:40     ` Linus Torvalds
2026-06-19 22:18       ` Yury Norov
2026-06-19  4:38 ` pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260620181957.115d662c@fedora \
    --to=rostedt@goodmis.org \
    --cc=ao.sun@transsion.com \
    --cc=bigeasy@linutronix.de \
    --cc=devnexen@gmail.com \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@kaiser.cx \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=pengpeng@iscas.ac.cn \
    --cc=pengyu@kylinos.cn \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rosenp@gmail.com \
    --cc=shuvampandey1@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tiffany019230@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vineeth@bitbyteword.org \
    --cc=yashsuthar983@gmail.com \
    --cc=ynorov@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.