* [PATCH] initconst adjustments
@ 2009-03-12 10:58 Jan Beulich
2009-03-12 22:17 ` Sam Ravnborg
2009-05-01 12:09 ` Sam Ravnborg
0 siblings, 2 replies; 4+ messages in thread
From: Jan Beulich @ 2009-03-12 10:58 UTC (permalink / raw)
To: sam; +Cc: linux-kernel
- add .init.rodata to INIT_DATA, and group all initconst flavors
together
- move strings generated from __setup_param() into .init.rodata
- add .*init.rodata to modpost's sets of init sections
- make modpost warn about references between meminit and cpuinit
as well as memexit and cpuexit sections (as CPU and memory
hotplug are independently selectable features)
Signed-off-by: Jan Beulich <jbeulich@novell.com>
---
include/asm-generic/vmlinux.lds.h | 5 ++-
include/linux/init.h | 3 +-
scripts/mod/modpost.c | 50 +++++++++++++++++++++++++++++---------
3 files changed, 44 insertions(+), 14 deletions(-)
--- linux-2.6.29-rc7/include/asm-generic/vmlinux.lds.h 2009-03-04 09:10:56.000000000 +0100
+++ 2.6.29-rc7-initconst/include/asm-generic/vmlinux.lds.h 2009-02-13 12:17:25.000000000 +0100
@@ -305,10 +305,11 @@
#define INIT_DATA \
*(.init.data) \
DEV_DISCARD(init.data) \
- DEV_DISCARD(init.rodata) \
CPU_DISCARD(init.data) \
- CPU_DISCARD(init.rodata) \
MEM_DISCARD(init.data) \
+ *(.init.rodata) \
+ DEV_DISCARD(init.rodata) \
+ CPU_DISCARD(init.rodata) \
MEM_DISCARD(init.rodata) \
/* implement dynamic printk debug */ \
VMLINUX_SYMBOL(__start___verbose_strings) = .; \
--- linux-2.6.29-rc7/include/linux/init.h 2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-initconst/include/linux/init.h 2009-02-13 12:17:25.000000000 +0100
@@ -231,7 +231,8 @@ struct obs_kernel_param {
* obs_kernel_param "array" too far apart in .init.setup.
*/
#define __setup_param(str, unique_id, fn, early) \
- static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \
+ static const char __setup_str_##unique_id[] __initconst \
+ __aligned(1) = str; \
static struct obs_kernel_param __setup_##unique_id \
__used __section(.init.setup) \
__attribute__((aligned((sizeof(long))))) \
--- linux-2.6.29-rc7/scripts/mod/modpost.c 2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-initconst/scripts/mod/modpost.c 2009-02-13 12:17:25.000000000 +0100
@@ -753,6 +753,8 @@ static int check_section(const char *mod
#define ALL_INIT_DATA_SECTIONS \
+ ".init.setup$", ".init.rodata$", \
+ ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$" \
".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$"
#define ALL_EXIT_DATA_SECTIONS \
".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$"
@@ -762,21 +764,23 @@ static int check_section(const char *mod
#define ALL_EXIT_TEXT_SECTIONS \
".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"
-#define ALL_INIT_SECTIONS ALL_INIT_DATA_SECTIONS, ALL_INIT_TEXT_SECTIONS
-#define ALL_EXIT_SECTIONS ALL_EXIT_DATA_SECTIONS, ALL_EXIT_TEXT_SECTIONS
+#define ALL_INIT_SECTIONS INIT_SECTIONS, DEV_INIT_SECTIONS, \
+ CPU_INIT_SECTIONS, MEM_INIT_SECTIONS
+#define ALL_EXIT_SECTIONS EXIT_SECTIONS, DEV_EXIT_SECTIONS, \
+ CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS
#define DATA_SECTIONS ".data$", ".data.rel$"
#define TEXT_SECTIONS ".text$"
-#define INIT_SECTIONS ".init.data$", ".init.text$"
-#define DEV_INIT_SECTIONS ".devinit.data$", ".devinit.text$"
-#define CPU_INIT_SECTIONS ".cpuinit.data$", ".cpuinit.text$"
-#define MEM_INIT_SECTIONS ".meminit.data$", ".meminit.text$"
-
-#define EXIT_SECTIONS ".exit.data$", ".exit.text$"
-#define DEV_EXIT_SECTIONS ".devexit.data$", ".devexit.text$"
-#define CPU_EXIT_SECTIONS ".cpuexit.data$", ".cpuexit.text$"
-#define MEM_EXIT_SECTIONS ".memexit.data$", ".memexit.text$"
+#define INIT_SECTIONS ".init.*"
+#define DEV_INIT_SECTIONS ".devinit.*"
+#define CPU_INIT_SECTIONS ".cpuinit.*"
+#define MEM_INIT_SECTIONS ".meminit.*"
+
+#define EXIT_SECTIONS ".exit.*"
+#define DEV_EXIT_SECTIONS ".devexit.*"
+#define CPU_EXIT_SECTIONS ".cpuexit.*"
+#define MEM_EXIT_SECTIONS ".memexit.*"
/* init data sections */
static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL };
@@ -868,12 +872,36 @@ const struct sectioncheck sectioncheck[]
.tosec = { INIT_SECTIONS, NULL },
.mismatch = XXXINIT_TO_INIT,
},
+/* Do not reference cpuinit code/data from meminit code/data */
+{
+ .fromsec = { MEM_INIT_SECTIONS, NULL },
+ .tosec = { CPU_INIT_SECTIONS, NULL },
+ .mismatch = XXXINIT_TO_INIT,
+},
+/* Do not reference meminit code/data from cpuinit code/data */
+{
+ .fromsec = { CPU_INIT_SECTIONS, NULL },
+ .tosec = { MEM_INIT_SECTIONS, NULL },
+ .mismatch = XXXINIT_TO_INIT,
+},
/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
{
.fromsec = { DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS, NULL },
.tosec = { EXIT_SECTIONS, NULL },
.mismatch = XXXEXIT_TO_EXIT,
},
+/* Do not reference cpuexit code/data from memexit code/data */
+{
+ .fromsec = { MEM_EXIT_SECTIONS, NULL },
+ .tosec = { CPU_EXIT_SECTIONS, NULL },
+ .mismatch = XXXEXIT_TO_EXIT,
+},
+/* Do not reference memexit code/data from cpuexit code/data */
+{
+ .fromsec = { CPU_EXIT_SECTIONS, NULL },
+ .tosec = { MEM_EXIT_SECTIONS, NULL },
+ .mismatch = XXXEXIT_TO_EXIT,
+},
/* Do not use exit code/data from init code */
{
.fromsec = { ALL_INIT_SECTIONS, NULL },
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] initconst adjustments
2009-03-12 10:58 [PATCH] initconst adjustments Jan Beulich
@ 2009-03-12 22:17 ` Sam Ravnborg
2009-03-13 8:03 ` Jan Beulich
2009-05-01 12:09 ` Sam Ravnborg
1 sibling, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2009-03-12 22:17 UTC (permalink / raw)
To: Jan Beulich; +Cc: linux-kernel
On Thu, Mar 12, 2009 at 10:58:33AM +0000, Jan Beulich wrote:
> - add .init.rodata to INIT_DATA, and group all initconst flavors
> together
> - move strings generated from __setup_param() into .init.rodata
> - add .*init.rodata to modpost's sets of init sections
> - make modpost warn about references between meminit and cpuinit
> as well as memexit and cpuexit sections (as CPU and memory
> hotplug are independently selectable features)
>
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
>
> ---
> include/asm-generic/vmlinux.lds.h | 5 ++-
> include/linux/init.h | 3 +-
> scripts/mod/modpost.c | 50 +++++++++++++++++++++++++++++---------
> 3 files changed, 44 insertions(+), 14 deletions(-)
>
> +++ 2.6.29-rc7-initconst/scripts/mod/modpost.c 2009-02-13 12:17:25.000000000 +0100
> @@ -753,6 +753,8 @@ static int check_section(const char *mod
>
>
> #define ALL_INIT_DATA_SECTIONS \
> + ".init.setup$", ".init.rodata$", \
> + ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$" \
> ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$"
> #define ALL_EXIT_DATA_SECTIONS \
> ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$"
> @@ -762,21 +764,23 @@ static int check_section(const char *mod
> #define ALL_EXIT_TEXT_SECTIONS \
> ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"
>
> -#define ALL_INIT_SECTIONS ALL_INIT_DATA_SECTIONS, ALL_INIT_TEXT_SECTIONS
> -#define ALL_EXIT_SECTIONS ALL_EXIT_DATA_SECTIONS, ALL_EXIT_TEXT_SECTIONS
> +#define ALL_INIT_SECTIONS INIT_SECTIONS, DEV_INIT_SECTIONS, \
> + CPU_INIT_SECTIONS, MEM_INIT_SECTIONS
> +#define ALL_EXIT_SECTIONS EXIT_SECTIONS, DEV_EXIT_SECTIONS, \
> + CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS
>
> #define DATA_SECTIONS ".data$", ".data.rel$"
> #define TEXT_SECTIONS ".text$"
>
> -#define INIT_SECTIONS ".init.data$", ".init.text$"
> -#define DEV_INIT_SECTIONS ".devinit.data$", ".devinit.text$"
> -#define CPU_INIT_SECTIONS ".cpuinit.data$", ".cpuinit.text$"
> -#define MEM_INIT_SECTIONS ".meminit.data$", ".meminit.text$"
> -
> -#define EXIT_SECTIONS ".exit.data$", ".exit.text$"
> -#define DEV_EXIT_SECTIONS ".devexit.data$", ".devexit.text$"
> -#define CPU_EXIT_SECTIONS ".cpuexit.data$", ".cpuexit.text$"
> -#define MEM_EXIT_SECTIONS ".memexit.data$", ".memexit.text$"
> +#define INIT_SECTIONS ".init.*"
> +#define DEV_INIT_SECTIONS ".devinit.*"
> +#define CPU_INIT_SECTIONS ".cpuinit.*"
> +#define MEM_INIT_SECTIONS ".meminit.*"
> +
> +#define EXIT_SECTIONS ".exit.*"
> +#define DEV_EXIT_SECTIONS ".devexit.*"
> +#define CPU_EXIT_SECTIONS ".cpuexit.*"
> +#define MEM_EXIT_SECTIONS ".memexit.*"
The abvoe simplification now makes us math all sections that starts with
for example .init. - and we have seen sections named .init.1 for example.
So I'm afraid that we will simply match too many sections here on the various
architectures.
A quick grep showed for example:
arch/blackfin/kernel/vmlinux.lds.S: .init.setup :
arch/blackfin/kernel/vmlinux.lds.S: *(.init.setup)
arch/blackfin/kernel/vmlinux.lds.S: .init.ramfs :
arch/blackfin/kernel/vmlinux.lds.S: *(.init.ramfs)
We should be on the safe side and avoid this optimization.
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] initconst adjustments
2009-03-12 22:17 ` Sam Ravnborg
@ 2009-03-13 8:03 ` Jan Beulich
0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2009-03-13 8:03 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kernel
>>> Sam Ravnborg <sam@ravnborg.org> 12.03.09 23:17 >>>
>On Thu, Mar 12, 2009 at 10:58:33AM +0000, Jan Beulich wrote:
>> +#define INIT_SECTIONS ".init.*"
>> +#define DEV_INIT_SECTIONS ".devinit.*"
>> +#define CPU_INIT_SECTIONS ".cpuinit.*"
>> +#define MEM_INIT_SECTIONS ".meminit.*"
>> +
>> +#define EXIT_SECTIONS ".exit.*"
>> +#define DEV_EXIT_SECTIONS ".devexit.*"
>> +#define CPU_EXIT_SECTIONS ".cpuexit.*"
>> +#define MEM_EXIT_SECTIONS ".memexit.*"
>
>The abvoe simplification now makes us math all sections that starts with
>for example .init. - and we have seen sections named .init.1 for example.
But that exactly is intended: Anything named .init.* should be what its
name says - init-only code or data. Even (if it was used anywhere) .init
itself should be this and nothing else. Any other use of such a name is
really broken imo.
>So I'm afraid that we will simply match too many sections here on the various
>architectures.
>
>
>A quick grep showed for example:
>arch/blackfin/kernel/vmlinux.lds.S: .init.setup :
>arch/blackfin/kernel/vmlinux.lds.S: *(.init.setup)
>arch/blackfin/kernel/vmlinux.lds.S: .init.ramfs :
>arch/blackfin/kernel/vmlinux.lds.S: *(.init.ramfs)
Which is precisely a case that we want to cover: These two sections are
init-only data (and site between ___init_begin and ___init_end, and hence
ought to be subject of the modpost checking.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] initconst adjustments
2009-03-12 10:58 [PATCH] initconst adjustments Jan Beulich
2009-03-12 22:17 ` Sam Ravnborg
@ 2009-05-01 12:09 ` Sam Ravnborg
1 sibling, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2009-05-01 12:09 UTC (permalink / raw)
To: Jan Beulich; +Cc: linux-kernel
On Thu, Mar 12, 2009 at 10:58:33AM +0000, Jan Beulich wrote:
> - add .init.rodata to INIT_DATA, and group all initconst flavors
> together
> - move strings generated from __setup_param() into .init.rodata
> - add .*init.rodata to modpost's sets of init sections
> - make modpost warn about references between meminit and cpuinit
> as well as memexit and cpuexit sections (as CPU and memory
> hotplug are independently selectable features)
>
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
Applied to kbuild-next.
Sam
[Kept rest of mail for reference as this is a fairly old patch by now].
>
> ---
> include/asm-generic/vmlinux.lds.h | 5 ++-
> include/linux/init.h | 3 +-
> scripts/mod/modpost.c | 50 +++++++++++++++++++++++++++++---------
> 3 files changed, 44 insertions(+), 14 deletions(-)
>
> --- linux-2.6.29-rc7/include/asm-generic/vmlinux.lds.h 2009-03-04 09:10:56.000000000 +0100
> +++ 2.6.29-rc7-initconst/include/asm-generic/vmlinux.lds.h 2009-02-13 12:17:25.000000000 +0100
> @@ -305,10 +305,11 @@
> #define INIT_DATA \
> *(.init.data) \
> DEV_DISCARD(init.data) \
> - DEV_DISCARD(init.rodata) \
> CPU_DISCARD(init.data) \
> - CPU_DISCARD(init.rodata) \
> MEM_DISCARD(init.data) \
> + *(.init.rodata) \
> + DEV_DISCARD(init.rodata) \
> + CPU_DISCARD(init.rodata) \
> MEM_DISCARD(init.rodata) \
> /* implement dynamic printk debug */ \
> VMLINUX_SYMBOL(__start___verbose_strings) = .; \
> --- linux-2.6.29-rc7/include/linux/init.h 2008-12-25 00:26:37.000000000 +0100
> +++ 2.6.29-rc7-initconst/include/linux/init.h 2009-02-13 12:17:25.000000000 +0100
> @@ -231,7 +231,8 @@ struct obs_kernel_param {
> * obs_kernel_param "array" too far apart in .init.setup.
> */
> #define __setup_param(str, unique_id, fn, early) \
> - static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \
> + static const char __setup_str_##unique_id[] __initconst \
> + __aligned(1) = str; \
> static struct obs_kernel_param __setup_##unique_id \
> __used __section(.init.setup) \
> __attribute__((aligned((sizeof(long))))) \
> --- linux-2.6.29-rc7/scripts/mod/modpost.c 2008-12-25 00:26:37.000000000 +0100
> +++ 2.6.29-rc7-initconst/scripts/mod/modpost.c 2009-02-13 12:17:25.000000000 +0100
> @@ -753,6 +753,8 @@ static int check_section(const char *mod
>
>
> #define ALL_INIT_DATA_SECTIONS \
> + ".init.setup$", ".init.rodata$", \
> + ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$" \
> ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$"
> #define ALL_EXIT_DATA_SECTIONS \
> ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$"
> @@ -762,21 +764,23 @@ static int check_section(const char *mod
> #define ALL_EXIT_TEXT_SECTIONS \
> ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"
>
> -#define ALL_INIT_SECTIONS ALL_INIT_DATA_SECTIONS, ALL_INIT_TEXT_SECTIONS
> -#define ALL_EXIT_SECTIONS ALL_EXIT_DATA_SECTIONS, ALL_EXIT_TEXT_SECTIONS
> +#define ALL_INIT_SECTIONS INIT_SECTIONS, DEV_INIT_SECTIONS, \
> + CPU_INIT_SECTIONS, MEM_INIT_SECTIONS
> +#define ALL_EXIT_SECTIONS EXIT_SECTIONS, DEV_EXIT_SECTIONS, \
> + CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS
>
> #define DATA_SECTIONS ".data$", ".data.rel$"
> #define TEXT_SECTIONS ".text$"
>
> -#define INIT_SECTIONS ".init.data$", ".init.text$"
> -#define DEV_INIT_SECTIONS ".devinit.data$", ".devinit.text$"
> -#define CPU_INIT_SECTIONS ".cpuinit.data$", ".cpuinit.text$"
> -#define MEM_INIT_SECTIONS ".meminit.data$", ".meminit.text$"
> -
> -#define EXIT_SECTIONS ".exit.data$", ".exit.text$"
> -#define DEV_EXIT_SECTIONS ".devexit.data$", ".devexit.text$"
> -#define CPU_EXIT_SECTIONS ".cpuexit.data$", ".cpuexit.text$"
> -#define MEM_EXIT_SECTIONS ".memexit.data$", ".memexit.text$"
> +#define INIT_SECTIONS ".init.*"
> +#define DEV_INIT_SECTIONS ".devinit.*"
> +#define CPU_INIT_SECTIONS ".cpuinit.*"
> +#define MEM_INIT_SECTIONS ".meminit.*"
> +
> +#define EXIT_SECTIONS ".exit.*"
> +#define DEV_EXIT_SECTIONS ".devexit.*"
> +#define CPU_EXIT_SECTIONS ".cpuexit.*"
> +#define MEM_EXIT_SECTIONS ".memexit.*"
>
> /* init data sections */
> static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL };
> @@ -868,12 +872,36 @@ const struct sectioncheck sectioncheck[]
> .tosec = { INIT_SECTIONS, NULL },
> .mismatch = XXXINIT_TO_INIT,
> },
> +/* Do not reference cpuinit code/data from meminit code/data */
> +{
> + .fromsec = { MEM_INIT_SECTIONS, NULL },
> + .tosec = { CPU_INIT_SECTIONS, NULL },
> + .mismatch = XXXINIT_TO_INIT,
> +},
> +/* Do not reference meminit code/data from cpuinit code/data */
> +{
> + .fromsec = { CPU_INIT_SECTIONS, NULL },
> + .tosec = { MEM_INIT_SECTIONS, NULL },
> + .mismatch = XXXINIT_TO_INIT,
> +},
> /* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
> {
> .fromsec = { DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS, NULL },
> .tosec = { EXIT_SECTIONS, NULL },
> .mismatch = XXXEXIT_TO_EXIT,
> },
> +/* Do not reference cpuexit code/data from memexit code/data */
> +{
> + .fromsec = { MEM_EXIT_SECTIONS, NULL },
> + .tosec = { CPU_EXIT_SECTIONS, NULL },
> + .mismatch = XXXEXIT_TO_EXIT,
> +},
> +/* Do not reference memexit code/data from cpuexit code/data */
> +{
> + .fromsec = { CPU_EXIT_SECTIONS, NULL },
> + .tosec = { MEM_EXIT_SECTIONS, NULL },
> + .mismatch = XXXEXIT_TO_EXIT,
> +},
> /* Do not use exit code/data from init code */
> {
> .fromsec = { ALL_INIT_SECTIONS, NULL },
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-01 12:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-12 10:58 [PATCH] initconst adjustments Jan Beulich
2009-03-12 22:17 ` Sam Ravnborg
2009-03-13 8:03 ` Jan Beulich
2009-05-01 12:09 ` Sam Ravnborg
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.