tracing: Remove trace_printk.h from kernel.h
Subsystems (23)
cover tracing: Remove trace_printk.h from kernel.h
Remove trace_printk.h by creating a trace_controls.h for those places that need access to tracing prototypes like tracing_off() and for the places that need trace_printk() directly, to have it included directly.
Changse since v4: https://lore.kernel.org/linux-trace-kernel/[email protected]/
- Forward ported to latest kernel.
- Added lockdep patch for _THIS_IP_
https://patch.msgid.link/[email protected]
Steven Rostedt (3):
lockdep: Add #include <linux/instruction_pointer.h> to lockdep.h
tracing: Move non-trace_printk prototypes into trace_controls.h
tracing: Remove trace_printk.h from kernel.h
----
arch/powerpc/kvm/book3s_xics.c | 1 + arch/powerpc/xmon/xmon.c | 1 + arch/s390/kernel/ipl.c | 1 + arch/s390/kernel/machine_kexec.c | 1 + drivers/gpu/drm/i915/gt/intel_gtt.h | 1 + drivers/gpu/drm/i915/i915_gem.h | 2 ++ drivers/hwtracing/stm/dummy_stm.c | 1 + drivers/infiniband/hw/hfi1/trace_dbg.h | 1 + drivers/tty/sysrq.c | 1 + drivers/usb/early/xhci-dbc.c | 1 + fs/ext4/inline.c | 1 + include/linux/ftrace.h | 2 ++ include/linux/kernel.h | 1 - include/linux/lockdep.h | 1 + include/linux/sunrpc/debug.h | 1 + include/linux/trace_controls.h | 54 ++++++++++++++++++++++++++++++++ include/linux/trace_printk.h | 56 ++-------------------------------- include/trace/trace_events.h | 2 ++ kernel/debug/debug_core.c | 1 + kernel/panic.c | 1 + kernel/rcu/rcu.h | 1 + kernel/rcu/rcutorture.c | 1 + kernel/trace/ring_buffer_benchmark.c | 1 + kernel/trace/trace.h | 1 + kernel/trace/trace_benchmark.c | 1 + lib/sys_info.c | 1 + samples/fprobe/fprobe_example.c | 1 + samples/ftrace/ftrace-direct-too.c | 1 - samples/trace_printk/trace-printk.c | 1 + 29 files changed, 85 insertions(+), 55 deletions(-) create mode 100644 include/linux/trace_controls.h
PATCH 1/3 lockdep: Add #include <linux/instruction_pointer.h> to lockdep.h
From: Steven Rostedt <[email protected]>
On 32bit x86, _THIS_IP_ is not defined in asm/linkage.h. It happens to get included into lockdep.h via kernel.h pulling in trace_printk.h which includes instruction_pointer.h that has _THIS_IP_ defined when linkage.h does not.
In order to remove trace_printk.h from kernel.h, have lockdep.h include instruction_pointer.h directly.
--- include/linux/lockdep.h | 1 + 1 file changed, 1 insertion(+)
include/linux/lockdep.h +1 -0
@@ -22,6 +22,7 @@ struct task_struct;#include <linux/list.h> #include <linux/debug_locks.h> #include <linux/stacktrace.h> +#include <linux/instruction_pointer.h> /* In case _THIS_IP_ isn't defined */ static inline void lockdep_copy_map (struct lockdep_map *to,struct lockdep_map *from)
Signature · 1 line
2.53.0
PATCH 2/3 tracing: Move non-trace_printk prototypes into trace_controls.h
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Remove the prototypes of the code that is not associated with trace_printk() from trace_printk.h.
These control functions as well as ftrace_dump() and trace_dump_stack() are used in cases where things go wrong. The main use case is to do a trace_dump_stack(); tracing_off(); ftrace_dump(); in a place that detected that something went wrong, whereas, trace_printk() is added to normal code during debugging and removed before committing upstream. The dump code is fine to keep in production.
--- arch/powerpc/xmon/xmon.c | 1 + arch/s390/kernel/ipl.c | 1 + arch/s390/kernel/machine_kexec.c | 1 + drivers/gpu/drm/i915/i915_gem.h | 1 + drivers/tty/sysrq.c | 1 + include/linux/trace_controls.h | 54 ++++++++++++++++++++++++++++++++ include/linux/trace_printk.h | 51 ------------------------------ kernel/debug/debug_core.c | 1 + kernel/panic.c | 1 + kernel/rcu/rcu.h | 1 + kernel/rcu/rcutorture.c | 1 + kernel/trace/trace.h | 1 + kernel/trace/trace_benchmark.c | 1 + lib/sys_info.c | 1 + 14 files changed, 66 insertions(+), 51 deletions(-) create mode 100644 include/linux/trace_controls.h
arch/powerpc/xmon/xmon.c +1 -0
@@ -27,6 +27,7 @@#include <linux/highmem.h> #include <linux/security.h> #include <linux/debugfs.h> +#include <linux/trace_controls.h> #include <asm/ptrace.h> #include <asm/smp.h>
arch/s390/kernel/ipl.c +1 -0
@@ -22,6 +22,7 @@#include <linux/debug_locks.h> #include <linux/vmalloc.h> #include <linux/secure_boot.h> +#include <linux/trace_controls.h> #include <asm/asm-extable.h> #include <asm/machine.h> #include <asm/diag.h>
arch/s390/kernel/machine_kexec.c +1 -0
@@ -12,6 +12,7 @@#include <linux/delay.h> #include <linux/reboot.h> #include <linux/ftrace.h> +#include <linux/trace_controls.h> #include <linux/debug_locks.h> #include <linux/cpufeature.h> #include <asm/guarded_storage.h>
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -116,6 +116,7 @@ int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file);#endif #if IS_ENABLED (CONFIG_DRM_I915_TRACE_GEM ) +#include <linux/trace_controls.h> #define GEM_TRACE (...) trace_printk(__VA_ARGS__)#define GEM_TRACE_ERR (...) do { \ pr_err(__VA_ARGS__); \
drivers/tty/sysrq.c +1 -0
@@ -324,6 +324,7 @@ static const struct sysrq_key_op sysrq_showstate_blocked_op = { };#ifdef CONFIG_TRACING +#include <linux/trace_controls.h> #include <linux/ftrace.h> static void sysrq_ftrace_dump (u8 key)
include/linux/trace_controls.h new file +54 -0
54 lines not on this page · raw message
include/linux/trace_printk.h +0 -51
77 lines not on this page · raw message
kernel/debug/debug_core.c +1 -0
@@ -27,6 +27,7 @@#define pr_fmt (fmt) "KGDB: " fmt +#include <linux/trace_controls.h> #include <linux/pid_namespace.h> #include <linux/clocksource.h> #include <linux/serial_core.h>
kernel/panic.c +1 -0
@@ -9,6 +9,7 @@* This function is used through-out the kernel (including mm and fs) * to indicate a major problem. */ +#include <linux/trace_controls.h> #include <linux/debug_locks.h> #include <linux/sched/debug.h> #include <linux/interrupt.h>
kernel/rcu/rcu.h +1 -0
@@ -12,6 +12,7 @@#include <linux/slab.h> #include <trace/events/rcu.h> +#include <linux/trace_controls.h> /* * Grace-period counter management.
kernel/rcu/rcutorture.c +1 -0
@@ -39,6 +39,7 @@#include <linux/srcu.h> #include <linux/slab.h> #include <linux/trace_clock.h> +#include <linux/trace_controls.h> #include <asm/byteorder.h> #include <linux/torture.h> #include <linux/vmalloc.h>
kernel/trace/trace.h +1 -0
@@ -22,6 +22,7 @@#include <linux/ctype.h> #include <linux/once_lite.h> #include <linux/ftrace_regs.h> +#include <linux/trace_controls.h> #include <linux/llist.h> #include "pid_list.h"
kernel/trace/trace_benchmark.c +1 -0
@@ -3,6 +3,7 @@#include <linux/module.h> #include <linux/kthread.h> #include <linux/trace_clock.h> +#include <linux/trace_controls.h> #define CREATE_TRACE_POINTS #include "trace_benchmark.h"
lib/sys_info.c +1 -0
@@ -8,6 +8,7 @@#include <linux/ftrace.h> #include <linux/nmi.h> #include <linux/sched/debug.h> +#include <linux/trace_controls.h> #include <linux/string.h> #include <linux/sysctl.h>
Signature · 1 line
2.53.0
PATCH 3/3 tracing: Remove trace_printk.h from kernel.h
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
There have been complaints about trace_printk.h causing more build time for being in kernel.h if it changes. There is also an effort to clean up kernel.h to have it not include unneeded header files. Move trace_printk.h out of kernel.h and place it in the headers and C files that use it.
--- arch/powerpc/kvm/book3s_xics.c | 1 + drivers/gpu/drm/i915/gt/intel_gtt.h | 1 + drivers/gpu/drm/i915/i915_gem.h | 1 + drivers/hwtracing/stm/dummy_stm.c | 1 + drivers/infiniband/hw/hfi1/trace_dbg.h | 1 + drivers/usb/early/xhci-dbc.c | 1 + fs/ext4/inline.c | 1 + include/linux/ftrace.h | 2 ++ include/linux/kernel.h | 1 - include/linux/sunrpc/debug.h | 1 + include/linux/trace_printk.h | 5 +++-- include/trace/trace_events.h | 2 ++ kernel/trace/ring_buffer_benchmark.c | 1 + samples/fprobe/fprobe_example.c | 1 + samples/ftrace/ftrace-direct-too.c | 1 - samples/trace_printk/trace-printk.c | 1 + 16 files changed, 18 insertions(+), 4 deletions(-)
arch/powerpc/kvm/book3s_xics.c +1 -0
@@ -26,6 +26,7 @@#if 1 #define XICS_DBG(fmt...) do { } while (0)#else +#include <linux/trace_printk.h> #define XICS_DBG(fmt...) trace_printk(fmt)#endif
drivers/gpu/drm/i915/gt/intel_gtt.h +1 -0
@@ -35,6 +35,7 @@#define I915_GFP_ALLOW_FAIL (GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN)#if IS_ENABLED (CONFIG_DRM_I915_TRACE_GTT ) +#include <linux/trace_printk.h> #define GTT_TRACE (...) trace_printk(__VA_ARGS__)#else #define GTT_TRACE (...)
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -117,6 +117,7 @@ int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file);#if IS_ENABLED (CONFIG_DRM_I915_TRACE_GEM )#include <linux/trace_controls.h> +#include <linux/trace_printk.h> #define GEM_TRACE (...) trace_printk(__VA_ARGS__)#define GEM_TRACE_ERR (...) do { \ pr_err(__VA_ARGS__); \
drivers/hwtracing/stm/dummy_stm.c +1 -0
@@ -8,6 +8,7 @@*/ #undef DEBUG +#include <linux/trace_printk.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h>
drivers/infiniband/hw/hfi1/trace_dbg.h +1 -0
@@ -103,6 +103,7 @@ __hfi1_trace_def(IOCTL);*/ #ifdef HFI1_EARLY_DBG +#include <linux/trace_printk.h> #define hfi1_dbg_early (fmt, ...) \ trace_printk(fmt, ##__VA_ARGS__)#else
drivers/usb/early/xhci-dbc.c +1 -0
@@ -30,6 +30,7 @@ static struct xdbc_state xdbc;static bool early_console_keep;#ifdef XDBC_TRACE +#include <linux/trace_printk.h> #define xdbc_trace trace_printk#else static inline void xdbc_trace (const char *fmt, ...) { }
fs/ext4/inline.c +1 -0
@@ -943,6 +943,7 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping, }#ifdef INLINE_DIR_DEBUG +#include <linux/trace_printk.h> void ext4_show_inline_dir (struct inode *dir,struct buffer_head *bh,void *inline_start,int inline_size) {
include/linux/ftrace.h +2 -0
@@ -8,6 +8,8 @@#define _LINUX_FTRACE_H#include <linux/trace_recursion.h> +#include <linux/trace_controls.h> +#include <linux/trace_printk.h> #include <linux/trace_clock.h> #include <linux/jump_label.h> #include <linux/kallsyms.h>
include/linux/kernel.h +0 -1
@@ -31,7 +31,6 @@#include <linux/build_bug.h> #include <linux/sprintf.h> #include <linux/static_call_types.h> -#include <linux/trace_printk.h> #include <linux/util_macros.h> #include <linux/wordpart.h>
include/linux/sunrpc/debug.h +1 -0
@@ -29,6 +29,7 @@ extern unsigned int nlm_debug;# define ifdebug (fac) if (unlikely(rpc_debug & RPCDBG_##fac))# if IS_ENABLED (CONFIG_SUNRPC_DEBUG_TRACE ) +# include <linux/trace_printk.h> # define __sunrpc_printk (fmt, ...) trace_printk(fmt, ##__VA_ARGS__)# else # define __sunrpc_printk (fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__)
include/linux/trace_printk.h +3 -2
@@ -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> #ifdef CONFIG_TRACING static inline __printf(1, 2)
@@ -147,5 +148,5 @@ ftrace_vprintk(const char *fmt, va_list ap)return 0 ; }#endif /* CONFIG_TRACING */ - +#endif /* !defined(__ASSEMBLY__) && !defined(__GENKSYMS__) && !defined(BUILD_VDSO) */ #endif
include/trace/trace_events.h +2 -0
@@ -18,7 +18,9 @@* in the structure. */ +#include <linux/trace_controls.h> #include <linux/trace_events.h> +#include <linux/trace_printk.h> #include <linux/btf_ids.h> #ifndef TRACE_SYSTEM_VAR
kernel/trace/ring_buffer_benchmark.c +1 -0
@@ -5,6 +5,7 @@* Copyright (C) 2009 Steven Rostedt <[email protected]> */ #include <linux/ring_buffer.h> +#include <linux/trace_printk.h> #include <linux/completion.h> #include <linux/kthread.h> #include <uapi/linux/sched/types.h>
samples/fprobe/fprobe_example.c +1 -0
@@ -12,6 +12,7 @@#define pr_fmt (fmt) "%s: " fmt, __func__ +#include <linux/trace_printk.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/fprobe.h>
samples/ftrace/ftrace-direct-too.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only #include <linux/module.h> -#include <linux/mm.h> /* for handle_mm_fault() */ #include <linux/ftrace.h> #if !defined(CONFIG_ARM64 ) && !defined(CONFIG_PPC32 )
samples/trace_printk/trace-printk.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only +#include <linux/trace_printk.h> #include <linux/module.h> #include <linux/kthread.h> #include <linux/irq_work.h>
Signature · 1 line
2.53.0