2009-04-28 17:07:10

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 00/15] clean up page aligned data and bss sections

Sam,

Here's a new version of the page-aligned section cleanup patch
series. Changes since last version include:

- added missing semicolons for ALIGN() directives in the macro
definitions in PATCH 1/14.
- fixed a bug in the powerpc patch where the DATA_PAGE_ALIGNED was
inside a CONFIG_PPC32 in PATCH 11/14 (which is now 2 patches)

---

This patch series add new macros for .data.page_aligned and
.bss.page_aligned, and converts the various architectures to use them.
It also eliminates the few remaining uses of .data.idt by replacing
them with references to .data.page_aligned.

This patch series is a bunch of cleanup in preparation for being able
to change the names of the .data.page_aligned and .bss.page_aligned
sections to be compatabible with -ffunction-sections -fdata-sections.

The x86 patches are on top of the your commit in the x86/kbuild of
linux-tip entitled:

x86: beautify vmlinux_64.lds.S

as requested by Linus.

Tim Abbott (15):
Add new macros for page-aligned data and bss sections.
sh: Use macros for .bss.page_aligned section.
mn10300: Use macros for .bss.page_aligned section.
xtensa: Use macros for .bss.page_aligned section.
x86: Use macros for .bss.page_aligned section.
alpha: Use macros for .data.page_aligned.
avr32: Use standard macros for .data.page_aligned section.
sh: Use macros for .data.page_aligned section.
s390: Use macros for .data.page_aligned.
powerpc: Remove unused __page_aligned macro.
powerpc: share .data output section definition between 32 and 64
bits.
powerpc: Use macros for .data.page_aligned section.
mn10300: Drop unused .data.idt section.
x86: Use section .data.page_aligned for the idt_table.
x86: Use macros for .data.page_aligned.

arch/alpha/kernel/vmlinux.lds.S | 6 +-----
arch/avr32/kernel/vmlinux.lds.S | 3 +--
arch/avr32/mm/init.c | 4 +---
arch/mn10300/kernel/vmlinux.lds.S | 5 +----
arch/powerpc/include/asm/page_64.h | 8 --------
arch/powerpc/kernel/vdso.c | 2 +-
arch/powerpc/kernel/vdso32/vdso32_wrapper.S | 3 ++-
arch/powerpc/kernel/vdso64/vdso64_wrapper.S | 3 ++-
arch/powerpc/kernel/vmlinux.lds.S | 13 ++++---------
arch/s390/kernel/vdso.c | 2 +-
arch/s390/kernel/vdso32/vdso32_wrapper.S | 3 ++-
arch/s390/kernel/vdso64/vdso64_wrapper.S | 3 ++-
arch/s390/kernel/vmlinux.lds.S | 6 +-----
arch/sh/kernel/irq.c | 6 ++----
arch/sh/kernel/vmlinux_32.lds.S | 5 ++---
arch/sh/kernel/vmlinux_64.lds.S | 5 ++---
arch/x86/kernel/head_32.S | 4 ++--
arch/x86/kernel/head_64.S | 2 +-
arch/x86/kernel/traps.c | 6 ++----
arch/x86/kernel/vmlinux_32.lds.S | 9 ++-------
arch/x86/kernel/vmlinux_64.lds.S | 8 ++------
arch/xtensa/kernel/head.S | 2 +-
arch/xtensa/kernel/vmlinux.lds.S | 2 +-
include/asm-generic/vmlinux.lds.h | 8 ++++++++
include/linux/linkage.h | 9 +++++++++
25 files changed, 53 insertions(+), 74 deletions(-)


2009-04-28 17:01:53

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 01/15] Add new macros for page-aligned data and bss sections.

This patch is preparation for replacing most uses of
".bss.page_aligned" and ".data.page_aligned" in the kernel with
macros, so that the section name can later be changed without having
to touch a lot of the kernel.

The long-term goal here is to be able to change the kernel's magic
section names to those that are compatible with -ffunction-sections
-fdata-sections. This requires renaming all magic sections with names
of the form ".data.foo".

Signed-off-by: Tim Abbott <[email protected]>
Cc: Sam Ravnborg <[email protected]>
---
include/asm-generic/vmlinux.lds.h | 8 ++++++++
include/linux/linkage.h | 9 +++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 89853bc..3d88c87 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -116,6 +116,14 @@
FTRACE_EVENTS() \
TRACE_SYSCALLS()

+#define PAGE_ALIGNED_DATA \
+ . = ALIGN(PAGE_SIZE); \
+ *(.data.page_aligned)
+
+#define PAGE_ALIGNED_BSS \
+ . = ALIGN(PAGE_SIZE); \
+ *(.bss.page_aligned)
+
#define RO_DATA(align) \
. = ALIGN((align)); \
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index fee9e59..af051fc 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -22,6 +22,15 @@
#define __page_aligned_bss __section(.bss.page_aligned) __aligned(PAGE_SIZE)

/*
+ * For assembly routines.
+ *
+ * Note when using these that you must specify the appropriate
+ * alignment directives yourself
+ */
+#define __PAGE_ALIGNED_DATA .section ".data.page_aligned", "aw", @progbits
+#define __PAGE_ALIGNED_BSS .section ".bss.page_aligned", "aw", @nobits
+
+/*
* This is used by architectures to keep arguments on the stack
* untouched by the compiler by keeping them live until the end.
* The argument stack may be owned by the assembly-language
--
1.6.2.1

2009-04-28 17:02:55

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 08/15] sh: Use macros for .data.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Acked-by: Paul Mundt <[email protected]>
---
arch/sh/kernel/vmlinux_32.lds.S | 3 +--
arch/sh/kernel/vmlinux_64.lds.S | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/sh/kernel/vmlinux_32.lds.S b/arch/sh/kernel/vmlinux_32.lds.S
index 99a4124..325af0b 100644
--- a/arch/sh/kernel/vmlinux_32.lds.S
+++ b/arch/sh/kernel/vmlinux_32.lds.S
@@ -69,8 +69,7 @@ SECTIONS
. = ALIGN(L1_CACHE_BYTES);
*(.data.read_mostly)

- . = ALIGN(PAGE_SIZE);
- *(.data.page_aligned)
+ PAGE_ALIGNED_DATA

__nosave_begin = .;
*(.data.nosave)
diff --git a/arch/sh/kernel/vmlinux_64.lds.S b/arch/sh/kernel/vmlinux_64.lds.S
index cb46577..b222700 100644
--- a/arch/sh/kernel/vmlinux_64.lds.S
+++ b/arch/sh/kernel/vmlinux_64.lds.S
@@ -78,8 +78,7 @@ SECTIONS
. = ALIGN(L1_CACHE_BYTES);
*(.data.read_mostly)

- . = ALIGN(PAGE_SIZE);
- *(.data.page_aligned)
+ PAGE_ALIGNED_DATA

__nosave_begin = .;
*(.data.nosave)
--
1.6.2.1

2009-04-28 17:02:28

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 09/15] s390: Use macros for .data.page_aligned.

.data.page_aligned should not need a separate output section, so as
part of this cleanup I moved into the .data output section in the
linker scripts in order to eliminate unnecessary references to the
section name.

Remove the reference to .data.idt, since nothing is put into the
.data.idt section on the s390 architecture. It looks like Cyrill
Gorcunov posted a patch to remove the .data.idt code on s390
previously:

<http://lkml.indiana.edu/hypermail/linux/kernel/0802.2/2536.html>

CCing him and the people who acked that patch in case there's a reason
it wasn't applied.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: Sam Ravnborg <[email protected]>
---
arch/s390/kernel/vdso.c | 2 +-
arch/s390/kernel/vdso32/vdso32_wrapper.S | 3 ++-
arch/s390/kernel/vdso64/vdso64_wrapper.S | 3 ++-
arch/s390/kernel/vmlinux.lds.S | 6 +-----
4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 89b2e7f..eff6fba 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -64,7 +64,7 @@ __setup("vdso=", vdso_setup);
static union {
struct vdso_data data;
u8 page[PAGE_SIZE];
-} vdso_data_store __attribute__((__section__(".data.page_aligned")));
+} vdso_data_store __page_aligned_data
struct vdso_data *vdso_data = &vdso_data_store.data;

/*
diff --git a/arch/s390/kernel/vdso32/vdso32_wrapper.S b/arch/s390/kernel/vdso32/vdso32_wrapper.S
index 61639a8..ae42f8c 100644
--- a/arch/s390/kernel/vdso32/vdso32_wrapper.S
+++ b/arch/s390/kernel/vdso32/vdso32_wrapper.S
@@ -1,7 +1,8 @@
#include <linux/init.h>
+#include <linux/linkage.h>
#include <asm/page.h>

- .section ".data.page_aligned"
+ __PAGE_ALIGNED_DATA

.globl vdso32_start, vdso32_end
.balign PAGE_SIZE
diff --git a/arch/s390/kernel/vdso64/vdso64_wrapper.S b/arch/s390/kernel/vdso64/vdso64_wrapper.S
index d8e2ac1..c245842 100644
--- a/arch/s390/kernel/vdso64/vdso64_wrapper.S
+++ b/arch/s390/kernel/vdso64/vdso64_wrapper.S
@@ -1,7 +1,8 @@
#include <linux/init.h>
+#include <linux/linkage.h>
#include <asm/page.h>

- .section ".data.page_aligned"
+ __PAGE_ALIGNED_DATA

.globl vdso64_start, vdso64_end
.balign PAGE_SIZE
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 89399b8..d552089 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -59,6 +59,7 @@ SECTIONS
} :data

.data : { /* Data */
+ PAGE_ALIGNED_DATA
DATA_DATA
CONSTRUCTORS
}
@@ -71,11 +72,6 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
__nosave_end = .;

- . = ALIGN(PAGE_SIZE);
- .data.page_aligned : {
- *(.data.idt)
- }
-
. = ALIGN(0x100);
.data.cacheline_aligned : {
*(.data.cacheline_aligned)
--
1.6.2.1

2009-04-28 17:03:32

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 11/15] powerpc: share .data output section definition between 32 and 64 bits.

Since upcoming changes will add several more common pieces of code
between the 32-bit and 64-bit powerpc architectures, it seems best to
unify these two blocks.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index a047a6c..47899b0 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -220,20 +220,19 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
_sdata = .;

-#ifdef CONFIG_PPC32
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
+#ifdef CONFIG_PPC32
*(.sdata)
*(.got.plt) *(.got)
- }
#else
- .data : AT(ADDR(.data) - LOAD_OFFSET) {
- DATA_DATA
*(.data.rel*)
*(.toc1)
*(.branch_lt)
+#endif
}

+#ifndef CONFIG_PPC32
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
*(.opd)
}
--
1.6.2.1

2009-04-28 17:04:18

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 03/15] mn10300: Use macros for .bss.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Cc: David Howells <[email protected]>
---
arch/mn10300/kernel/vmlinux.lds.S | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 24de6b9..6ad0fa8 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -131,7 +131,7 @@ SECTIONS

__bss_start = .; /* BSS */
.bss : {
- *(.bss.page_aligned)
+ PAGE_ALIGNED_BSS
*(.bss)
}
. = ALIGN(4);
--
1.6.2.1

2009-04-28 17:04:45

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 06/15] alpha: Use macros for .data.page_aligned.

.data.page_aligned should not need a separate output section, so as
part of this cleanup I moved into the .data output section in the
linker scripts in order to eliminate unnecessary references to the
section name.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Richard Henderson <[email protected]>
---
arch/alpha/kernel/vmlinux.lds.S | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index b9d6568..2f33cf9 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -97,11 +97,6 @@ SECTIONS
*(.data.init_thread)
}

- . = ALIGN(PAGE_SIZE);
- .data.page_aligned : {
- *(.data.page_aligned)
- }
-
. = ALIGN(64);
.data.cacheline_aligned : {
*(.data.cacheline_aligned)
@@ -110,6 +105,7 @@ SECTIONS
_data = .;
/* Data */
.data : {
+ PAGE_ALIGNED_DATA
DATA_DATA
CONSTRUCTORS
}
--
1.6.2.1

2009-04-28 17:03:49

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 13/15] 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.

Signed-off-by: Tim Abbott <[email protected]>
Cc: David Howells <[email protected]>
Acked-by: Cyrill Gorcunov <[email protected]>
Cc: Sam Ravnborg <[email protected]>
---
arch/mn10300/kernel/vmlinux.lds.S | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 6ad0fa8..364250f 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -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) }

--
1.6.2.1

2009-04-28 17:05:18

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 02/15] sh: Use macros for .bss.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Acked-by: Paul Mundt <[email protected]>
---
arch/sh/kernel/irq.c | 6 ++----
arch/sh/kernel/vmlinux_32.lds.S | 2 +-
arch/sh/kernel/vmlinux_64.lds.S | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 3f1372e..9853fde 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -157,11 +157,9 @@ asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs)
}

#ifdef CONFIG_IRQSTACKS
-static char softirq_stack[NR_CPUS * THREAD_SIZE]
- __attribute__((__section__(".bss.page_aligned")));
+static char softirq_stack[NR_CPUS * THREAD_SIZE] __page_aligned_bss;

-static char hardirq_stack[NR_CPUS * THREAD_SIZE]
- __attribute__((__section__(".bss.page_aligned")));
+static char hardirq_stack[NR_CPUS * THREAD_SIZE] __page_aligned_bss;

/*
* allocate per-cpu stacks for hardirq and for softirq processing
diff --git a/arch/sh/kernel/vmlinux_32.lds.S b/arch/sh/kernel/vmlinux_32.lds.S
index dd9b2ee..99a4124 100644
--- a/arch/sh/kernel/vmlinux_32.lds.S
+++ b/arch/sh/kernel/vmlinux_32.lds.S
@@ -131,7 +131,7 @@ SECTIONS
.bss : {
__init_end = .;
__bss_start = .; /* BSS */
- *(.bss.page_aligned)
+ PAGE_ALIGNED_BSS
*(.bss)
*(COMMON)
. = ALIGN(4);
diff --git a/arch/sh/kernel/vmlinux_64.lds.S b/arch/sh/kernel/vmlinux_64.lds.S
index 6966446..cb46577 100644
--- a/arch/sh/kernel/vmlinux_64.lds.S
+++ b/arch/sh/kernel/vmlinux_64.lds.S
@@ -140,7 +140,7 @@ SECTIONS
.bss : C_PHYS(.bss) {
__init_end = .;
__bss_start = .; /* BSS */
- *(.bss.page_aligned)
+ PAGE_ALIGNED_BSS
*(.bss)
*(COMMON)
. = ALIGN(4);
--
1.6.2.1

2009-04-28 17:06:44

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 05/15] x86: Use macros for .bss.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: H. Peter Anvin <[email protected]>
---
arch/x86/kernel/head_32.S | 2 +-
arch/x86/kernel/head_64.S | 2 +-
arch/x86/kernel/vmlinux_32.lds.S | 2 +-
arch/x86/kernel/vmlinux_64.lds.S | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 3068388..8f2a18b 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -618,7 +618,7 @@ ENTRY(_stext)
/*
* BSS section
*/
-.section ".bss.page_aligned","wa"
+__PAGE_ALIGNED_BSS
.align PAGE_SIZE_asm
#ifdef CONFIG_X86_PAE
swapper_pg_pmd:
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 54b29bb..ae9a453 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -419,7 +419,7 @@ ENTRY(phys_base)
ENTRY(idt_table)
.skip IDT_ENTRIES * 16

- .section .bss.page_aligned, "aw", @nobits
+ __PAGE_ALIGNED_BSS
.align PAGE_SIZE
ENTRY(empty_zero_page)
.skip PAGE_SIZE
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S
index 62ad500..db882aa 100644
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -185,7 +185,7 @@ SECTIONS
.bss : AT(ADDR(.bss) - LOAD_OFFSET) {
__init_end = .;
__bss_start = .; /* BSS */
- *(.bss.page_aligned)
+ PAGE_ALIGNED_BSS
*(.bss)
. = ALIGN(4);
__bss_stop = .;
diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S
index 6d5a5b0..424fb87 100644
--- a/arch/x86/kernel/vmlinux_64.lds.S
+++ b/arch/x86/kernel/vmlinux_64.lds.S
@@ -283,7 +283,7 @@ SECTIONS
.bss : AT(ADDR(.bss) - LOAD_OFFSET) {
. = ALIGN(PAGE_SIZE);
__bss_start = .; /* BSS */
- *(.bss.page_aligned)
+ PAGE_ALIGNED_BSS
*(.bss)
__bss_stop = .;
}
--
1.6.2.1

2009-04-28 17:07:42

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 04/15] xtensa: Use macros for .bss.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Chris Zankel <[email protected]>
---
arch/xtensa/kernel/head.S | 2 +-
arch/xtensa/kernel/vmlinux.lds.S | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S
index d9ddc1b..d215adc 100644
--- a/arch/xtensa/kernel/head.S
+++ b/arch/xtensa/kernel/head.S
@@ -235,7 +235,7 @@ should_never_return:
* BSS section
*/

-.section ".bss.page_aligned", "w"
+__PAGE_ALIGNED_BSS
#ifdef CONFIG_MMU
ENTRY(swapper_pg_dir)
.fill PAGE_SIZE, 1, 0
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index 5accf51..f96f354 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -262,7 +262,7 @@ SECTIONS

/* BSS section */
_bss_start = .;
- .bss : { *(.bss.page_aligned) *(.bss) }
+ .bss : { PAGE_ALIGNED_BSS *(.bss) }
_bss_end = .;

_end = .;
--
1.6.2.1

2009-04-28 17:08:40

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 07/15] avr32: Use standard macros for .data.page_aligned section.

Signed-off-by: Tim Abbott <[email protected]>
Acked-by: Haavard Skinnemoen <[email protected]>
---
arch/avr32/kernel/vmlinux.lds.S | 3 +--
arch/avr32/mm/init.c | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
index 7910d41..36d676f 100644
--- a/arch/avr32/kernel/vmlinux.lds.S
+++ b/arch/avr32/kernel/vmlinux.lds.S
@@ -98,8 +98,7 @@ SECTIONS
*(.data.init_task)

/* Then, the page-aligned data */
- . = ALIGN(PAGE_SIZE);
- *(.data.page_aligned)
+ PAGE_ALIGNED_DATA

/* Then, the cacheline aligned data */
. = ALIGN(L1_CACHE_BYTES);
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index e819fa6..cc60d10 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -24,11 +24,9 @@
#include <asm/setup.h>
#include <asm/sections.h>

-#define __page_aligned __attribute__((section(".data.page_aligned")))
-
DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);

-pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned;
+pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_data;

struct page *empty_zero_page;
EXPORT_SYMBOL(empty_zero_page);
--
1.6.2.1

2009-04-28 17:08:12

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 12/15] powerpc: Use macros for .data.page_aligned section.

.data.page_aligned should not need a separate output section, so as
part of this cleanup I moved into the .data output section in the
linker scripts in order to eliminate unnecessary references to the
section name.

Note that this change moves the page-aligned data inside _edata.
Since it _is_ data, I suspect having page-aligned data outside _edata
was a bug. Please comment if it is not.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vdso.c | 2 +-
arch/powerpc/kernel/vdso32/vdso32_wrapper.S | 3 ++-
arch/powerpc/kernel/vdso64/vdso64_wrapper.S | 3 ++-
arch/powerpc/kernel/vmlinux.lds.S | 6 +-----
4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index ad06d5c..841910a 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -74,7 +74,7 @@ static int vdso_ready;
static union {
struct vdso_data data;
u8 page[PAGE_SIZE];
-} vdso_data_store __attribute__((__section__(".data.page_aligned")));
+} vdso_data_store __page_aligned_data
struct vdso_data *vdso_data = &vdso_data_store.data;

/* Format of the patch table */
diff --git a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
index 556f0ca..6e8f507 100644
--- a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
+++ b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
@@ -1,7 +1,8 @@
#include <linux/init.h>
+#include <linux/linkage.h>
#include <asm/page.h>

- .section ".data.page_aligned"
+ __PAGE_ALIGNED_DATA

.globl vdso32_start, vdso32_end
.balign PAGE_SIZE
diff --git a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
index 0529cb9..b8553d6 100644
--- a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
+++ b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
@@ -1,7 +1,8 @@
#include <linux/init.h>
+#include <linux/linkage.h>
#include <asm/page.h>

- .section ".data.page_aligned"
+ __PAGE_ALIGNED_DATA

.globl vdso64_start, vdso64_end
.balign PAGE_SIZE
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 47899b0..d3dcea0 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -221,6 +221,7 @@ SECTIONS
_sdata = .;

.data : AT(ADDR(.data) - LOAD_OFFSET) {
+ PAGE_ALIGNED_DATA
DATA_DATA
#ifdef CONFIG_PPC32
*(.sdata)
@@ -258,11 +259,6 @@ SECTIONS
*(.data.init_task)
}

- . = ALIGN(PAGE_SIZE);
- .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
- *(.data.page_aligned)
- }
-
.data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
*(.data.cacheline_aligned)
}
--
1.6.2.1

2009-04-28 17:09:26

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 10/15] powerpc: Remove unused __page_aligned macro.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/include/asm/page_64.h | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index 043bfdf..20f9c74 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -152,14 +152,6 @@ do { \

#endif /* !CONFIG_HUGETLB_PAGE */

-#ifdef MODULE
-#define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
-#else
-#define __page_aligned \
- __attribute__((__aligned__(PAGE_SIZE), \
- __section__(".data.page_aligned")))
-#endif
-
#define VM_DATA_DEFAULT_FLAGS \
(test_thread_flag(TIF_32BIT) ? \
VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
--
1.6.2.1

2009-04-28 17:10:15

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 15/15] x86: Use macros for .data.page_aligned.

.data.page_aligned should not need a separate output section. So, as
part of this cleanup I moved it into the .data output section in the
linker scripts in order to eliminate unnecessary references to the
section name.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Ingo Molnar <[email protected]>
---
arch/x86/kernel/head_32.S | 2 +-
arch/x86/kernel/vmlinux_32.lds.S | 6 +-----
arch/x86/kernel/vmlinux_64.lds.S | 6 +-----
3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 8f2a18b..f2a44f3 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -636,7 +636,7 @@ ENTRY(empty_zero_page)
* This starts the data section.
*/
#ifdef CONFIG_X86_PAE
-.section ".data.page_aligned","wa"
+__PAGE_ALIGNED_DATA
/* Page-aligned for the benefit of paravirt? */
.align PAGE_SIZE_asm
ENTRY(swapper_pg_dir)
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S
index fdb0642..57cbcf2 100644
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -64,6 +64,7 @@ SECTIONS
/* writeable */
. = ALIGN(PAGE_SIZE);
.data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
+ PAGE_ALIGNED_DATA
DATA_DATA
CONSTRUCTORS
} :data
@@ -76,11 +77,6 @@ SECTIONS
__nosave_end = .;
}

- . = ALIGN(PAGE_SIZE);
- .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
- *(.data.page_aligned)
- }
-
. = ALIGN(32);
.data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
*(.data.cacheline_aligned)
diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S
index 424fb87..5b74dc9 100644
--- a/arch/x86/kernel/vmlinux_64.lds.S
+++ b/arch/x86/kernel/vmlinux_64.lds.S
@@ -64,6 +64,7 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
/* Data */
.data : AT(ADDR(.data) - LOAD_OFFSET) {
+ PAGE_ALIGNED_DATA
DATA_DATA
CONSTRUCTORS
/* End of data section */
@@ -157,11 +158,6 @@ SECTIONS
*(.data.init_task)
} :data.init

- .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
- . = ALIGN(PAGE_SIZE);
- *(.data.page_aligned)
- }
-
.smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
/* might get freed after init */
. = ALIGN(PAGE_SIZE);
--
1.6.2.1

2009-04-28 17:09:46

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 14/15] x86: Use section .data.page_aligned for the idt_table.

The .data.idt section is just squashed into the .data.page_aligned
output section by the linker script anyway, so it might as well be in
the .data.page_aligned section.

This eliminates all references to .data.idt on x86.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Ingo Molnar <[email protected]>
---
arch/x86/kernel/traps.c | 6 ++----
arch/x86/kernel/vmlinux_32.lds.S | 1 -
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a1d2883..d7affb7 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -73,11 +73,9 @@ char ignore_fpu_irq;

/*
* The IDT has to be page-aligned to simplify the Pentium
- * F0 0F bug workaround.. We have a special link segment
- * for this.
+ * F0 0F bug workaround.
*/
-gate_desc idt_table[256]
- __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
+gate_desc idt_table[256] __page_aligned_data = { { { { 0, 0 } } }, };
#endif

DECLARE_BITMAP(used_vectors, NR_VECTORS);
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S
index db882aa..fdb0642 100644
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -79,7 +79,6 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
.data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
*(.data.page_aligned)
- *(.data.idt)
}

. = ALIGN(32);
--
1.6.2.1

2009-04-28 19:49:31

by Tim Abbott

[permalink] [raw]
Subject: Re: [PATCH v2 00/15] clean up page aligned data and bss sections

On Tue, 28 Apr 2009, Tim Abbott wrote:

> Here's a new version of the page-aligned section cleanup patch
> series. Changes since last version include:

Sam,

I am close to having prepared another 4 patch series of similar size to
this one for .data.nosave, .data.cacheline_aligned, .data.init_task, and
.data.read_mostly. Along with this page-aligned series and the things
that have already been merged, I think these are all of the major
cross-architecture patchsets needed for -ffunction-sections (there will
remain a good number of section names that only appear on one or two
architectures).

It seems with this set of patches that we're going to bother all the arch
maintainers several times if we handle these all completely independently
(especially since each patch series has patches that depend on patches
from the previous one). So, I was thinking perhaps we should proceed as
follows:

(1) I send a patch series that does the architecture-independent macro
additions as well as the changes for one architecture (say, x86) to use
those macros so that they can be reviewed along with the actual usage.

(2) We get those reviewed and merge at least the architecture-independent
patches

(3) I can send one patch series for each architecture that is just using
the macros that have already been merged; then the patch series are nicely
decoupled and each arch maintainer only has to ack a single set of changes
to their architecture.

Does this plan make sense?

-Tim Abbott

2009-04-28 21:28:35

by David Howells

[permalink] [raw]
Subject: Re: [PATCH v2 01/15] Add new macros for page-aligned data and bss sections.

Tim Abbott <[email protected]> wrote:

> This patch is preparation for replacing most uses of
> ".bss.page_aligned" and ".data.page_aligned" in the kernel with
> macros, so that the section name can later be changed without having
> to touch a lot of the kernel.
>
> The long-term goal here is to be able to change the kernel's magic
> section names to those that are compatible with -ffunction-sections
> -fdata-sections. This requires renaming all magic sections with names
> of the form ".data.foo".
>
> Signed-off-by: Tim Abbott <[email protected]>
> Cc: Sam Ravnborg <[email protected]>

Acked-by: David Howells <[email protected]>

2009-04-28 21:28:49

by David Howells

[permalink] [raw]
Subject: Re: [PATCH v2 03/15] mn10300: Use macros for .bss.page_aligned section.

Tim Abbott <[email protected]> wrote:

> Signed-off-by: Tim Abbott <[email protected]>
> Cc: David Howells <[email protected]>

Acked-by: David Howells <[email protected]>

2009-04-28 21:29:11

by David Howells

[permalink] [raw]
Subject: Re: [PATCH v2 13/15] mn10300: Drop unused .data.idt section.

Tim Abbott <[email protected]> wrote:

> 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.
>
> Signed-off-by: Tim Abbott <[email protected]>
> Cc: David Howells <[email protected]>
> Acked-by: Cyrill Gorcunov <[email protected]>
> Cc: Sam Ravnborg <[email protected]>

Acked-by: David Howells <[email protected]>

2009-04-28 22:52:28

by Paul Mackerras

[permalink] [raw]
Subject: Re: [PATCH v2 12/15] powerpc: Use macros for .data.page_aligned section.

Tim Abbott writes:

> diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
> index ad06d5c..841910a 100644
> --- a/arch/powerpc/kernel/vdso.c
> +++ b/arch/powerpc/kernel/vdso.c
> @@ -74,7 +74,7 @@ static int vdso_ready;
> static union {
> struct vdso_data data;
> u8 page[PAGE_SIZE];
> -} vdso_data_store __attribute__((__section__(".data.page_aligned")));
> +} vdso_data_store __page_aligned_data
^
Surely we need a semicolon here? -------|

Paul.

2009-04-29 20:48:52

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH v2 00/15] clean up page aligned data and bss sections

On Tue, Apr 28, 2009 at 03:48:24PM -0400, Tim Abbott wrote:
> On Tue, 28 Apr 2009, Tim Abbott wrote:
>
> > Here's a new version of the page-aligned section cleanup patch
> > series. Changes since last version include:
>
> Sam,
>
> I am close to having prepared another 4 patch series of similar size to
> this one for .data.nosave, .data.cacheline_aligned, .data.init_task, and
> .data.read_mostly. Along with this page-aligned series and the things
> that have already been merged, I think these are all of the major
> cross-architecture patchsets needed for -ffunction-sections (there will
> remain a good number of section names that only appear on one or two
> architectures).
>
> It seems with this set of patches that we're going to bother all the arch
> maintainers several times if we handle these all completely independently
> (especially since each patch series has patches that depend on patches
> from the previous one). So, I was thinking perhaps we should proceed as
> follows:
>
> (1) I send a patch series that does the architecture-independent macro
> additions as well as the changes for one architecture (say, x86) to use
> those macros so that they can be reviewed along with the actual usage.
>
> (2) We get those reviewed and merge at least the architecture-independent
> patches
>
> (3) I can send one patch series for each architecture that is just using
> the macros that have already been merged; then the patch series are nicely
> decoupled and each arch maintainer only has to ack a single set of changes
> to their architecture.

Yes - lets get the support stuff applied first and work out from there.
I plan to apply your patches to kbuild-next during the weekend so
we have them in a tree that hits -next.

Sam