Skip to contentSkip to conversation

split exception table content out of module.h into extable.h

PATCH In review Paul Gortmaker 6 participants 20 messages Jul 25, 2016 – Jul 28, 2016

Subsystems (14)
Arm (32-bit) x86 PowerPC MIPS +10 more subsystems
lore
Share & tools
lore
#0 lore raw

cover split exception table content out of module.h into extable.h

[RFC: Not looking for detailed review given the merge window is open.
As long as nobody thinks the general idea is horrible, I'll expand into more fringe arch and resend in 2wks and get it added then to linux-next.]

While doing an audit looking for unnecessary instances of module.h inclusion across arch/x86/ I found a significant number of includes of module.h were for things like search_exception_table and friends.

For historical reasons (i.e. pre-git) the exception table stuff was buried in the middle of the module.h file. So we have core kernel files that are completely non-modular (both arch specific and arch independent) that are just including module.h for this.

The converse is also true, in that conventional drivers, be they for filesystems or actual hardware peripherals or similar, do not normally care about the exception tables.

Here we fork the exception table content out of module.h into a new extable.h file. The gain here is that module.h gets a bit smaller; a win for all modular drivers that we build for allmodconfig. Also most core files that only need exception table stuff get to shed an include of module.h that brings in lots of extra stuff and just looks generally out of place. They use the tiny extable.h instead.

We temporarily include extable.h into the module.h itself. Then we will work our way across the arch independent and arch specific files needing just exception table content, and move them off module.h and onto extable.h

Once that is done, we can remove the extable.h from module.h and in doing it like this, we avoid introducing build failures into the git history.

We have the option of taking this final one line commit and pushing it out a complete release if we want to open up a bigger window for converting some of the more fringe archtectures.

I've converted about a dozen architectures here w/o issue; that largely reflects what I currently have toolchains for. Build testing seems necessary in all instances, since the odds are high that the module.h presence was hiding implicit use of other headers, as was the case for s390.

Paul.

Signature · 89 lines
Cc: Andrew Morton <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Russell King <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Paul Gortmaker (14):
  exceptions: fork exception table content from module.h into extable.h
  x86: migrate exception table users off module.h and onto extable.h
  arm: migrate exception table users off module.h and onto extable.h
  arm64: migrate exception table users off module.h and onto extable.h
  mips: migrate exception table users off module.h and onto extable.h
  sparc: migrate exception table users off module.h and onto extable.h
  powerpc: migrate exception table users off module.h and onto extable.h
  m68k: migrate exception table users off module.h and onto extable.h
  s390: migrate exception table users off module.h and onto extable.h
  tile: migrate exception table users off module.h and onto extable.h
  alpha: migrate exception table users off module.h and onto extable.h
  parisc: migrate exception table users off module.h and onto extable.h
  core: migrate exception table users off module.h and onto extable.h
  module.h: remove extable.h include now users have migrated

 arch/alpha/kernel/traps.c          |  2 +-
 arch/alpha/mm/fault.c              |  2 +-
 arch/arm/mm/extable.c              |  2 +-
 arch/arm/mm/fault.c                |  2 +-
 arch/arm64/kernel/probes/kprobes.c |  2 +-
 arch/arm64/mm/extable.c            |  2 +-
 arch/arm64/mm/fault.c              |  2 +-
 arch/m68k/kernel/signal.c          |  2 +-
 arch/mips/kernel/module.c          |  1 +
 arch/mips/kernel/traps.c           |  2 +-
 arch/mips/mm/extable.c             |  2 +-
 arch/parisc/mm/fault.c             |  2 +-
 arch/powerpc/kernel/kprobes.c      |  2 +-
 arch/powerpc/mm/fault.c            |  2 +-
 arch/s390/kernel/early.c           |  2 +-
 arch/s390/kernel/kprobes.c         |  2 ++
 arch/s390/kernel/traps.c           |  3 ++-
 arch/s390/mm/fault.c               |  2 +-
 arch/sparc/kernel/kprobes.c        |  2 +-
 arch/sparc/kernel/traps_64.c       |  2 +-
 arch/sparc/kernel/unaligned_64.c   |  2 +-
 arch/sparc/mm/fault_64.c           |  2 +-
 arch/sparc/mm/init_64.c            |  2 +-
 arch/tile/kernel/unaligned.c       |  2 +-
 arch/tile/mm/extable.c             |  2 +-
 arch/tile/mm/fault.c               |  2 +-
 arch/x86/kernel/kprobes/core.c     |  2 +-
 arch/x86/kernel/kprobes/opt.c      |  2 +-
 arch/x86/mm/extable.c              |  2 +-
 arch/x86/mm/fault.c                |  2 +-
 include/linux/extable.h            | 30 ++++++++++++++++++++++++++++++
 include/linux/module.h             | 26 +-------------------------
 init/main.c                        |  1 +
 kernel/extable.c                   |  1 +
 kernel/module.c                    |  1 +
 35 files changed, 66 insertions(+), 53 deletions(-)
 create mode 100644 include/linux/extable.h

-- 
2.8.4
#1 lore raw

PATCH 1/14 exceptions: fork exception table content from module.h into extable.h

For historical reasons (i.e. pre-git) the exception table stuff was buried in the middle of the module.h file. I noticed this while doing an audit for needless includes of module.h and found core kernel files (both arch specific and arch independent) were just including module.h for this.

The converse is also true, in that conventional drivers, be they for filesystems or actual hardware peripherals or similar, do not normally care about the exception tables.

Here we fork the exception table content out of module.h into a new file called extable.h -- and temporarily include it into the module.h itself.

Then we will work our way across the arch independent and arch specific files needing just exception table content, and move them off module.h and onto extable.h

Once that is done, we can remove the extable.h from module.h and in doing it like this, we avoid introducing build failures into the git history.

The gain here is that module.h gets a bit smaller, across all modular drivers that we build for allmodconfig. Also the core files that only need exception table stuff don't have an include of module.h that brings in lots of extra stuff and just looks generally out of place.

Cc Rusty Russell <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 include/linux/extable.h | 30 ++++++++++++++++++++++++++++++
 include/linux/module.h  | 27 ++-------------------------
 2 files changed, 32 insertions(+), 25 deletions(-)
 create mode 100644 include/linux/extable.h
include/linux/extable.h new file +30 -0
new file mode 100644
index 000000000000..2c71dccd1bc3
@@ -0,0 +1,30 @@
+#ifndef _LINUX_EXTABLE_H
+#define _LINUX_EXTABLE_H
+
+struct module;
+struct exception_table_entry;
+
+const struct exception_table_entry *
+search_extable(const struct exception_table_entry *first,
+	       const struct exception_table_entry *last,
+	       unsigned long value);
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish);
+void sort_main_extable(void);
+void trim_init_extable(struct module *m);
+
+/* Given an address, look for it in the exception tables */
+const struct exception_table_entry *search_exception_tables(unsigned long add);
+
+#ifdef CONFIG_MODULES
+/* For extable.c to search modules' exception tables. */
+const struct exception_table_entry *search_module_extables(unsigned long addr);
+#else
+static inline const struct exception_table_entry *
+search_module_extables(unsigned long addr)
+{
+	return NULL;
+}
+#endif /*CONFIG_MODULES*/
+
+#endif /* _LINUX_EXTABLE_H */
include/linux/module.h +2 -25
index f777164c238b..f95ed243a4de 100644
@@ -18,6 +18,7 @@
 #include <linux/moduleparam.h>
 #include <linux/jump_label.h>
 #include <linux/export.h>
+#include <linux/extable.h>	/* only as arch move module.h -> extable.h */
 #include <linux/rbtree_latch.h>
 
 #include <linux/percpu.h>
@@ -37,6 +38,7 @@ struct modversion_info {
 };
 
 struct module;
+struct exception_table_entry;
 
 struct module_kobject {
 	struct kobject kobj;
@@ -155,18 +157,6 @@ extern void cleanup_module(void);
 #define __INITRODATA_OR_MODULE __INITRODATA
 #endif /*CONFIG_MODULES*/
 
-/* Archs provide a method of finding the correct exception table. */
-struct exception_table_entry;
-
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value);
-void sort_extable(struct exception_table_entry *start,
-		  struct exception_table_entry *finish);
-void sort_main_extable(void);
-void trim_init_extable(struct module *m);
-
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
 
@@ -268,9 +258,6 @@ extern const typeof(name) __mod_##type##__##name##_device_table		\
  * files require multiple MODULE_FIRMWARE() specifiers */
 #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
 
-/* Given an address, look for it in the exception tables */
-const struct exception_table_entry *search_exception_tables(unsigned long add);
-
 struct notifier_block;
 
 #ifdef CONFIG_MODULES
@@ -630,9 +617,6 @@ const char *module_address_lookup(unsigned long addr,
 int lookup_module_symbol_name(unsigned long addr, char *symname);
 int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
 
-/* For extable.c to search modules' exception tables. */
-const struct exception_table_entry *search_module_extables(unsigned long addr);
-
 int register_module_notifier(struct notifier_block *nb);
 int unregister_module_notifier(struct notifier_block *nb);
 
@@ -657,13 +641,6 @@ static inline bool is_livepatch_module(struct module *mod)
 
 #else /* !CONFIG_MODULES... */
 
-/* Given an address, look for it in the exception tables. */
-static inline const struct exception_table_entry *
-search_module_extables(unsigned long addr)
-{
-	return NULL;
-}
-
 static inline struct module *__module_address(unsigned long addr)
 {
 	return NULL;
Signature · 1 line
2.8.4
#2 lore raw

Re: [PATCH 01/14] exceptions: fork exception table content from module.h into extable.h

Quoted 5 lines · Paul Gortmaker

For historical reasons (i.e. pre-git) the exception table stuff was buried in the middle of the module.h file. I noticed this while doing an audit for needless includes of module.h and found core kernel files (both arch specific and arch independent) were just including module.h for this.

I'm going to include this first patch now; it's trivial, and allows the rest of the changes to proceed at the archs' leisure.

I have another patch series which had to be tweaked, so I'm deferring the push to Linus for a couple of days stewing in linux-next anyway.

Thanks,
Rusty.

Quoted 143 lines

The converse is also true, in that conventional drivers, be they for filesystems or actual hardware peripherals or similar, do not normally care about the exception tables.

Here we fork the exception table content out of module.h into a new file called extable.h -- and temporarily include it into the module.h itself.

Then we will work our way across the arch independent and arch specific files needing just exception table content, and move them off module.h and onto extable.h

Once that is done, we can remove the extable.h from module.h and in doing it like this, we avoid introducing build failures into the git history.

The gain here is that module.h gets a bit smaller, across all modular drivers that we build for allmodconfig. Also the core files that only need exception table stuff don't have an include of module.h that brings in lots of extra stuff and just looks generally out of place.

Cc Rusty Russell <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 include/linux/extable.h | 30 ++++++++++++++++++++++++++++++
 include/linux/module.h  | 27 ++-------------------------
 2 files changed, 32 insertions(+), 25 deletions(-)
 create mode 100644 include/linux/extable.h
include/linux/extable.h new file +30 -0
new file mode 100644
index 000000000000..2c71dccd1bc3
@@ -0,0 +1,30 @@
+#ifndef _LINUX_EXTABLE_H
+#define _LINUX_EXTABLE_H
+
+struct module;
+struct exception_table_entry;
+
+const struct exception_table_entry *
+search_extable(const struct exception_table_entry *first,
+	       const struct exception_table_entry *last,
+	       unsigned long value);
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish);
+void sort_main_extable(void);
+void trim_init_extable(struct module *m);
+
+/* Given an address, look for it in the exception tables */
+const struct exception_table_entry *search_exception_tables(unsigned long add);
+
+#ifdef CONFIG_MODULES
+/* For extable.c to search modules' exception tables. */
+const struct exception_table_entry *search_module_extables(unsigned long addr);
+#else
+static inline const struct exception_table_entry *
+search_module_extables(unsigned long addr)
+{
+	return NULL;
+}
+#endif /*CONFIG_MODULES*/
+
+#endif /* _LINUX_EXTABLE_H */
include/linux/module.h +2 -25
index f777164c238b..f95ed243a4de 100644
@@ -18,6 +18,7 @@
 #include <linux/moduleparam.h>
 #include <linux/jump_label.h>
 #include <linux/export.h>
+#include <linux/extable.h>	/* only as arch move module.h -> extable.h */
 #include <linux/rbtree_latch.h>
 
 #include <linux/percpu.h>
@@ -37,6 +38,7 @@ struct modversion_info {
 };
 
 struct module;
+struct exception_table_entry;
 
 struct module_kobject {
 	struct kobject kobj;
@@ -155,18 +157,6 @@ extern void cleanup_module(void);
 #define __INITRODATA_OR_MODULE __INITRODATA
 #endif /*CONFIG_MODULES*/
 
-/* Archs provide a method of finding the correct exception table. */
-struct exception_table_entry;
-
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value);
-void sort_extable(struct exception_table_entry *start,
-		  struct exception_table_entry *finish);
-void sort_main_extable(void);
-void trim_init_extable(struct module *m);
-
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
 
@@ -268,9 +258,6 @@ extern const typeof(name) __mod_##type##__##name##_device_table		\
  * files require multiple MODULE_FIRMWARE() specifiers */
 #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
 
-/* Given an address, look for it in the exception tables */
-const struct exception_table_entry *search_exception_tables(unsigned long add);
-
 struct notifier_block;
 
 #ifdef CONFIG_MODULES
@@ -630,9 +617,6 @@ const char *module_address_lookup(unsigned long addr,
 int lookup_module_symbol_name(unsigned long addr, char *symname);
 int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
 
-/* For extable.c to search modules' exception tables. */
-const struct exception_table_entry *search_module_extables(unsigned long addr);
-
 int register_module_notifier(struct notifier_block *nb);
 int unregister_module_notifier(struct notifier_block *nb);
 
@@ -657,13 +641,6 @@ static inline bool is_livepatch_module(struct module *mod)
 
 #else /* !CONFIG_MODULES... */
 
-/* Given an address, look for it in the exception tables. */
-static inline const struct exception_table_entry *
-search_module_extables(unsigned long addr)
-{
-	return NULL;
-}
-
 static inline struct module *__module_address(unsigned long addr)
 {
 	return NULL;
Signature · 1 line
2.8.4
#3 lore raw

PATCH 2/14 x86: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/kprobes/core.c | 2 +-
 arch/x86/kernel/kprobes/opt.c  | 2 +-
 arch/x86/mm/extable.c          | 2 +-
 arch/x86/mm/fault.c            | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/kprobes/core.c +1 -1
index 7847e5c0e0b5..28cee019209c 100644
@@ -45,7 +45,7 @@
 #include <linux/slab.h>
 #include <linux/hardirq.h>
 #include <linux/preempt.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kdebug.h>
 #include <linux/kallsyms.h>
 #include <linux/ftrace.h>
arch/x86/kernel/kprobes/opt.c +1 -1
index 4425f593f0ec..3bb4c5f021f6 100644
@@ -24,7 +24,7 @@
 #include <linux/slab.h>
 #include <linux/hardirq.h>
 #include <linux/preempt.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kdebug.h>
 #include <linux/kallsyms.h>
 #include <linux/ftrace.h>
arch/x86/mm/extable.c +1 -1
index 832b98f822be..79ae939970d3 100644
@@ -1,4 +1,4 @@
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <asm/uaccess.h>
 #include <asm/traps.h>
 #include <asm/kdebug.h>
arch/x86/mm/fault.c +1 -1
index dc8023060456..79ae05477d94 100644
@@ -5,7 +5,7 @@
  */
 #include <linux/sched.h>		/* test_thread_flag(), ...	*/
 #include <linux/kdebug.h>		/* oops_begin/end, ...		*/
-#include <linux/module.h>		/* search_exception_table	*/
+#include <linux/extable.h>		/* search_exception_table	*/
 #include <linux/bootmem.h>		/* max_low_pfn			*/
 #include <linux/kprobes.h>		/* NOKPROBE_SYMBOL, ...		*/
 #include <linux/mmiotrace.h>		/* kmmio_handler, ...		*/
Signature · 1 line
2.8.4
Acked-by on v1 2/14
#4 lore raw

Re: [PATCH 02/14] x86: migrate exception table users off module.h and onto extable.h

Quoted 11 lines · Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

Thanks,

Ingo

#5 lore raw

PATCH 3/14 arm: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

---
 arch/arm/mm/extable.c | 2 +-
 arch/arm/mm/fault.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/extable.c +1 -1
index 312e15e6d00b..f436f7439e46 100644
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/arm/mm/extable.c
  */
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/uaccess.h>
 
 int fixup_exception(struct pt_regs *regs)
arch/arm/mm/fault.c +1 -1
index 3a2e678b8d30..94de590db99e 100644
@@ -8,7 +8,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/signal.h>
 #include <linux/mm.h>
 #include <linux/hardirq.h>
Signature · 1 line
2.8.4
#6 lore raw

PATCH 4/14 arm64: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm64/kernel/probes/kprobes.c | 2 +-
 arch/arm64/mm/extable.c            | 2 +-
 arch/arm64/mm/fault.c              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm64/kernel/probes/kprobes.c +1 -1
index bf9768588288..9c1866ef3271 100644
@@ -19,7 +19,7 @@
 #include <linux/kasan.h>
 #include <linux/kernel.h>
 #include <linux/kprobes.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/slab.h>
 #include <linux/stop_machine.h>
 #include <linux/stringify.h>
arch/arm64/mm/extable.c +1 -1
index 81acd4706878..c9f118cd812b 100644
@@ -2,7 +2,7 @@
  * Based on arch/arm/mm/extable.c
  */
 
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/uaccess.h>
 
 int fixup_exception(struct pt_regs *regs)
arch/arm64/mm/fault.c +1 -1
index c8beaa0da7df..427f2fd49463 100644
@@ -18,7 +18,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/signal.h>
 #include <linux/mm.h>
 #include <linux/hardirq.h>
Signature · 1 line
2.8.4
maintainer Acked-by on v1 4/14
#7 lore raw

Re: [PATCH 04/14] arm64: migrate exception table users off module.h and onto extable.h

Quoted 10 lines · Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
#8 lore raw

PATCH 5/14 mips: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

---
 arch/mips/kernel/module.c | 1 +
 arch/mips/kernel/traps.c  | 2 +-
 arch/mips/mm/extable.c    | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
arch/mips/kernel/module.c +1 -0
index 79850e376ef6..94627a3a6a0d 100644
@@ -20,6 +20,7 @@
 
 #undef DEBUG
 
+#include <linux/extable.h>
 #include <linux/moduleloader.h>
 #include <linux/elf.h>
 #include <linux/mm.h>
arch/mips/kernel/traps.c +1 -1
index 6fb4704bd156..b4522e3a0562 100644
@@ -20,7 +20,7 @@
 #include <linux/kexec.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
arch/mips/mm/extable.c +1 -1
index 9d25d2ba4b9e..e474fa2efed4 100644
@@ -5,7 +5,7 @@
  *
  * Copyright (C) 1997, 99, 2001 - 2004 Ralf Baechle <[email protected]>
  */
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/spinlock.h>
 #include <asm/branch.h>
 #include <asm/uaccess.h>
Signature · 1 line
2.8.4
#9 lore raw

Re: [PATCH 05/14] mips: migrate exception table users off module.h and onto extable.h

url: https://github.com/0day-ci/linux/commits/Paul-Gortmaker/split-exception-table-content-out-of-module-h-into-extable-h/20160725-152314 config: mips-jz4740 (attached as .config) compiler…

Hi,

[auto build test ERROR on next-20160724]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5 v4.7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Paul-Gortmaker/split-exception-table-content-out-of-module-h-into-extable-h/20160725-152314
config: mips-jz4740 (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips

All errors (new ones prefixed by >>):

arch/mips/kernel/traps.c: In function 'show_registers':

>> arch/mips/kernel/traps.c:354:2: error: implicit declaration of function 'print_modules' [-Werror=implicit-function-declaration]
     print_modules();
     ^

cc1: some warnings being treated as errors

vim +/print_modules +354 arch/mips/kernel/traps.c

c1bf207d David Daney     2010-08-03  348  void show_registers(struct pt_regs *regs)
^1da177e Linus Torvalds  2005-04-16  349  {
39b8d525 Ralf Baechle    2008-04-28  350  	const int field = 2 * sizeof(unsigned long);
83e4da1e Leonid Yegoshin 2013-10-08  351  	mm_segment_t old_fs = get_fs();
39b8d525 Ralf Baechle    2008-04-28  352  
eae23f2c Ralf Baechle    2007-10-14  353  	__show_regs(regs);
^1da177e Linus Torvalds  2005-04-16 @354  	print_modules();
39b8d525 Ralf Baechle    2008-04-28  355  	printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
39b8d525 Ralf Baechle    2008-04-28  356  	       current->comm, current->pid, current_thread_info(), current,
39b8d525 Ralf Baechle    2008-04-28  357  	      field, current_thread_info()->tp_value);

:::::: The code at line 354 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#10 lore raw

PATCH 6/14 sparc: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

---
 arch/sparc/kernel/kprobes.c      | 2 +-
 arch/sparc/kernel/traps_64.c     | 2 +-
 arch/sparc/kernel/unaligned_64.c | 2 +-
 arch/sparc/mm/fault_64.c         | 2 +-
 arch/sparc/mm/init_64.c          | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
arch/sparc/kernel/kprobes.c +1 -1
index cd83be527586..b0377db12d83 100644
@@ -5,7 +5,7 @@
 
 #include <linux/kernel.h>
 #include <linux/kprobes.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kdebug.h>
 #include <linux/slab.h>
 #include <linux/context_tracking.h>
arch/sparc/kernel/traps_64.c +1 -1
index d21cd625c0de..4094a51b1970 100644
@@ -8,7 +8,7 @@
  * I like traps on v9, :))))
  */
 
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/sched.h>
 #include <linux/linkage.h>
 #include <linux/kernel.h>
arch/sparc/kernel/unaligned_64.c +1 -1
index 9aacb9159262..52c00d90d4b4 100644
@@ -11,7 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <asm/asi.h>
 #include <asm/ptrace.h>
 #include <asm/pstate.h>
arch/sparc/mm/fault_64.c +1 -1
index 6c43b924a7a2..0e9773ca7ff1 100644
@@ -14,7 +14,7 @@
 #include <linux/mman.h>
 #include <linux/signal.h>
 #include <linux/mm.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/init.h>
 #include <linux/perf_event.h>
 #include <linux/interrupt.h>
arch/sparc/mm/init_64.c +1 -1
index aec508e37490..96680a687799 100644
@@ -5,7 +5,7 @@
  *  Copyright (C) 1997-1999 Jakub Jelinek ([email protected])
  */
  
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
Signature · 1 line
2.8.4
#11 lore raw

PATCH 7/14 powerpc: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/kernel/kprobes.c | 2 +-
 arch/powerpc/mm/fault.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/kprobes.c +1 -1
index 3ed8ec09b5c9..e785cc9e1ecd 100644
@@ -29,7 +29,7 @@
 #include <linux/kprobes.h>
 #include <linux/ptrace.h>
 #include <linux/preempt.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kdebug.h>
 #include <linux/slab.h>
 #include <asm/code-patching.h>
arch/powerpc/mm/fault.c +1 -1
index a4db22f65021..bb1ffc559f38 100644
@@ -26,7 +26,7 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/highmem.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kprobes.h>
 #include <linux/kdebug.h>
 #include <linux/perf_event.h>
Signature · 1 line
2.8.4
#12 lore raw

PATCH 8/14 m68k: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

This file was only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile this.

---
 arch/m68k/kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/signal.c +1 -1
index 2dcee3a88867..db775322b485 100644
@@ -42,7 +42,7 @@
 #include <linux/personality.h>
 #include <linux/tty.h>
 #include <linux/binfmts.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/tracehook.h>
 
 #include <asm/setup.h>
Signature · 1 line
2.8.4
#13 lore raw

PATCH 9/14 s390: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

The additions of uaccess.h are to deal with implict includes like:

arch/s390/kernel/traps.c: In function 'do_report_trap':
arch/s390/kernel/traps.c:56:4: error: implicit declaration of function 'extable_fixup' [-Werror=implicit-function-declaration] arch/s390/kernel/traps.c: In function 'illegal_op':
arch/s390/kernel/traps.c:173:3: error: implicit declaration of function 'get_user' [-Werror=implicit-function-declaration]

Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>
---
 arch/s390/kernel/early.c   | 2 +-
 arch/s390/kernel/kprobes.c | 2 ++
 arch/s390/kernel/traps.c   | 3 ++-
 arch/s390/mm/fault.c       | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)
arch/s390/kernel/early.c +1 -1
index 717b03aa16b5..2374c5b46bbc 100644
@@ -13,7 +13,7 @@
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/lockdep.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/pfn.h>
 #include <linux/uaccess.h>
 #include <linux/kernel.h>
arch/s390/kernel/kprobes.c +2 -0
index 250f5972536a..4871c7c3ccde 100644
@@ -26,12 +26,14 @@
 #include <linux/stop_machine.h>
 #include <linux/kdebug.h>
 #include <linux/uaccess.h>
+#include <linux/extable.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/hardirq.h>
 #include <linux/ftrace.h>
 #include <asm/cacheflush.h>
 #include <asm/sections.h>
+#include <asm/uaccess.h>
 #include <asm/dis.h>
 
 DEFINE_PER_CPU(struct kprobe *, current_kprobe);
arch/s390/kernel/traps.c +2 -1
index dd97a3e8a34a..d0539f76fd24 100644
@@ -14,11 +14,12 @@
  */
 #include <linux/kprobes.h>
 #include <linux/kdebug.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/ptrace.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <asm/uaccess.h>
 #include <asm/fpu/api.h>
 #include "entry.h"
 
arch/s390/mm/fault.c +1 -1
index a58bca62a93b..cca73881e672 100644
@@ -24,7 +24,7 @@
 #include <linux/kdebug.h>
 #include <linux/init.h>
 #include <linux/console.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/hardirq.h>
 #include <linux/kprobes.h>
 #include <linux/uaccess.h>
Signature · 1 line
2.8.4
#14 lore raw

PATCH 10/14 tile: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

---
 arch/tile/kernel/unaligned.c | 2 +-
 arch/tile/mm/extable.c       | 2 +-
 arch/tile/mm/fault.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/tile/kernel/unaligned.c +1 -1
index 9772a3554282..4fe78c5b8394 100644
@@ -22,7 +22,7 @@
 #include <linux/mman.h>
 #include <linux/types.h>
 #include <linux/err.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/compat.h>
 #include <linux/prctl.h>
 #include <asm/cacheflush.h>
arch/tile/mm/extable.c +1 -1
index 4fb0acb9d154..aeaf20c7aaa4 100644
@@ -12,7 +12,7 @@
  *   more details.
  */
 
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/spinlock.h>
 #include <linux/uaccess.h>
 
arch/tile/mm/fault.c +1 -1
index beba986589e5..709f8e9ba3e9 100644
@@ -29,7 +29,7 @@
 #include <linux/tty.h>
 #include <linux/vt_kern.h>		/* For unblank_screen() */
 #include <linux/highmem.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kprobes.h>
 #include <linux/hugetlb.h>
 #include <linux/syscalls.h>
Signature · 1 line
2.8.4
#15 lore raw

PATCH 11/14 alpha: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile these files.

Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>
---
 arch/alpha/kernel/traps.c | 2 +-
 arch/alpha/mm/fault.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/alpha/kernel/traps.c +1 -1
index 74aceead06e9..7cf05aa482d5 100644
@@ -13,7 +13,7 @@
 #include <linux/sched.h>
 #include <linux/tty.h>
 #include <linux/delay.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/kallsyms.h>
 #include <linux/ratelimit.h>
 
arch/alpha/mm/fault.c +1 -1
index 83e9eee57a55..47948b4dd157 100644
@@ -22,7 +22,7 @@
 #include <linux/mman.h>
 #include <linux/smp.h>
 #include <linux/interrupt.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/uaccess.h>
 
 extern void die_if_kernel(char *,struct pt_regs *,long, unsigned long *);
Signature · 1 line
2.8.4
#16 lore raw

PATCH 12/14 parisc: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

This file was only including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and avoid all the extra header content in module.h that we don't really need to compile this file.

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/mm/fault.c +1 -1
index 163af2c31d76..a67519b79504 100644
@@ -14,7 +14,7 @@
 #include <linux/ptrace.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
-#include <linux/module.h>
+#include <linux/extable.h>
 #include <linux/uaccess.h>
 
 #include <asm/traps.h>
Signature · 1 line
2.8.4
#17 lore raw

PATCH 13/14 core: migrate exception table users off module.h and onto extable.h

In reply to Paul Gortmaker

These files were including module.h for exception table related functions. We've now separated that content out into its own file "extable.h" so now move over to that and where possible, avoid all the extra header content in module.h that we don't really need to compile these non-modular files.

Note:
init/main.c still needs module.h for __init_or_module kernel/extable.c still needs module.h for is_module_text_address

...and so we don't get the benefit of removing module.h from the cpp feed for these two files, unlike the almost universal 1:1 exchange of module.h for extable.h we were able to do in the arch dirs.

Cc Rusty Russell <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 init/main.c      | 1 +
 kernel/extable.c | 1 +
 kernel/module.c  | 1 +
 3 files changed, 3 insertions(+)
init/main.c +1 -0
index 9a9a25570f72..42fa8368d4a9 100644
@@ -12,6 +12,7 @@
 #define DEBUG		/* Enable initcall_debug */
 
 #include <linux/types.h>
+#include <linux/extable.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/kernel.h>
kernel/extable.c +1 -0
index e820ccee9846..55038378d882 100644
@@ -17,6 +17,7 @@
 */
 #include <linux/ftrace.h>
 #include <linux/memory.h>
+#include <linux/extable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/init.h>
kernel/module.c +1 -0
index e70a2faf71d9..536ab4b72761 100644
@@ -17,6 +17,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 #include <linux/export.h>
+#include <linux/extable.h>
 #include <linux/moduleloader.h>
 #include <linux/trace_events.h>
 #include <linux/init.h>
Signature · 1 line
2.8.4
#18 lore raw

PATCH 14/14 module.h: remove extable.h include now users have migrated

In reply to Paul Gortmaker

With hopefully most/all users of module.h that were looking for exception table functions moved over to the new extable.h header, we can remove the back-compat include that let us transition without introducing build regressions.

Cc Rusty Russell <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 include/linux/module.h | 1 -
 1 file changed, 1 deletion(-)
include/linux/module.h +0 -1
index f95ed243a4de..1974eadcb308 100644
@@ -18,7 +18,6 @@
 #include <linux/moduleparam.h>
 #include <linux/jump_label.h>
 #include <linux/export.h>
-#include <linux/extable.h>	/* only as arch move module.h -> extable.h */
 #include <linux/rbtree_latch.h>
 
 #include <linux/percpu.h>
Signature · 1 line
2.8.4
#19 lore raw
In reply to Paul Gortmaker
Quoted 10 lines · Paul Gortmaker

While doing an audit looking for unnecessary instances of module.h inclusion across arch/x86/ I found a significant number of includes of module.h were for things like search_exception_table and friends.

For historical reasons (i.e. pre-git) the exception table stuff was buried in the middle of the module.h file. So we have core kernel files that are completely non-modular (both arch specific and arch independent) that are just including module.h for this.

Quoted 5 lines

The converse is also true, in that conventional drivers, be they for filesystems or actual hardware peripherals or similar, do not normally care about the exception tables.

Here we fork the exception table content [...]

This looks to be the right thing to do as far as I can tell. I'm not sure how big of a problem the extable stuff is (we definitely have much bigger unnecessary include files that cause a lot more problems), but it seems like a reasonable cleanup.

Linus