section name cleanup for mn10300
cover section name cleanup for mn10300
This patch series cleans up the section names on the mn10300 architecture. It requires the architecture-independent macro definitions from this patch series:
<http://www.spinics.net/lists/mips/msg33499.html>
The long-term goal here is to add support for building the kernel with -ffunction-sections -fdata-sections. This requires renaming all the magic section names in the kernel of the form .text.foo, .data.foo, .bss.foo, and .rodata.foo to not have collisions with sections generated for code like:
static int nosave = 0; /* -fdata-sections places in .data.nosave */ static void head(); /* -ffunction-sections places in .text.head */
Note that these patches have not been boot-tested (aside from testing the analogous changes on x86), since I don't have access to the appropriate hardware.
-Tim Abbott
Tim Abbott (6):
mn10300: Use macros for .bss.page_aligned section.
mn10300: Drop unused .data.idt section.
mn10300: use NOSAVE_DATA macro for .data.nosave section.
mn10300: use new macro for .data.cacheline_aligned section.
mn10300: use new macros for .data.init_task.
mn10300: use new macro for .data.read_mostly section.
arch/mn10300/kernel/init_task.c | 3 +-- arch/mn10300/kernel/vmlinux.lds.S | 29 ++++++----------------------- 2 files changed, 7 insertions(+), 25 deletions(-)
PATCH 1/6 mn10300: Use macros for .bss.page_aligned section.
--- arch/mn10300/kernel/vmlinux.lds.S | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mn10300/kernel/vmlinux.lds.S +1 -1
@@ -131,7 +131,7 @@ SECTIONS __bss_start = .; /* BSS */ .bss : { - *(.bss.page_aligned) + PAGE_ALIGNED_BSS *(.bss) } . = ALIGN(4);
Signature · 1 line
1.6.2.1
PATCH 2/6 mn10300: Drop unused .data.idt section.
Since nothing gets put into .data.idt on this architecture, eliminate it from the linker script.
This change was apparently proposed previously:
<http://lkml.indiana.edu/hypermail/linux/kernel/0802.2/2538.html>
CCing the author and people who acked that patch in case there was a reason it wasn't applied.
--- arch/mn10300/kernel/vmlinux.lds.S | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
arch/mn10300/kernel/vmlinux.lds.S +0 -3
@@ -59,9 +59,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); __nosave_end = .; - . = ALIGN(PAGE_SIZE); - .data.page_aligned : { *(.data.idt) } - . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) }
Signature · 1 line
1.6.2.1
PATCH 3/6 mn10300: use NOSAVE_DATA macro for .data.nosave section.
.data.nosave should not need a separate output section; this change moves it into the .data output section.
--- arch/mn10300/kernel/vmlinux.lds.S | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
arch/mn10300/kernel/vmlinux.lds.S +1 -6
@@ -49,16 +49,11 @@ SECTIONS /* writeable */ .data : { /* Data */ + NOSAVE_DATA DATA_DATA CONSTRUCTORS } - . = ALIGN(PAGE_SIZE); - __nosave_begin = .; - .data_nosave : { *(.data.nosave) } - . = ALIGN(PAGE_SIZE); - __nosave_end = .; - . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) }
Signature · 1 line
1.6.2.1
PATCH 4/6 mn10300: use new macro for .data.cacheline_aligned section.
.data.cacheline_aligned should not need a separate output section; this change moves it into the .data section.
--- arch/mn10300/kernel/vmlinux.lds.S | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/mn10300/kernel/vmlinux.lds.S +1 -3
@@ -50,13 +50,11 @@ SECTIONS /* writeable */ .data : { /* Data */ NOSAVE_DATA + CACHELINE_ALIGNED_DATA(32) DATA_DATA CONSTRUCTORS } - . = ALIGN(32); - .data.cacheline_aligned : { *(.data.cacheline_aligned) } - /* rarely changed data like cpu maps */ . = ALIGN(32); .data.read_mostly : AT(ADDR(.data.read_mostly)) {
Signature · 1 line
1.6.2.1
PATCH 5/6 mn10300: use new macros for .data.init_task.
.data.init_task should not need a separate output section; this change moves it into the .data section.
--- arch/mn10300/kernel/init_task.c | 3 +-- arch/mn10300/kernel/vmlinux.lds.S | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-)
arch/mn10300/kernel/init_task.c +1 -2
@@ -30,8 +30,7 @@ EXPORT_SYMBOL(init_mm);* way process stacks are handled. This is done by having a special * "init_task" linker map entry.. */ -union thread_union init_thread_union - __attribute__((__section__(".data.init_task"))) = +union thread_union init_thread_union __init_task_data = {INIT_THREAD_INFO (init_task) };/*
arch/mn10300/kernel/vmlinux.lds.S +1 -3
@@ -49,6 +49,7 @@ SECTIONS /* writeable */ .data : { /* Data */ + INIT_TASK_DATA(THREAD_SIZE) NOSAVE_DATA CACHELINE_ALIGNED_DATA(32) DATA_DATA
@@ -62,9 +63,6 @@ SECTIONS _edata = .; /* End of data section */ } - . = ALIGN(THREAD_SIZE); /* init_task */ - .data.init_task : { *(.data.init_task) } - /* might get freed after init */ . = ALIGN(PAGE_SIZE); .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
Signature · 1 line
1.6.2.1
PATCH 6/6 mn10300: use new macro for .data.read_mostly section.
.data.read_mostly should not need a separate output section; this change moves it into the .data section.
--- arch/mn10300/kernel/vmlinux.lds.S | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
arch/mn10300/kernel/vmlinux.lds.S +2 -7
@@ -52,16 +52,11 @@ SECTIONS INIT_TASK_DATA(THREAD_SIZE) NOSAVE_DATA CACHELINE_ALIGNED_DATA(32) + READ_MOSTLY_DATA(32) DATA_DATA CONSTRUCTORS - } - - /* rarely changed data like cpu maps */ - . = ALIGN(32); - .data.read_mostly : AT(ADDR(.data.read_mostly)) { - *(.data.read_mostly) _edata = .; /* End of data section */ - } + } /* might get freed after init */ . = ALIGN(PAGE_SIZE);
Signature · 1 line
1.6.2.1
Re: [PATCH 5/6] mn10300: use new macros for .data.init_task.
In reply to Tim AbbottQuoted 2 lines · Tim Abbott
.data.init_task should not need a separate output section; this change moves it into the .data section.
Hmmm... This causes the kernel I'm building to make an extra page of RAM into dead space.
David
Re: [PATCH 5/6] mn10300: use new macros for .data.init_task.
Quoted 7 lines · David Howells
Quoted 2 lines · Tim Abbott
.data.init_task should not need a separate output section; this change moves it into the .data section.
Hmmm... This causes the kernel I'm building to make an extra page of RAM into dead space.
I would try reversing the order of the things inside the .data output section, since the stuff after .data at the end of this patch series is page-aligned, while the stuff before .data isn't.
-Tim Abbott
Re: [PATCH 5/6] mn10300: use new macros for .data.init_task.
Quoted 7 lines · Tim Abbott
Quoted 5 lines · David Howells
Quoted 2 lines · Tim Abbott
.data.init_task should not need a separate output section; this change moves it into the .data section.
Quoted 6 lines
Quoted 2 lines
Hmmm... This causes the kernel I'm building to make an extra page of RAM into dead space.
I would try reversing the order of the things inside the .data output section, since the stuff after .data at the end of this patch series is page-aligned, while the stuff before .data isn't.
I'm looking into creating a WRDATA macro like we have RODATA today. If that flys then we will hide a lot in that section, including the correct order.
But it will take a few hours before I'm ready.
Sam
Quoted 3 lines · Tim Abbott
This patch series cleans up the section names on the mn10300 architecture. It requires the architecture-independent macro definitions from this patch series:
Interesting... Whilst it compiles and links with no problems, this cleanup has the following detrimental effects:
None of these patches applied
text data bss dec hex filename 1879329 82980 321772 2284081 22da31 vmlinux
All of these patches applied:
text data bss dec hex filename 1879329 87076 321772 2288177 22ea31 vmlinux
Somewhere it eats an extra page.
David
Quoted 14 lines · David Howells
Quoted 3 lines · Tim Abbott
This patch series cleans up the section names on the mn10300 architecture. It requires the architecture-independent macro definitions from this patch series:
Interesting... Whilst it compiles and links with no problems, this cleanup has the following detrimental effects:
None of these patches applied
text data bss dec hex filename 1879329 82980 321772 2284081 22da31 vmlinux
Quoted 6 lines
All of these patches applied:
text data bss dec hex filename 1879329 87076 321772 2288177 22ea31 vmlinuxSomewhere it eats an extra page.
This is likely due to moving around the sections and we have got them in less perfect order.
I also thing 5/6 is wrong as it movesinit_task befoe _edata.
Could you try to back out them one by one
to see which one causes the extra memory waste.
Sam
Quoted 5 lines · Sam Ravnborg
I also thing 5/6 is wrong as it moves
init_taskbefoe_edata.Could you try to back out them one by one
to see which one causes the extra memory waste.
Moving init_task around is the culprit.
I guess the extra page has a 50% chance of being leaked anyway, as it depends on the alignment of the previous section.
I can probably make the kernel reclaim it by sticking a label either side of the alignment and if they're more than a page apart, reclaim the page that ends at the second label.
David