Skip to contentSkip to conversation

kallsyms header cleanup

PATCH Superseded Tom Zanussi 2 participants 9 messages Apr 14, 2015

Subsystems (9)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover kallsyms header cleanup

During review of an unrelated patchset, the question was asked why module.h was included in code that wouldn't be a module and didn't do anything with modules [1].

The reason is that it uses kallsyms defines, but kallsyms.h doesn't include module.h, though it should because it uses MODULE_NAME_LEN. The code in question also didn't include kallsyms.h but relied on ftrace.h to pull it in. But ftrace.h no longer contains anything that needs kallsyms.h, and continues to include it only because other code expects it to.

This patchset is the start of cleaning all that up. It also adds explicit kallsyms.h includes and removes module.h includes for obvious cases in kernel/trace and lib/, where I happened to be working.

There are a bunch of other files that probably include module.h only for kallsyms, but I haven't gone through them yet. I can either resubmit this patchset after looking at all those, or can submit a follow-on patchset to this one assuming this is best way to do it...

[1] https://lkml.org/lkml/2015/4/4/70

Changes from v1:
- added KSYM_SYMBOL_LEN patches for fnic and slub
- separated tracing changes into KSYM_SYMBOL_LEN-only module.h changes
- fixed up bogus lib change from previous patchset
- separate patch to remove unnecessary tracing kallsyms.h and module.h usage

The following changes since commit 3cfb2f7976a2f9cfe48eda4e6d7e4ce74fee09e3:

Merge tag 'pci-v4.0-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci (2015-04-09 10:17:44 -0700)

are available in the git repository at:

git://git.yoctoproject.org/linux-yocto-contrib.git tzanussi/kallsyms-header-cleanup-v2
http://git.yoctoproject.org/cgit.cgi//log/?h=kallsyms-v2

Tom Zanussi (7):
tracing: Remove kallsyms.h include from linux/ftrace.h
kallsyms: Add module.h include
tracing: Remove redundant module.h includes
lib: Remove redundant module.h includes
fnic: Remove redundant module.h includes
slub: Remove redundant module.h includes
tracing: Remove unnecessary kallsyms.h and module.h includes

 drivers/scsi/fnic/fnic_trace.c    | 1 -
 include/linux/ftrace.h            | 1 -
 include/linux/kallsyms.h          | 1 +
 kernel/trace/trace.c              | 2 --
 kernel/trace/trace_branch.c       | 2 --
 kernel/trace/trace_export.c       | 2 --
 kernel/trace/trace_irqsoff.c      | 2 --
 kernel/trace/trace_kprobe.c       | 1 +
 kernel/trace/trace_output.c       | 2 +-
 kernel/trace/trace_sched_switch.c | 2 --
 kernel/trace/trace_sched_wakeup.c | 2 --
 kernel/trace/trace_stack.c        | 2 --
 kernel/trace/trace_syscalls.c     | 2 +-
 lib/vsprintf.c                    | 1 -
 mm/slub.c                         | 1 -
 15 files changed, 4 insertions(+), 20 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH v2 1/7 tracing: Remove kallsyms.h include from linux/ftrace.h

kallsyms.h was included by ftrace.h for KSYM_NAME_LEN, but that usage was removed by commit 3f5ec13696f [tracing/fastboot: move boot tracer structs and funcs into their own header].

Remove kallsyms.h and have users relying on ftrace.h to include it for them include it explicitly.

---
 include/linux/ftrace.h        | 1 -
 kernel/trace/trace_kprobe.c   | 1 +
 kernel/trace/trace_output.c   | 1 +
 kernel/trace/trace_syscalls.c | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)
include/linux/ftrace.h +0 -1
index 1da6029..8554dd5 100644
@@ -7,7 +7,6 @@
 #define _LINUX_FTRACE_H
 
 #include <linux/trace_clock.h>
-#include <linux/kallsyms.h>
 #include <linux/linkage.h>
 #include <linux/bitops.h>
 #include <linux/ptrace.h>
kernel/trace/trace_kprobe.c +1 -0
index d73f565..52abd46 100644
@@ -18,6 +18,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/kallsyms.h>
 #include <linux/uaccess.h>
 
 #include "trace_probe.h"
kernel/trace/trace_output.c +1 -0
index 692bf71..135dbd5 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/kallsyms.h>
 #include <linux/mutex.h>
 #include <linux/ftrace.h>
 
kernel/trace/trace_syscalls.c +1 -0
index f97f6e3..3cb7355 100644
@@ -4,6 +4,7 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>	/* for MODULE_NAME_LEN via KSYM_SYMBOL_LEN */
+#include <linux/kallsyms.h>
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
 #include <asm/syscall.h>
Signature · 1 line
1.9.3
#3 lore raw

PATCH v2 3/7 tracing: Remove redundant module.h includes

In reply to Tom Zanussi

kallsyms.h now includes module.h, so remove module.h includes that were apparently there only to satisfy kallsyms use of MODULE_NAME_LEN (via KSYM_SYMBOL_LEN).

---
 kernel/trace/trace_output.c   | 1 -
 kernel/trace/trace_syscalls.c | 1 -
 2 files changed, 2 deletions(-)
kernel/trace/trace_output.c +0 -1
index 135dbd5..7cc8e96 100644
@@ -5,7 +5,6 @@
  *
  */
 
-#include <linux/module.h>
 #include <linux/kallsyms.h>
 #include <linux/mutex.h>
 #include <linux/ftrace.h>
kernel/trace/trace_syscalls.c +0 -1
index 3cb7355..da74ff7 100644
@@ -3,7 +3,6 @@
 #include <linux/syscalls.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/module.h>	/* for MODULE_NAME_LEN via KSYM_SYMBOL_LEN */
 #include <linux/kallsyms.h>
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
Signature · 1 line
1.9.3
#4 lore raw

PATCH v2 4/7 lib: Remove redundant module.h includes

In reply to Tom Zanussi

kallsyms.h now includes module.h, so remove module.h includes that were apparently there only to satisfy kallsyms use of MODULE_NAME_LEN (via KSYM_SYMBOL_LEN).

---
 lib/vsprintf.c | 1 -
 1 file changed, 1 deletion(-)
lib/vsprintf.c +0 -1
index b235c96..c748b95 100644
@@ -17,7 +17,6 @@
  */
 
 #include <stdarg.h>
-#include <linux/module.h>	/* for KSYM_SYMBOL_LEN */
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
Signature · 1 line
1.9.3
#5 lore raw

PATCH v2 5/7 fnic: Remove redundant module.h includes

In reply to Tom Zanussi

kallsyms.h now includes module.h, so remove module.h includes that were apparently there only to satisfy kallsyms use of MODULE_NAME_LEN (via KSYM_SYMBOL_LEN).

---
 drivers/scsi/fnic/fnic_trace.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/fnic/fnic_trace.c +0 -1
index 65a9bde..98311e4 100644
@@ -15,7 +15,6 @@
  * SOFTWARE.
  */
 
-#include <linux/module.h>
 #include <linux/mempool.h>
 #include <linux/errno.h>
 #include <linux/spinlock.h>
Signature · 1 line
1.9.3
#8 lore raw

PATCH v2 7/7 tracing: Remove unnecessary kallsyms.h and module.h includes

In reply to Tom Zanussi

At some point, these files made use of something from kallsyms.h and/or module.h, but they now use nothing from either and can be removed.

---
 kernel/trace/trace.c              | 2 --
 kernel/trace/trace_branch.c       | 2 --
 kernel/trace/trace_export.c       | 2 --
 kernel/trace/trace_irqsoff.c      | 2 --
 kernel/trace/trace_sched_switch.c | 2 --
 kernel/trace/trace_sched_wakeup.c | 2 --
 kernel/trace/trace_stack.c        | 2 --
 7 files changed, 14 deletions(-)
kernel/trace/trace.c +0 -2
index 62c6506..5479ce7 100644
@@ -15,7 +15,6 @@
 #include <generated/utsrelease.h>
 #include <linux/stacktrace.h>
 #include <linux/writeback.h>
-#include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/notifier.h>
 #include <linux/irqflags.h>
@@ -26,7 +25,6 @@
 #include <linux/uaccess.h>
 #include <linux/kprobes.h>
 #include <linux/ftrace.h>
-#include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/splice.h>
 #include <linux/kdebug.h>
kernel/trace/trace_branch.c +0 -2
index 57cbf1e..965b6f3 100644
@@ -3,12 +3,10 @@
  *
  * Copyright (C) 2008 Steven Rostedt <[email protected]>
  */
-#include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
 #include <linux/irqflags.h>
 #include <linux/uaccess.h>
-#include <linux/module.h>
 #include <linux/ftrace.h>
 #include <linux/hash.h>
 #include <linux/fs.h>
kernel/trace/trace_export.c +0 -2
index 12e2b99..ddf8d06 100644
@@ -4,11 +4,9 @@
  * Copyright (C) 2009 Steven Rostedt <[email protected]>
  */
 #include <linux/stringify.h>
-#include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
-#include <linux/module.h>
 #include <linux/init.h>
 
 #include "trace_output.h"
kernel/trace/trace_irqsoff.c +0 -2
index 8523ea3..f65f596 100644
@@ -9,9 +9,7 @@
  *  Copyright (C) 2004-2006 Ingo Molnar
  *  Copyright (C) 2004 Nadia Yvette Chambers
  */
-#include <linux/kallsyms.h>
 #include <linux/uaccess.h>
-#include <linux/module.h>
 #include <linux/ftrace.h>
 
 #include "trace.h"
kernel/trace/trace_sched_switch.c +0 -2
index 419ca37..e1793f2 100644
@@ -4,8 +4,6 @@
  * Copyright (C) 2007 Steven Rostedt <[email protected]>
  *
  */
-#include <linux/module.h>
-#include <linux/kallsyms.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
 #include <trace/events/sched.h>
kernel/trace/trace_sched_wakeup.c +0 -2
index d6e1003..9dd1d57 100644
@@ -9,8 +9,6 @@
  *  Copyright (C) 2004-2006 Ingo Molnar
  *  Copyright (C) 2004 Nadia Yvette Chambers
  */
-#include <linux/module.h>
-#include <linux/kallsyms.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
 #include <linux/sched/rt.h>
kernel/trace/trace_stack.c +0 -2
index c3e4fcf..405ce8b 100644
@@ -3,12 +3,10 @@
  *
  */
 #include <linux/stacktrace.h>
-#include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
-#include <linux/module.h>
 #include <linux/sysctl.h>
 #include <linux/init.h>
 
Signature · 1 line
1.9.3
#6 lore raw

PATCH v2 6/7 slub: Remove redundant module.h includes

In reply to Tom Zanussi

kallsyms.h now includes module.h, so remove module.h includes that were apparently there only to satisfy kallsyms use of MODULE_NAME_LEN (via KSYM_SYMBOL_LEN).

---
 mm/slub.c | 1 -
 1 file changed, 1 deletion(-)
mm/slub.c +0 -1
index 82c4737..f2b6711 100644
@@ -11,7 +11,6 @@
 
 #include <linux/mm.h>
 #include <linux/swap.h> /* struct reclaim_state */
-#include <linux/module.h>
 #include <linux/bit_spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/bitops.h>
Signature · 1 line
1.9.3
#2 lore raw

PATCH v2 2/7 kallsyms: Add module.h include

In reply to Tom Zanussi

KSYM_SYMBOL_LEN uses MODULE_NAME_LEN defined in module.h, so include module.h so users don't have to.

---
 include/linux/kallsyms.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/kallsyms.h +1 -0
index 6883e19..e1550a4 100644
@@ -8,6 +8,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/stddef.h>
+#include <linux/module.h>
 
 #define KSYM_NAME_LEN 128
 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
Signature · 1 line
1.9.3
reviewer Acked-by on v2 6/7
#7 lore raw

Re: [PATCH v2 6/7] slub: Remove redundant module.h includes

In reply to Tom Zanussi
Quoted 5 lines · Tom Zanussi

kallsyms.h now includes module.h, so remove module.h includes that were apparently there only to satisfy kallsyms use of MODULE_NAME_LEN (via KSYM_SYMBOL_LEN).

This seems fine for slub. The series is based on Linus's latest tree and doesn't apply at all to linux-next, so you may want to rebase it after the 4.1 merge window.