init: move THIS_MODULE from <linux/export.h> to <linux/init.h>
PATCH 1/1 init: move THIS_MODULE from <linux/export.h> to <linux/init.h>
Commit f50169324df4 ("module.h: split out the EXPORT_SYMBOL into export.h") appropriately separated EXPORT_SYMBOL into <linux/export.h> because modules and EXPORT_SYMBOL are orthogonal; modules are symbol consumers, while EXPORT_SYMBOL are used by symbol providers, which may not be necessarily a module.
However, that commit also relocated THIS_MODULE. As explained in the commit description, the intention was to define THIS_MODULE in a lightweight header, but I do not believe <linux/export.h> was the suitable location because EXPORT_SYMBOL and THIS_MODULE are unrelated.
Move it to another lightweight header, <linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>.
With this adjustment, the role of <linux/export.h> becomes clearer as it only defines EXPORT_SYMBOL.
---
include/linux/export.h | 18 ------------------ include/linux/init.h | 7 +++++++ 2 files changed, 7 insertions(+), 18 deletions(-)
include/linux/export.h +0 -18
@@ -6,15 +6,6 @@#include <linux/linkage.h> #include <linux/stringify.h> -/* -* Export symbols from the kernel to modules. Forked from module.h -* to reduce the amount of pointless cruft we feed to gcc when only -* exporting a simple symbol or two. -* -* Try not to add #includes here. It slows compilation and makes kernel -* hackers place grumpy comments in header files. -*/ -/* * This comment block is used by fixdep. Please do not remove. *
@@ -23,15 +14,6 @@* side effect of the *.o build rule. */ -#ifndef __ASSEMBLY__ -#ifdef MODULE -extern struct module __this_module; -#define THIS_MODULE (&__this_module) -#else -#define THIS_MODULE ((struct module *)0) -#endif -#endif /* __ASSEMBLY__ */ -#ifdef CONFIG_64BIT #define __EXPORT_SYMBOL_REF (sym) \ .balign 8 ASM_NL \
include/linux/init.h +7 -0
@@ -179,6 +179,13 @@ extern void (*late_time_init)(void);extern bool initcall_debug; +#ifdef MODULE +extern struct module __this_module; +#define THIS_MODULE (&__this_module) +#else +#define THIS_MODULE ((struct module *)0) +#endif +#endif #ifndef MODULE
Signature · 1 line
2.40.1
Quoted 17 lines · Masahiro Yamada
Commit
f50169324df4("module.h: split out theEXPORT_SYMBOLintoexport.h") appropriately separatedEXPORT_SYMBOLinto <linux/export.h> because modules andEXPORT_SYMBOLare orthogonal; modules are symbol consumers, whileEXPORT_SYMBOLare used by symbol providers, which may not be necessarily a module.However, that commit also relocated
THIS_MODULE. As explained in the commit description, the intention was to defineTHIS_MODULEin a lightweight header, but I do not believe <linux/export.h> was the suitable location becauseEXPORT_SYMBOLandTHIS_MODULEare unrelated.Move it to another lightweight header, <
linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>.
Quoted 5 lines
With this adjustment, the role of <
linux/export.h> becomes clearer as it only definesEXPORT_SYMBOL.Signed-off-by Masahiro Yamada <[email protected]>---
Applied to kbuild.
I did not get any report from the 0day bot so far, but I hope it will get a little more compile tests before getting into linux-next.
Quoted 62 lines
include/linux/export.h | 18 ------------------ include/linux/init.h | 7 +++++++ 2 files changed, 7 insertions(+), 18 deletions(-)include/linux/export.h +0
-18@@ -6,15 +6,6 @@#include <linux/linkage.h> #include <linux/stringify.h> -/* -* Export symbols from the kernel to modules. Forked from module.h -* to reduce the amount of pointless cruft we feed to gcc when only -* exporting a simple symbol or two. -* -* Try not to add #includes here. It slows compilation and makes kernel -* hackers place grumpy comments in header files. -*/ -/* * This comment block is used by fixdep. Please do not remove. * @@ -23,15 +14,6 @@* side effect of the *.o build rule. */ -#ifndef __ASSEMBLY__ -#ifdef MODULE -extern struct module __this_module; -#define THIS_MODULE (&__this_module) -#else -#define THIS_MODULE ((struct module *)0) -#endif -#endif /* __ASSEMBLY__ */ -#ifdef CONFIG_64BIT #define __EXPORT_SYMBOL_REF (sym) \ .balign 8 ASM_NL \include/linux/init.h +7
-1@@ -179,6 +179,13 @@ extern void (*late_time_init)(void);extern bool initcall_debug; +#ifdef MODULE +extern struct module __this_module; +#define THIS_MODULE (&__this_module) +#else +#define THIS_MODULE ((struct module *)0) +#endif +#endif #ifndef MODULE --2.40.1
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 25 lines · [Re: [PATCH] init: move THIS_MODULE from <linux/export.h> to <linux/init.h>]…
Quoted 17 lines · On Sun, Nov 26, 2023 at 4:19???PM Masahiro Yamada <[email protected]> wrote:
Commit
f50169324df4("module.h: split out theEXPORT_SYMBOLintoexport.h") appropriately separatedEXPORT_SYMBOLinto <linux/export.h> because modules andEXPORT_SYMBOLare orthogonal; modules are symbol consumers, whileEXPORT_SYMBOLare used by symbol providers, which may not be necessarily a module.However, that commit also relocated
THIS_MODULE. As explained in the commit description, the intention was to defineTHIS_MODULEin a lightweight header, but I do not believe <linux/export.h> was the suitable location becauseEXPORT_SYMBOLandTHIS_MODULEare unrelated.Move it to another lightweight header, <
linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>.Quoted 5 lines
With this adjustment, the role of <
linux/export.h> becomes clearer as it only definesEXPORT_SYMBOL.Signed-off-by Masahiro Yamada <[email protected]>---
Quoted 5 lines
Applied to kbuild.
I did not get any report from the 0day bot so far, but I hope it will get a little more compile tests before getting into linux-next.
Haven't touched that kind of header shuffle for over 10 years?
But yeah, it is near impossible to not trip over some implicit header inclusion somewhere in some driver or a less common arch and hence break the build at least once when doing this kind of stuff.
Paul.
--
Quoted 70 lines
Quoted 65 lines
include/linux/export.h | 18 ------------------ include/linux/init.h | 7 +++++++ 2 files changed, 7 insertions(+), 18 deletions(-)include/linux/export.h +0
-18@@ -6,15 +6,6 @@#include <linux/linkage.h> #include <linux/stringify.h> -/* -* Export symbols from the kernel to modules. Forked from module.h -* to reduce the amount of pointless cruft we feed to gcc when only -* exporting a simple symbol or two. -* -* Try not to add #includes here. It slows compilation and makes kernel -* hackers place grumpy comments in header files. -*/ -/* * This comment block is used by fixdep. Please do not remove. * @@ -23,15 +14,6 @@* side effect of the *.o build rule. */ -#ifndef __ASSEMBLY__ -#ifdef MODULE -extern struct module __this_module; -#define THIS_MODULE (&__this_module) -#else -#define THIS_MODULE ((struct module *)0) -#endif -#endif /* __ASSEMBLY__ */ -#ifdef CONFIG_64BIT #define __EXPORT_SYMBOL_REF (sym) \ .balign 8 ASM_NL \include/linux/init.h +7
-1@@ -179,6 +179,13 @@ extern void (*late_time_init)(void);extern bool initcall_debug; +#ifdef MODULE +extern struct module __this_module; +#define THIS_MODULE (&__this_module) +#else +#define THIS_MODULE ((struct module *)0) +#endif +#endif #ifndef MODULE --2.40.1
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 16 lines · Masahiro Yamada
Commit
f50169324df4("module.h: split out theEXPORT_SYMBOLintoexport.h") appropriately separatedEXPORT_SYMBOLinto <linux/export.h> because modules andEXPORT_SYMBOLare orthogonal; modules are symbol consumers, whileEXPORT_SYMBOLare used by symbol providers, which may not be necessarily a module.However, that commit also relocated
THIS_MODULE. As explained in the commit description, the intention was to defineTHIS_MODULEin a lightweight header, but I do not believe <linux/export.h> was the suitable location becauseEXPORT_SYMBOLandTHIS_MODULEare unrelated.Move it to another lightweight header, <
linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>.
Quoted 4 lines
With this adjustment, the role of <
linux/export.h> becomes clearer as it only definesEXPORT_SYMBOL.Signed-off-by Masahiro Yamada <[email protected]>
Do you want this this to go through modules-next or your tree? I'm fine it goes either way.
Luis
Quoted 18 lines · Luis Chamberlain
Quoted 16 lines · Masahiro Yamada
Commit
f50169324df4("module.h: split out theEXPORT_SYMBOLintoexport.h") appropriately separatedEXPORT_SYMBOLinto <linux/export.h> because modules andEXPORT_SYMBOLare orthogonal; modules are symbol consumers, whileEXPORT_SYMBOLare used by symbol providers, which may not be necessarily a module.However, that commit also relocated
THIS_MODULE. As explained in the commit description, the intention was to defineTHIS_MODULEin a lightweight header, but I do not believe <linux/export.h> was the suitable location becauseEXPORT_SYMBOLandTHIS_MODULEare unrelated.Move it to another lightweight header, <
linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>.
Quoted 6 lines
Quoted 4 lines
With this adjustment, the role of <
linux/export.h> becomes clearer as it only definesEXPORT_SYMBOL.Signed-off-by Masahiro Yamada <[email protected]>Reviewed-by Luis Chamberlain <[email protected]>
I will fold your reviewed-by tag.
Thanks.
Quoted 5 lines
Do you want this this to go through modules-next or your tree? I'm fine it goes either way.
Luis
Signature · 2 lines
Best Regards Masahiro Yamada