* [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: Nicholas Piggin, linux-arch, linux-kbuild, Christophe Leroy,
Nicolas Pitre
A few people have been interested in this again. And I promised
if it remains dead code it should be removed, so I would like to
have another try.
I think I got snagged on the modules problem last time and did
not take the time to work it out, this time I just turned off the
compile options for modules (the linker option was never set anyway
so no loss).
This includes some linker script catches and ideas from others, I
didn't documnt them all, but thanks for looking.
I would be interested to help other archs get this working too, if
anybody needs some help.
Thanks,
Nick
Nicholas Piggin (4):
kbuild: Fix asm-generic/vmlinux.lds.h for
LD_DEAD_CODE_DATA_ELIMINATION
kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
-ffunction-sections/-fdata-sections for module build
kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
enabled
powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
Makefile | 4 +--
arch/Kconfig | 15 ----------
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
init/Kconfig | 27 +++++++++++++++++
6 files changed, 70 insertions(+), 48 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 45+ messages in thread
* [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, Nicholas Piggin, linux-kbuild
A few people have been interested in this again. And I promised
if it remains dead code it should be removed, so I would like to
have another try.
I think I got snagged on the modules problem last time and did
not take the time to work it out, this time I just turned off the
compile options for modules (the linker option was never set anyway
so no loss).
This includes some linker script catches and ideas from others, I
didn't documnt them all, but thanks for looking.
I would be interested to help other archs get this working too, if
anybody needs some help.
Thanks,
Nick
Nicholas Piggin (4):
kbuild: Fix asm-generic/vmlinux.lds.h for
LD_DEAD_CODE_DATA_ELIMINATION
kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
-ffunction-sections/-fdata-sections for module build
kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
enabled
powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
Makefile | 4 +--
arch/Kconfig | 15 ----------
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
init/Kconfig | 27 +++++++++++++++++
6 files changed, 70 insertions(+), 48 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 45+ messages in thread
* [PATCH 1/4] kbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 7:34 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: Nicholas Piggin, linux-arch, linux-kbuild, Christophe Leroy,
Nicolas Pitre
KEEP more tables, and add the function/data section wildcard to more
section selections.
This is a little ad-hoc at the moment, but kernel code should be moved
to consistently use .text..x (note: double dots) for explicit sections
and all references to it in the linker script can be made with
TEXT_MAIN, and similarly for other sections.
For now, let's see if major architectures move to enabling this option
then we can do some refactoring passes. Otherwise if it remains unused
or superseded by LTO, this may not be required.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 278841c75b97..23f5f8d22f56 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -64,15 +64,24 @@
* generates .data.identifier sections, which need to be pulled in with
* .data. We don't want to pull in .data..other sections, which Linux
* has defined. Same for text and bss.
+ *
+ * RODATA_MAIN is not used because existing code already defines .rodata.x
+ * sections to be brought in with rodata.
*/
#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
+#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
#else
#define TEXT_MAIN .text
#define DATA_MAIN .data
+#define SDATA_MAIN .sdata
+#define RODATA_MAIN .rodata
#define BSS_MAIN .bss
+#define SBSS_MAIN .sbss
#endif
/*
@@ -105,7 +114,7 @@
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
#define MCOUNT_REC() . = ALIGN(8); \
VMLINUX_SYMBOL(__start_mcount_loc) = .; \
- *(__mcount_loc) \
+ KEEP(*(__mcount_loc)) \
VMLINUX_SYMBOL(__stop_mcount_loc) = .;
#else
#define MCOUNT_REC()
@@ -113,7 +122,7 @@
#ifdef CONFIG_TRACE_BRANCH_PROFILING
#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
- *(_ftrace_annotated_branch) \
+ KEEP(*(_ftrace_annotated_branch)) \
VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
#else
#define LIKELY_PROFILE()
@@ -121,7 +130,7 @@
#ifdef CONFIG_PROFILE_ALL_BRANCHES
#define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
- *(_ftrace_branch) \
+ KEEP(*(_ftrace_branch)) \
VMLINUX_SYMBOL(__stop_branch_profile) = .;
#else
#define BRANCH_PROFILE()
@@ -238,8 +247,8 @@
*(DATA_MAIN) \
*(.ref.data) \
*(.data..shared_aligned) /* percpu related */ \
- MEM_KEEP(init.data) \
- MEM_KEEP(exit.data) \
+ MEM_KEEP(init.data*) \
+ MEM_KEEP(exit.data*) \
*(.data.unlikely) \
VMLINUX_SYMBOL(__start_once) = .; \
*(.data.once) \
@@ -289,8 +298,8 @@
VMLINUX_SYMBOL(__start_init_task) = .; \
VMLINUX_SYMBOL(init_thread_union) = .; \
VMLINUX_SYMBOL(init_stack) = .; \
- *(.data..init_task) \
- *(.data..init_thread_info) \
+ KEEP(*(.data..init_task)) \
+ KEEP(*(.data..init_thread_info)) \
. = VMLINUX_SYMBOL(__start_init_task) + THREAD_SIZE; \
VMLINUX_SYMBOL(__end_init_task) = .;
@@ -487,8 +496,8 @@
*(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \
*(.text..refcount) \
*(.ref.text) \
- MEM_KEEP(init.text) \
- MEM_KEEP(exit.text) \
+ MEM_KEEP(init.text*) \
+ MEM_KEEP(exit.text*) \
/* sched.text is aling to function alignment to secure we have same
@@ -538,7 +547,7 @@
VMLINUX_SYMBOL(__softirqentry_text_end) = .;
/* Section used for early init (in .S files) */
-#define HEAD_TEXT *(.head.text)
+#define HEAD_TEXT KEEP(*(.head.text))
#define HEAD_TEXT_SECTION \
.head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
@@ -579,11 +588,11 @@
/* init and exit section handling */
#define INIT_DATA \
KEEP(*(SORT(___kentry+*))) \
- *(.init.data) \
- MEM_DISCARD(init.data) \
+ *(.init.data init.data.*) \
+ MEM_DISCARD(init.data*) \
KERNEL_CTORS() \
MCOUNT_REC() \
- *(.init.rodata) \
+ *(.init.rodata .init.rodata.*) \
FTRACE_EVENTS() \
TRACE_SYSCALLS() \
KPROBE_BLACKLIST() \
@@ -602,16 +611,16 @@
EARLYCON_TABLE()
#define INIT_TEXT \
- *(.init.text) \
+ *(.init.text .init.text.*) \
*(.text.startup) \
- MEM_DISCARD(init.text)
+ MEM_DISCARD(init.text*)
#define EXIT_DATA \
- *(.exit.data) \
+ *(.exit.data .exit.data.*) \
*(.fini_array) \
*(.dtors) \
- MEM_DISCARD(exit.data) \
- MEM_DISCARD(exit.rodata)
+ MEM_DISCARD(exit.data*) \
+ MEM_DISCARD(exit.rodata*)
#define EXIT_TEXT \
*(.exit.text) \
@@ -629,7 +638,7 @@
. = ALIGN(sbss_align); \
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
*(.dynsbss) \
- *(.sbss) \
+ *(SBSS_MAIN) \
*(.scommon) \
}
@@ -754,7 +763,7 @@
#define NOTES \
.notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start_notes) = .; \
- *(.note.*) \
+ KEEP(*(.note.*)) \
VMLINUX_SYMBOL(__stop_notes) = .; \
}
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 1/4] kbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, Nicholas Piggin, linux-kbuild
KEEP more tables, and add the function/data section wildcard to more
section selections.
This is a little ad-hoc at the moment, but kernel code should be moved
to consistently use .text..x (note: double dots) for explicit sections
and all references to it in the linker script can be made with
TEXT_MAIN, and similarly for other sections.
For now, let's see if major architectures move to enabling this option
then we can do some refactoring passes. Otherwise if it remains unused
or superseded by LTO, this may not be required.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 278841c75b97..23f5f8d22f56 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -64,15 +64,24 @@
* generates .data.identifier sections, which need to be pulled in with
* .data. We don't want to pull in .data..other sections, which Linux
* has defined. Same for text and bss.
+ *
+ * RODATA_MAIN is not used because existing code already defines .rodata.x
+ * sections to be brought in with rodata.
*/
#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
+#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
#else
#define TEXT_MAIN .text
#define DATA_MAIN .data
+#define SDATA_MAIN .sdata
+#define RODATA_MAIN .rodata
#define BSS_MAIN .bss
+#define SBSS_MAIN .sbss
#endif
/*
@@ -105,7 +114,7 @@
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
#define MCOUNT_REC() . = ALIGN(8); \
VMLINUX_SYMBOL(__start_mcount_loc) = .; \
- *(__mcount_loc) \
+ KEEP(*(__mcount_loc)) \
VMLINUX_SYMBOL(__stop_mcount_loc) = .;
#else
#define MCOUNT_REC()
@@ -113,7 +122,7 @@
#ifdef CONFIG_TRACE_BRANCH_PROFILING
#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
- *(_ftrace_annotated_branch) \
+ KEEP(*(_ftrace_annotated_branch)) \
VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
#else
#define LIKELY_PROFILE()
@@ -121,7 +130,7 @@
#ifdef CONFIG_PROFILE_ALL_BRANCHES
#define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
- *(_ftrace_branch) \
+ KEEP(*(_ftrace_branch)) \
VMLINUX_SYMBOL(__stop_branch_profile) = .;
#else
#define BRANCH_PROFILE()
@@ -238,8 +247,8 @@
*(DATA_MAIN) \
*(.ref.data) \
*(.data..shared_aligned) /* percpu related */ \
- MEM_KEEP(init.data) \
- MEM_KEEP(exit.data) \
+ MEM_KEEP(init.data*) \
+ MEM_KEEP(exit.data*) \
*(.data.unlikely) \
VMLINUX_SYMBOL(__start_once) = .; \
*(.data.once) \
@@ -289,8 +298,8 @@
VMLINUX_SYMBOL(__start_init_task) = .; \
VMLINUX_SYMBOL(init_thread_union) = .; \
VMLINUX_SYMBOL(init_stack) = .; \
- *(.data..init_task) \
- *(.data..init_thread_info) \
+ KEEP(*(.data..init_task)) \
+ KEEP(*(.data..init_thread_info)) \
. = VMLINUX_SYMBOL(__start_init_task) + THREAD_SIZE; \
VMLINUX_SYMBOL(__end_init_task) = .;
@@ -487,8 +496,8 @@
*(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \
*(.text..refcount) \
*(.ref.text) \
- MEM_KEEP(init.text) \
- MEM_KEEP(exit.text) \
+ MEM_KEEP(init.text*) \
+ MEM_KEEP(exit.text*) \
/* sched.text is aling to function alignment to secure we have same
@@ -538,7 +547,7 @@
VMLINUX_SYMBOL(__softirqentry_text_end) = .;
/* Section used for early init (in .S files) */
-#define HEAD_TEXT *(.head.text)
+#define HEAD_TEXT KEEP(*(.head.text))
#define HEAD_TEXT_SECTION \
.head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
@@ -579,11 +588,11 @@
/* init and exit section handling */
#define INIT_DATA \
KEEP(*(SORT(___kentry+*))) \
- *(.init.data) \
- MEM_DISCARD(init.data) \
+ *(.init.data init.data.*) \
+ MEM_DISCARD(init.data*) \
KERNEL_CTORS() \
MCOUNT_REC() \
- *(.init.rodata) \
+ *(.init.rodata .init.rodata.*) \
FTRACE_EVENTS() \
TRACE_SYSCALLS() \
KPROBE_BLACKLIST() \
@@ -602,16 +611,16 @@
EARLYCON_TABLE()
#define INIT_TEXT \
- *(.init.text) \
+ *(.init.text .init.text.*) \
*(.text.startup) \
- MEM_DISCARD(init.text)
+ MEM_DISCARD(init.text*)
#define EXIT_DATA \
- *(.exit.data) \
+ *(.exit.data .exit.data.*) \
*(.fini_array) \
*(.dtors) \
- MEM_DISCARD(exit.data) \
- MEM_DISCARD(exit.rodata)
+ MEM_DISCARD(exit.data*) \
+ MEM_DISCARD(exit.rodata*)
#define EXIT_TEXT \
*(.exit.text) \
@@ -629,7 +638,7 @@
. = ALIGN(sbss_align); \
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
*(.dynsbss) \
- *(.sbss) \
+ *(SBSS_MAIN) \
*(.scommon) \
}
@@ -754,7 +763,7 @@
#define NOTES \
.notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start_notes) = .; \
- *(.note.*) \
+ KEEP(*(.note.*)) \
VMLINUX_SYMBOL(__stop_notes) = .; \
}
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 2/4] kbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for module build
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 7:34 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: Nicholas Piggin, linux-arch, linux-kbuild, Christophe Leroy,
Nicolas Pitre
Modules do not tend to cope with -ffunction-sections, even though they
do not link with -gc-sections. It may be possible for unused symbols to
be trimmed from modules, but in general that would take much more work
in architecture module linker scripts.
For now, enable these only for kernel build.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e811e0c509c5..2ed651403bb4 100644
--- a/Makefile
+++ b/Makefile
@@ -799,8 +799,8 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
endif
ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
-KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,)
-KBUILD_CFLAGS += $(call cc-option,-fdata-sections,)
+KBUILD_CFLAGS_KERNEL += $(call cc-option,-ffunction-sections,)
+KBUILD_CFLAGS_KERNEL += $(call cc-option,-fdata-sections,)
endif
# arch Makefile may override CC so keep this after arch Makefile is included
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 2/4] kbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for module build
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, Nicholas Piggin, linux-kbuild
Modules do not tend to cope with -ffunction-sections, even though they
do not link with -gc-sections. It may be possible for unused symbols to
be trimmed from modules, but in general that would take much more work
in architecture module linker scripts.
For now, enable these only for kernel build.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index e811e0c509c5..2ed651403bb4 100644
--- a/Makefile
+++ b/Makefile
@@ -799,8 +799,8 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
endif
ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
-KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,)
-KBUILD_CFLAGS += $(call cc-option,-fdata-sections,)
+KBUILD_CFLAGS_KERNEL += $(call cc-option,-ffunction-sections,)
+KBUILD_CFLAGS_KERNEL += $(call cc-option,-fdata-sections,)
endif
# arch Makefile may override CC so keep this after arch Makefile is included
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 3/4] kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 7:34 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: Nicholas Piggin, linux-arch, linux-kbuild, Christophe Leroy,
Nicolas Pitre
Architectures that are capable can select
HAVE_LD_DEAD_CODE_DATA_ELIMINATION to enable selection of that
option (as an EXPERT kernel option).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/Kconfig | 15 ---------------
init/Kconfig | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 8e0d665c8d53..3234b73d4626 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -596,21 +596,6 @@ config CC_STACKPROTECTOR_AUTO
endchoice
-config LD_DEAD_CODE_DATA_ELIMINATION
- bool
- help
- Select this if the architecture wants to do dead code and
- data elimination with the linker by compiling with
- -ffunction-sections -fdata-sections and linking with
- --gc-sections.
-
- This requires that the arch annotates or otherwise protects
- its external entry points from being discarded. Linker scripts
- must also merge .text.*, .data.*, and .bss.* correctly into
- output sections. Care must be taken not to pull in unrelated
- sections (e.g., '.text.init'). Typically '.' in section names
- is used to distinguish them from label names / C identifiers.
-
config HAVE_ARCH_WITHIN_STACK_FRAMES
bool
help
diff --git a/init/Kconfig b/init/Kconfig
index f013afc74b11..1706d963766b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1038,6 +1038,33 @@ config CC_OPTIMIZE_FOR_SIZE
endchoice
+config HAVE_LD_DEAD_CODE_DATA_ELIMINATION
+ bool
+ help
+ This requires that the arch annotates or otherwise protects
+ its external entry points from being discarded. Linker scripts
+ must also merge .text.*, .data.*, and .bss.* correctly into
+ output sections. Care must be taken not to pull in unrelated
+ sections (e.g., '.text.init'). Typically '.' in section names
+ is used to distinguish them from label names / C identifiers.
+
+config LD_DEAD_CODE_DATA_ELIMINATION
+ bool "Dead code and data elimination (EXPERIMENTAL)"
+ depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
+ depends on EXPERT
+ help
+ Select this if the architecture wants to do dead code and
+ data elimination with the linker by compiling with
+ -ffunction-sections -fdata-sections, and linking with
+ --gc-sections.
+
+ This can reduce on disk and in-memory size of the kernel
+ code and static data, particularly for small configs and
+ on small systems. This has the possibility of introducing
+ silently broken kernel if the required annotations are not
+ present. This option is not well tested yet, so use at your
+ own risk.
+
config SYSCTL
bool
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 3/4] kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, Nicholas Piggin, linux-kbuild
Architectures that are capable can select
HAVE_LD_DEAD_CODE_DATA_ELIMINATION to enable selection of that
option (as an EXPERT kernel option).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/Kconfig | 15 ---------------
init/Kconfig | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 8e0d665c8d53..3234b73d4626 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -596,21 +596,6 @@ config CC_STACKPROTECTOR_AUTO
endchoice
-config LD_DEAD_CODE_DATA_ELIMINATION
- bool
- help
- Select this if the architecture wants to do dead code and
- data elimination with the linker by compiling with
- -ffunction-sections -fdata-sections and linking with
- --gc-sections.
-
- This requires that the arch annotates or otherwise protects
- its external entry points from being discarded. Linker scripts
- must also merge .text.*, .data.*, and .bss.* correctly into
- output sections. Care must be taken not to pull in unrelated
- sections (e.g., '.text.init'). Typically '.' in section names
- is used to distinguish them from label names / C identifiers.
-
config HAVE_ARCH_WITHIN_STACK_FRAMES
bool
help
diff --git a/init/Kconfig b/init/Kconfig
index f013afc74b11..1706d963766b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1038,6 +1038,33 @@ config CC_OPTIMIZE_FOR_SIZE
endchoice
+config HAVE_LD_DEAD_CODE_DATA_ELIMINATION
+ bool
+ help
+ This requires that the arch annotates or otherwise protects
+ its external entry points from being discarded. Linker scripts
+ must also merge .text.*, .data.*, and .bss.* correctly into
+ output sections. Care must be taken not to pull in unrelated
+ sections (e.g., '.text.init'). Typically '.' in section names
+ is used to distinguish them from label names / C identifiers.
+
+config LD_DEAD_CODE_DATA_ELIMINATION
+ bool "Dead code and data elimination (EXPERIMENTAL)"
+ depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
+ depends on EXPERT
+ help
+ Select this if the architecture wants to do dead code and
+ data elimination with the linker by compiling with
+ -ffunction-sections -fdata-sections, and linking with
+ --gc-sections.
+
+ This can reduce on disk and in-memory size of the kernel
+ code and static data, particularly for small configs and
+ on small systems. This has the possibility of introducing
+ silently broken kernel if the required annotations are not
+ present. This option is not well tested yet, so use at your
+ own risk.
+
config SYSCTL
bool
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 7:34 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev
Cc: Nicholas Piggin, linux-arch, linux-kbuild, Christophe Leroy,
Nicolas Pitre
This requires further changes to linker script to KEEP some tables
and wildcard compiler generated sections into the right place. This
includes pp32 modifications from Christophe Leroy.
When compiling powernv_defconfig with this option:
text data bss dec filename
11827621 4810490 1341080 17979191 vmlinux
11752437 4598858 1338776 17690071 vmlinux.dcde
Resulting kernel is almost 400kB smaller (and still boots).
[ppc32 numbers here]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c32a181a7cbb..ee6dbe2efc8b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -205,6 +205,7 @@ config PPC
select HAVE_KPROBES
select HAVE_KPROBES_ON_FTRACE
select HAVE_KRETPROBES
+ select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index c8af90ff49f0..89381dc959ce 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -89,7 +89,7 @@ SECTIONS
*/
.text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
#ifdef CONFIG_LD_HEAD_STUB_CATCH
- *(.linker_stub_catch);
+ KEEP(*(.linker_stub_catch));
. = . ;
#endif
@@ -98,7 +98,7 @@ SECTIONS
ALIGN_FUNCTION();
#endif
/* careful! __ftr_alt_* sections need to be close to .text */
- *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
+ *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
SCHED_TEXT
CPUIDLE_TEXT
LOCK_TEXT
@@ -170,10 +170,10 @@ SECTIONS
.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
INIT_DATA
__vtop_table_begin = .;
- *(.vtop_fixup);
+ KEEP(*(.vtop_fixup));
__vtop_table_end = .;
__ptov_table_begin = .;
- *(.ptov_fixup);
+ KEEP(*(.ptov_fixup));
__ptov_table_end = .;
}
@@ -194,26 +194,26 @@ SECTIONS
. = ALIGN(8);
__ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
__start___ftr_fixup = .;
- *(__ftr_fixup)
+ KEEP(*(__ftr_fixup))
__stop___ftr_fixup = .;
}
. = ALIGN(8);
__mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
__start___mmu_ftr_fixup = .;
- *(__mmu_ftr_fixup)
+ KEEP(*(__mmu_ftr_fixup))
__stop___mmu_ftr_fixup = .;
}
. = ALIGN(8);
__lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
__start___lwsync_fixup = .;
- *(__lwsync_fixup)
+ KEEP(*(__lwsync_fixup))
__stop___lwsync_fixup = .;
}
#ifdef CONFIG_PPC64
. = ALIGN(8);
__fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
__start___fw_ftr_fixup = .;
- *(__fw_ftr_fixup)
+ KEEP(*(__fw_ftr_fixup))
__stop___fw_ftr_fixup = .;
}
#endif
@@ -226,7 +226,7 @@ SECTIONS
. = ALIGN(8);
.machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
__machine_desc_start = . ;
- *(.machine.desc)
+ KEEP(*(.machine.desc))
__machine_desc_end = . ;
}
#ifdef CONFIG_RELOCATABLE
@@ -274,7 +274,7 @@ SECTIONS
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
*(.data.rel*)
- *(.sdata)
+ *(SDATA_MAIN)
*(.sdata2)
*(.got.plt) *(.got)
*(.plt)
@@ -289,7 +289,7 @@ SECTIONS
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
__start_opd = .;
- *(.opd)
+ KEEP(*(.opd))
__end_opd = .;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 7:34 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 7:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, Nicholas Piggin, linux-kbuild
This requires further changes to linker script to KEEP some tables
and wildcard compiler generated sections into the right place. This
includes pp32 modifications from Christophe Leroy.
When compiling powernv_defconfig with this option:
text data bss dec filename
11827621 4810490 1341080 17979191 vmlinux
11752437 4598858 1338776 17690071 vmlinux.dcde
Resulting kernel is almost 400kB smaller (and still boots).
[ppc32 numbers here]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c32a181a7cbb..ee6dbe2efc8b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -205,6 +205,7 @@ config PPC
select HAVE_KPROBES
select HAVE_KPROBES_ON_FTRACE
select HAVE_KRETPROBES
+ select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index c8af90ff49f0..89381dc959ce 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -89,7 +89,7 @@ SECTIONS
*/
.text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
#ifdef CONFIG_LD_HEAD_STUB_CATCH
- *(.linker_stub_catch);
+ KEEP(*(.linker_stub_catch));
. = . ;
#endif
@@ -98,7 +98,7 @@ SECTIONS
ALIGN_FUNCTION();
#endif
/* careful! __ftr_alt_* sections need to be close to .text */
- *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
+ *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
SCHED_TEXT
CPUIDLE_TEXT
LOCK_TEXT
@@ -170,10 +170,10 @@ SECTIONS
.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
INIT_DATA
__vtop_table_begin = .;
- *(.vtop_fixup);
+ KEEP(*(.vtop_fixup));
__vtop_table_end = .;
__ptov_table_begin = .;
- *(.ptov_fixup);
+ KEEP(*(.ptov_fixup));
__ptov_table_end = .;
}
@@ -194,26 +194,26 @@ SECTIONS
. = ALIGN(8);
__ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
__start___ftr_fixup = .;
- *(__ftr_fixup)
+ KEEP(*(__ftr_fixup))
__stop___ftr_fixup = .;
}
. = ALIGN(8);
__mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
__start___mmu_ftr_fixup = .;
- *(__mmu_ftr_fixup)
+ KEEP(*(__mmu_ftr_fixup))
__stop___mmu_ftr_fixup = .;
}
. = ALIGN(8);
__lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
__start___lwsync_fixup = .;
- *(__lwsync_fixup)
+ KEEP(*(__lwsync_fixup))
__stop___lwsync_fixup = .;
}
#ifdef CONFIG_PPC64
. = ALIGN(8);
__fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
__start___fw_ftr_fixup = .;
- *(__fw_ftr_fixup)
+ KEEP(*(__fw_ftr_fixup))
__stop___fw_ftr_fixup = .;
}
#endif
@@ -226,7 +226,7 @@ SECTIONS
. = ALIGN(8);
.machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
__machine_desc_start = . ;
- *(.machine.desc)
+ KEEP(*(.machine.desc))
__machine_desc_end = . ;
}
#ifdef CONFIG_RELOCATABLE
@@ -274,7 +274,7 @@ SECTIONS
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
*(.data.rel*)
- *(.sdata)
+ *(SDATA_MAIN)
*(.sdata2)
*(.got.plt) *(.got)
*(.plt)
@@ -289,7 +289,7 @@ SECTIONS
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
__start_opd = .;
- *(.opd)
+ KEEP(*(.opd))
__end_opd = .;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 9:59 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 9:59 UTC (permalink / raw)
To: Nicholas Piggin
Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild, Christophe LEROY
On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> A few people have been interested in this again. And I promised
> if it remains dead code it should be removed, so I would like to
> have another try.
>
> I think I got snagged on the modules problem last time and did
> not take the time to work it out, this time I just turned off the
> compile options for modules (the linker option was never set anyway
> so no loss).
>
> This includes some linker script catches and ideas from others, I
> didn't documnt them all, but thanks for looking.
This series works for me. v2 from Christophe was triggering a kernel
panic (call stack mentioned set_pte_at...).
So if needed:
Tested-by: Mathieu Malaterre <malat@debian.org>
Env: Mac Mini G4, with custom config.
> I would be interested to help other archs get this working too, if
> anybody needs some help.
>
> Thanks,
> Nick
>
> Nicholas Piggin (4):
> kbuild: Fix asm-generic/vmlinux.lds.h for
> LD_DEAD_CODE_DATA_ELIMINATION
> kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
> -ffunction-sections/-fdata-sections for module build
> kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
> enabled
> powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
>
> Makefile | 4 +--
> arch/Kconfig | 15 ----------
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
> include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
> init/Kconfig | 27 +++++++++++++++++
> 6 files changed, 70 insertions(+), 48 deletions(-)
>
> --
> 2.17.0
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
@ 2018-04-20 9:59 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 9:59 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> A few people have been interested in this again. And I promised
> if it remains dead code it should be removed, so I would like to
> have another try.
>
> I think I got snagged on the modules problem last time and did
> not take the time to work it out, this time I just turned off the
> compile options for modules (the linker option was never set anyway
> so no loss).
>
> This includes some linker script catches and ideas from others, I
> didn't documnt them all, but thanks for looking.
This series works for me. v2 from Christophe was triggering a kernel
panic (call stack mentioned set_pte_at...).
So if needed:
Tested-by: Mathieu Malaterre <malat@debian.org>
Env: Mac Mini G4, with custom config.
> I would be interested to help other archs get this working too, if
> anybody needs some help.
>
> Thanks,
> Nick
>
> Nicholas Piggin (4):
> kbuild: Fix asm-generic/vmlinux.lds.h for
> LD_DEAD_CODE_DATA_ELIMINATION
> kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
> -ffunction-sections/-fdata-sections for module build
> kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
> enabled
> powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
>
> Makefile | 4 +--
> arch/Kconfig | 15 ----------
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
> include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
> init/Kconfig | 27 +++++++++++++++++
> 6 files changed, 70 insertions(+), 48 deletions(-)
>
> --
> 2.17.0
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 10:00 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 10:00 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
^^^
Do you want somebody else to provide those numbers ?
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
> --
> 2.17.0
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 10:00 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 10:00 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
^^^
Do you want somebody else to provide those numbers ?
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
> --
> 2.17.0
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 10:01 ` Christophe LEROY
-1 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:01 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, linux-kbuild, Nicolas Pitre
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
Christophe
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 10:01 ` Christophe LEROY
0 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:01 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, linux-kbuild
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
Christophe
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 10:02 ` Christophe LEROY
-1 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:02 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, linux-kbuild, Nicolas Pitre
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> A few people have been interested in this again. And I promised
> if it remains dead code it should be removed, so I would like to
> have another try.
>
> I think I got snagged on the modules problem last time and did
> not take the time to work it out, this time I just turned off the
> compile options for modules (the linker option was never set anyway
> so no loss).
>
> This includes some linker script catches and ideas from others, I
> didn't documnt them all, but thanks for looking.
Thanks a lot.
It works well on both my 8xx and 83xx targets. I don't have
CONFIG_MODULE set.
Christophe
>
> I would be interested to help other archs get this working too, if
> anybody needs some help.
>
> Thanks,
> Nick
>
> Nicholas Piggin (4):
> kbuild: Fix asm-generic/vmlinux.lds.h for
> LD_DEAD_CODE_DATA_ELIMINATION
> kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
> -ffunction-sections/-fdata-sections for module build
> kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
> enabled
> powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
>
> Makefile | 4 +--
> arch/Kconfig | 15 ----------
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
> include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
> init/Kconfig | 27 +++++++++++++++++
> 6 files changed, 70 insertions(+), 48 deletions(-)
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc
@ 2018-04-20 10:02 ` Christophe LEROY
0 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:02 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, linux-kbuild
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> A few people have been interested in this again. And I promised
> if it remains dead code it should be removed, so I would like to
> have another try.
>
> I think I got snagged on the modules problem last time and did
> not take the time to work it out, this time I just turned off the
> compile options for modules (the linker option was never set anyway
> so no loss).
>
> This includes some linker script catches and ideas from others, I
> didn't documnt them all, but thanks for looking.
Thanks a lot.
It works well on both my 8xx and 83xx targets. I don't have
CONFIG_MODULE set.
Christophe
>
> I would be interested to help other archs get this working too, if
> anybody needs some help.
>
> Thanks,
> Nick
>
> Nicholas Piggin (4):
> kbuild: Fix asm-generic/vmlinux.lds.h for
> LD_DEAD_CODE_DATA_ELIMINATION
> kbuild: LD_DEAD_CODE_DATA_ELIMINATION no
> -ffunction-sections/-fdata-sections for module build
> kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if
> enabled
> powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
>
> Makefile | 4 +--
> arch/Kconfig | 15 ----------
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++-------
> include/asm-generic/vmlinux.lds.h | 49 ++++++++++++++++++-------------
> init/Kconfig | 27 +++++++++++++++++
> 6 files changed, 70 insertions(+), 48 deletions(-)
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 10:01 ` Christophe LEROY
@ 2018-04-20 10:36 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 10:36 UTC (permalink / raw)
To: Christophe LEROY; +Cc: linuxppc-dev, linux-arch, linux-kbuild, Nicolas Pitre
On Fri, 20 Apr 2018 12:01:34 +0200
Christophe LEROY <christophe.leroy@c-s.fr> wrote:
> Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> > This requires further changes to linker script to KEEP some tables
> > and wildcard compiler generated sections into the right place. This
> > includes pp32 modifications from Christophe Leroy.
> >
> > When compiling powernv_defconfig with this option:
> >
> > text data bss dec filename
> > 11827621 4810490 1341080 17979191 vmlinux
> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >
> > Resulting kernel is almost 400kB smaller (and still boots).
> >
> > [ppc32 numbers here]
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> > arch/powerpc/Kconfig | 1 +
> > arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> > 2 files changed, 12 insertions(+), 11 deletions(-)
> >
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index c32a181a7cbb..ee6dbe2efc8b 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -205,6 +205,7 @@ config PPC
> > select HAVE_KPROBES
> > select HAVE_KPROBES_ON_FTRACE
> > select HAVE_KRETPROBES
> > + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> > select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> > select HAVE_MEMBLOCK
> > select HAVE_MEMBLOCK_NODE_MAP
> > diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> > index c8af90ff49f0..89381dc959ce 100644
> > --- a/arch/powerpc/kernel/vmlinux.lds.S
> > +++ b/arch/powerpc/kernel/vmlinux.lds.S
> > @@ -89,7 +89,7 @@ SECTIONS
> > */
> > .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> > #ifdef CONFIG_LD_HEAD_STUB_CATCH
> > - *(.linker_stub_catch);
> > + KEEP(*(.linker_stub_catch));
> > . = . ;
> > #endif
> >
> > @@ -98,7 +98,7 @@ SECTIONS
> > ALIGN_FUNCTION();
> > #endif
> > /* careful! __ftr_alt_* sections need to be close to .text */
> > - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> > + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>
> Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
It's from my early patch before we added those in the generic linker
script. Yes your version looks nicer.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 10:36 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 10:36 UTC (permalink / raw)
To: Christophe LEROY; +Cc: linux-arch, Nicolas Pitre, linuxppc-dev, linux-kbuild
On Fri, 20 Apr 2018 12:01:34 +0200
Christophe LEROY <christophe.leroy@c-s.fr> wrote:
> Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> > This requires further changes to linker script to KEEP some tables
> > and wildcard compiler generated sections into the right place. This
> > includes pp32 modifications from Christophe Leroy.
> >
> > When compiling powernv_defconfig with this option:
> >
> > text data bss dec filename
> > 11827621 4810490 1341080 17979191 vmlinux
> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >
> > Resulting kernel is almost 400kB smaller (and still boots).
> >
> > [ppc32 numbers here]
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> > arch/powerpc/Kconfig | 1 +
> > arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> > 2 files changed, 12 insertions(+), 11 deletions(-)
> >
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index c32a181a7cbb..ee6dbe2efc8b 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -205,6 +205,7 @@ config PPC
> > select HAVE_KPROBES
> > select HAVE_KPROBES_ON_FTRACE
> > select HAVE_KRETPROBES
> > + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> > select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> > select HAVE_MEMBLOCK
> > select HAVE_MEMBLOCK_NODE_MAP
> > diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> > index c8af90ff49f0..89381dc959ce 100644
> > --- a/arch/powerpc/kernel/vmlinux.lds.S
> > +++ b/arch/powerpc/kernel/vmlinux.lds.S
> > @@ -89,7 +89,7 @@ SECTIONS
> > */
> > .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> > #ifdef CONFIG_LD_HEAD_STUB_CATCH
> > - *(.linker_stub_catch);
> > + KEEP(*(.linker_stub_catch));
> > . = . ;
> > #endif
> >
> > @@ -98,7 +98,7 @@ SECTIONS
> > ALIGN_FUNCTION();
> > #endif
> > /* careful! __ftr_alt_* sections need to be close to .text */
> > - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> > + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>
> Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
It's from my early patch before we added those in the generic linker
script. Yes your version looks nicer.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 7:34 ` Nicholas Piggin
@ 2018-04-20 10:39 ` Christophe LEROY
-1 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:39 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, linux-kbuild, Nicolas Pitre
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Tested on MPC885 and MPC8321E, CONFIG_MODULE unset.
Christophe
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 10:39 ` Christophe LEROY
0 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 10:39 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: linux-arch, Nicolas Pitre, linux-kbuild
Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
> This requires further changes to linker script to KEEP some tables
> and wildcard compiler generated sections into the right place. This
> includes pp32 modifications from Christophe Leroy.
>
> When compiling powernv_defconfig with this option:
>
> text data bss dec filename
> 11827621 4810490 1341080 17979191 vmlinux
> 11752437 4598858 1338776 17690071 vmlinux.dcde
>
> Resulting kernel is almost 400kB smaller (and still boots).
>
> [ppc32 numbers here]
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Tested on MPC885 and MPC8321E, CONFIG_MODULE unset.
Christophe
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
> 2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index c32a181a7cbb..ee6dbe2efc8b 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -205,6 +205,7 @@ config PPC
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> select HAVE_KRETPROBES
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index c8af90ff49f0..89381dc959ce 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -89,7 +89,7 @@ SECTIONS
> */
> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
> #ifdef CONFIG_LD_HEAD_STUB_CATCH
> - *(.linker_stub_catch);
> + KEEP(*(.linker_stub_catch));
> . = . ;
> #endif
>
> @@ -98,7 +98,7 @@ SECTIONS
> ALIGN_FUNCTION();
> #endif
> /* careful! __ftr_alt_* sections need to be close to .text */
> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
> SCHED_TEXT
> CPUIDLE_TEXT
> LOCK_TEXT
> @@ -170,10 +170,10 @@ SECTIONS
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
> INIT_DATA
> __vtop_table_begin = .;
> - *(.vtop_fixup);
> + KEEP(*(.vtop_fixup));
> __vtop_table_end = .;
> __ptov_table_begin = .;
> - *(.ptov_fixup);
> + KEEP(*(.ptov_fixup));
> __ptov_table_end = .;
> }
>
> @@ -194,26 +194,26 @@ SECTIONS
> . = ALIGN(8);
> __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
> __start___ftr_fixup = .;
> - *(__ftr_fixup)
> + KEEP(*(__ftr_fixup))
> __stop___ftr_fixup = .;
> }
> . = ALIGN(8);
> __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
> __start___mmu_ftr_fixup = .;
> - *(__mmu_ftr_fixup)
> + KEEP(*(__mmu_ftr_fixup))
> __stop___mmu_ftr_fixup = .;
> }
> . = ALIGN(8);
> __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
> __start___lwsync_fixup = .;
> - *(__lwsync_fixup)
> + KEEP(*(__lwsync_fixup))
> __stop___lwsync_fixup = .;
> }
> #ifdef CONFIG_PPC64
> . = ALIGN(8);
> __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
> __start___fw_ftr_fixup = .;
> - *(__fw_ftr_fixup)
> + KEEP(*(__fw_ftr_fixup))
> __stop___fw_ftr_fixup = .;
> }
> #endif
> @@ -226,7 +226,7 @@ SECTIONS
> . = ALIGN(8);
> .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
> __machine_desc_start = . ;
> - *(.machine.desc)
> + KEEP(*(.machine.desc))
> __machine_desc_end = . ;
> }
> #ifdef CONFIG_RELOCATABLE
> @@ -274,7 +274,7 @@ SECTIONS
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> DATA_DATA
> *(.data.rel*)
> - *(.sdata)
> + *(SDATA_MAIN)
> *(.sdata2)
> *(.got.plt) *(.got)
> *(.plt)
> @@ -289,7 +289,7 @@ SECTIONS
>
> .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
> __start_opd = .;
> - *(.opd)
> + KEEP(*(.opd))
> __end_opd = .;
> }
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 10:00 ` Mathieu Malaterre
@ 2018-04-20 10:41 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 10:41 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Fri, 20 Apr 2018 12:00:49 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > This requires further changes to linker script to KEEP some tables
> > and wildcard compiler generated sections into the right place. This
> > includes pp32 modifications from Christophe Leroy.
> >
> > When compiling powernv_defconfig with this option:
> >
> > text data bss dec filename
> > 11827621 4810490 1341080 17979191 vmlinux
> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >
> > Resulting kernel is almost 400kB smaller (and still boots).
> >
> > [ppc32 numbers here]
>
> ^^^
>
> Do you want somebody else to provide those numbers ?
If you have a booting kernel, yes some more numbers would be good.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 10:41 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-20 10:41 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Fri, 20 Apr 2018 12:00:49 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > This requires further changes to linker script to KEEP some tables
> > and wildcard compiler generated sections into the right place. This
> > includes pp32 modifications from Christophe Leroy.
> >
> > When compiling powernv_defconfig with this option:
> >
> > text data bss dec filename
> > 11827621 4810490 1341080 17979191 vmlinux
> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >
> > Resulting kernel is almost 400kB smaller (and still boots).
> >
> > [ppc32 numbers here]
>
> ^^^
>
> Do you want somebody else to provide those numbers ?
If you have a booting kernel, yes some more numbers would be good.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 10:36 ` Nicholas Piggin
@ 2018-04-20 13:21 ` Christophe LEROY
-1 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 13:21 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, linux-arch, linux-kbuild, Nicolas Pitre
Le 20/04/2018 à 12:36, Nicholas Piggin a écrit :
> On Fri, 20 Apr 2018 12:01:34 +0200
> Christophe LEROY <christophe.leroy@c-s.fr> wrote:
>
>> Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
>>> This requires further changes to linker script to KEEP some tables
>>> and wildcard compiler generated sections into the right place. This
>>> includes pp32 modifications from Christophe Leroy.
>>>
>>> When compiling powernv_defconfig with this option:
>>>
>>> text data bss dec filename
>>> 11827621 4810490 1341080 17979191 vmlinux
>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>
>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>
>>> [ppc32 numbers here]
Here a few results, obtained with readelf -l vmlinux | grep LOAD
First val is filesz, second is memsz, for each config you get the size
before and after activation of LD_DCDE, and the difference between the two.
mpc83xx_defconfig:
Before: 0x5ecfe0 0x60b69c
After: 0x5d2fe0 0x5f04a4
Diff: 0x01a000 0x01b4c8
mpc83xx_defconfig without CONFIG_MODULE:
Before: 0x5c1040 0x5e0614
After: 0x55f040 0x57d314
Diff: 0x062000 0x063300
mpc885_ads_defconfig:
Before: 0x36eda4 0x38da04
After: 0x316da4 0x333764
Diff: 0x058000 0x05a2a0
Custom mpc885 config:
Before: 0x719948 0x78bc34
After: 0x6b9948 0x72a99c
Diff: 0x060000 0x061298
Custom mpc8321 config:
Before: 0x70f714 0x7d766c
After: 0x6af714 0x7763ec
Diff: 0x060000 0x061280
>>>
>>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>> ---
>>> arch/powerpc/Kconfig | 1 +
>>> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
>>> 2 files changed, 12 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>>> index c32a181a7cbb..ee6dbe2efc8b 100644
>>> --- a/arch/powerpc/Kconfig
>>> +++ b/arch/powerpc/Kconfig
>>> @@ -205,6 +205,7 @@ config PPC
>>> select HAVE_KPROBES
>>> select HAVE_KPROBES_ON_FTRACE
>>> select HAVE_KRETPROBES
>>> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
>>> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
>>> select HAVE_MEMBLOCK
>>> select HAVE_MEMBLOCK_NODE_MAP
>>> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
>>> index c8af90ff49f0..89381dc959ce 100644
>>> --- a/arch/powerpc/kernel/vmlinux.lds.S
>>> +++ b/arch/powerpc/kernel/vmlinux.lds.S
>>> @@ -89,7 +89,7 @@ SECTIONS
>>> */
>>> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
>>> #ifdef CONFIG_LD_HEAD_STUB_CATCH
>>> - *(.linker_stub_catch);
>>> + KEEP(*(.linker_stub_catch));
>>> . = . ;
>>> #endif
>>>
>>> @@ -98,7 +98,7 @@ SECTIONS
>>> ALIGN_FUNCTION();
>>> #endif
>>> /* careful! __ftr_alt_* sections need to be close to .text */
>>> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>>> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>>
>> Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
>
> It's from my early patch before we added those in the generic linker
> script. Yes your version looks nicer.
>
> Thanks,
> Nick
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 13:21 ` Christophe LEROY
0 siblings, 0 replies; 45+ messages in thread
From: Christophe LEROY @ 2018-04-20 13:21 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, Nicolas Pitre, linuxppc-dev, linux-kbuild
Le 20/04/2018 à 12:36, Nicholas Piggin a écrit :
> On Fri, 20 Apr 2018 12:01:34 +0200
> Christophe LEROY <christophe.leroy@c-s.fr> wrote:
>
>> Le 20/04/2018 à 09:34, Nicholas Piggin a écrit :
>>> This requires further changes to linker script to KEEP some tables
>>> and wildcard compiler generated sections into the right place. This
>>> includes pp32 modifications from Christophe Leroy.
>>>
>>> When compiling powernv_defconfig with this option:
>>>
>>> text data bss dec filename
>>> 11827621 4810490 1341080 17979191 vmlinux
>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>
>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>
>>> [ppc32 numbers here]
Here a few results, obtained with readelf -l vmlinux | grep LOAD
First val is filesz, second is memsz, for each config you get the size
before and after activation of LD_DCDE, and the difference between the two.
mpc83xx_defconfig:
Before: 0x5ecfe0 0x60b69c
After: 0x5d2fe0 0x5f04a4
Diff: 0x01a000 0x01b4c8
mpc83xx_defconfig without CONFIG_MODULE:
Before: 0x5c1040 0x5e0614
After: 0x55f040 0x57d314
Diff: 0x062000 0x063300
mpc885_ads_defconfig:
Before: 0x36eda4 0x38da04
After: 0x316da4 0x333764
Diff: 0x058000 0x05a2a0
Custom mpc885 config:
Before: 0x719948 0x78bc34
After: 0x6b9948 0x72a99c
Diff: 0x060000 0x061298
Custom mpc8321 config:
Before: 0x70f714 0x7d766c
After: 0x6af714 0x7763ec
Diff: 0x060000 0x061280
>>>
>>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>> ---
>>> arch/powerpc/Kconfig | 1 +
>>> arch/powerpc/kernel/vmlinux.lds.S | 22 +++++++++++-----------
>>> 2 files changed, 12 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>>> index c32a181a7cbb..ee6dbe2efc8b 100644
>>> --- a/arch/powerpc/Kconfig
>>> +++ b/arch/powerpc/Kconfig
>>> @@ -205,6 +205,7 @@ config PPC
>>> select HAVE_KPROBES
>>> select HAVE_KPROBES_ON_FTRACE
>>> select HAVE_KRETPROBES
>>> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
>>> select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
>>> select HAVE_MEMBLOCK
>>> select HAVE_MEMBLOCK_NODE_MAP
>>> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
>>> index c8af90ff49f0..89381dc959ce 100644
>>> --- a/arch/powerpc/kernel/vmlinux.lds.S
>>> +++ b/arch/powerpc/kernel/vmlinux.lds.S
>>> @@ -89,7 +89,7 @@ SECTIONS
>>> */
>>> .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
>>> #ifdef CONFIG_LD_HEAD_STUB_CATCH
>>> - *(.linker_stub_catch);
>>> + KEEP(*(.linker_stub_catch));
>>> . = . ;
>>> #endif
>>>
>>> @@ -98,7 +98,7 @@ SECTIONS
>>> ALIGN_FUNCTION();
>>> #endif
>>> /* careful! __ftr_alt_* sections need to be close to .text */
>>> - *(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>>> + *(.text.hot .text .text.[0-9a-zA-Z_]* .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
>>
>> Why not use TEXT_MAIN here instead of .text .text.[0-9a-zA-Z_]* ?
>
> It's from my early patch before we added those in the generic linker
> script. Yes your version looks nicer.
>
> Thanks,
> Nick
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 10:41 ` Nicholas Piggin
@ 2018-04-20 20:08 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 20:08 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Fri, 20 Apr 2018 12:00:49 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > This requires further changes to linker script to KEEP some tables
>> > and wildcard compiler generated sections into the right place. This
>> > includes pp32 modifications from Christophe Leroy.
>> >
>> > When compiling powernv_defconfig with this option:
>> >
>> > text data bss dec filename
>> > 11827621 4810490 1341080 17979191 vmlinux
>> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >
>> > Resulting kernel is almost 400kB smaller (and still boots).
>> >
>> > [ppc32 numbers here]
>>
>> ^^^
>>
>> Do you want somebody else to provide those numbers ?
>
> If you have a booting kernel, yes some more numbers would be good.
I've used /boot/config-4.15.0-2-powerpc from my current debian
package. Rebuild master with and without option, boot ok, load/unload
module ok.
$ size nick/vmlinux.with*
text data bss dec hex filename
7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
This is not clear why with option the size of kernel is slightly bigger:
$ du -sk nick/vmlinux.with*
124488 nick/vmlinux.with
124004 nick/vmlinux.without
> Thanks,
> Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-20 20:08 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-20 20:08 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Fri, 20 Apr 2018 12:00:49 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > This requires further changes to linker script to KEEP some tables
>> > and wildcard compiler generated sections into the right place. This
>> > includes pp32 modifications from Christophe Leroy.
>> >
>> > When compiling powernv_defconfig with this option:
>> >
>> > text data bss dec filename
>> > 11827621 4810490 1341080 17979191 vmlinux
>> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >
>> > Resulting kernel is almost 400kB smaller (and still boots).
>> >
>> > [ppc32 numbers here]
>>
>> ^^^
>>
>> Do you want somebody else to provide those numbers ?
>
> If you have a booting kernel, yes some more numbers would be good.
I've used /boot/config-4.15.0-2-powerpc from my current debian
package. Rebuild master with and without option, boot ok, load/unload
module ok.
$ size nick/vmlinux.with*
text data bss dec hex filename
7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
This is not clear why with option the size of kernel is slightly bigger:
$ du -sk nick/vmlinux.with*
124488 nick/vmlinux.with
124004 nick/vmlinux.without
> Thanks,
> Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 20:08 ` Mathieu Malaterre
@ 2018-04-21 2:48 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-21 2:48 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Fri, 20 Apr 2018 22:08:27 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > On Fri, 20 Apr 2018 12:00:49 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > This requires further changes to linker script to KEEP some tables
> >> > and wildcard compiler generated sections into the right place. This
> >> > includes pp32 modifications from Christophe Leroy.
> >> >
> >> > When compiling powernv_defconfig with this option:
> >> >
> >> > text data bss dec filename
> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >
> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >
> >> > [ppc32 numbers here]
> >>
> >> ^^^
> >>
> >> Do you want somebody else to provide those numbers ?
> >
> > If you have a booting kernel, yes some more numbers would be good.
>
> I've used /boot/config-4.15.0-2-powerpc from my current debian
> package. Rebuild master with and without option, boot ok, load/unload
> module ok.
>
> $ size nick/vmlinux.with*
> text data bss dec hex filename
> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>
> This is not clear why with option the size of kernel is slightly bigger:
>
> $ du -sk nick/vmlinux.with*
> 124488 nick/vmlinux.with
> 124004 nick/vmlinux.without
Not sure. readelf -S vmlinux may show something.
To really get lots of detail, you can add to the top level Makefile:
LDFLAGS_vmlinux += -M
Then it will print the link map for you and other details. Actually
it will output several times because we link vmlinux 2-3 times, so
just take the last one. There is a lot of data there.
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-21 2:48 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-04-21 2:48 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Fri, 20 Apr 2018 22:08:27 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > On Fri, 20 Apr 2018 12:00:49 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > This requires further changes to linker script to KEEP some tables
> >> > and wildcard compiler generated sections into the right place. This
> >> > includes pp32 modifications from Christophe Leroy.
> >> >
> >> > When compiling powernv_defconfig with this option:
> >> >
> >> > text data bss dec filename
> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >
> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >
> >> > [ppc32 numbers here]
> >>
> >> ^^^
> >>
> >> Do you want somebody else to provide those numbers ?
> >
> > If you have a booting kernel, yes some more numbers would be good.
>
> I've used /boot/config-4.15.0-2-powerpc from my current debian
> package. Rebuild master with and without option, boot ok, load/unload
> module ok.
>
> $ size nick/vmlinux.with*
> text data bss dec hex filename
> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>
> This is not clear why with option the size of kernel is slightly bigger:
>
> $ du -sk nick/vmlinux.with*
> 124488 nick/vmlinux.with
> 124004 nick/vmlinux.without
Not sure. readelf -S vmlinux may show something.
To really get lots of detail, you can add to the top level Makefile:
LDFLAGS_vmlinux += -M
Then it will print the link map for you and other details. Actually
it will output several times because we link vmlinux 2-3 times, so
just take the last one. There is a lot of data there.
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 20:08 ` Mathieu Malaterre
@ 2018-04-21 7:16 ` christophe leroy
-1 siblings, 0 replies; 45+ messages in thread
From: christophe leroy @ 2018-04-21 7:16 UTC (permalink / raw)
To: Mathieu Malaterre, Nicholas Piggin
Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
Le 20/04/2018 à 22:08, Mathieu Malaterre a écrit :
> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> On Fri, 20 Apr 2018 12:00:49 +0200
>> Mathieu Malaterre <malat@debian.org> wrote:
>>
>>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>>>> This requires further changes to linker script to KEEP some tables
>>>> and wildcard compiler generated sections into the right place. This
>>>> includes pp32 modifications from Christophe Leroy.
>>>>
>>>> When compiling powernv_defconfig with this option:
>>>>
>>>> text data bss dec filename
>>>> 11827621 4810490 1341080 17979191 vmlinux
>>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>>
>>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>>
>>>> [ppc32 numbers here]
>>>
>>> ^^^
>>>
>>> Do you want somebody else to provide those numbers ?
>>
>> If you have a booting kernel, yes some more numbers would be good.
>
> I've used /boot/config-4.15.0-2-powerpc from my current debian
> package. Rebuild master with and without option, boot ok, load/unload
> module ok.
>
> $ size nick/vmlinux.with*
> text data bss dec hex filename
> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>
> This is not clear why with option the size of kernel is slightly bigger:
The file contains also debug symbols, which might differ.
Only the LOAD part of the file is interesting, that's the part you get
when doing ppc-linux-objcopy vmlinux vmlinux.bin -O binary
You can see it with readelf -l vmlinux
Christophe
>
> $ du -sk nick/vmlinux.with*
> 124488 nick/vmlinux.with
> 124004 nick/vmlinux.without
>
>
>> Thanks,
>> Nick
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-21 7:16 ` christophe leroy
0 siblings, 0 replies; 45+ messages in thread
From: christophe leroy @ 2018-04-21 7:16 UTC (permalink / raw)
To: Mathieu Malaterre, Nicholas Piggin
Cc: linux-arch, Nicolas Pitre, linuxppc-dev, linux-kbuild
Le 20/04/2018 à 22:08, Mathieu Malaterre a écrit :
> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> On Fri, 20 Apr 2018 12:00:49 +0200
>> Mathieu Malaterre <malat@debian.org> wrote:
>>
>>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>>>> This requires further changes to linker script to KEEP some tables
>>>> and wildcard compiler generated sections into the right place. This
>>>> includes pp32 modifications from Christophe Leroy.
>>>>
>>>> When compiling powernv_defconfig with this option:
>>>>
>>>> text data bss dec filename
>>>> 11827621 4810490 1341080 17979191 vmlinux
>>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>>
>>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>>
>>>> [ppc32 numbers here]
>>>
>>> ^^^
>>>
>>> Do you want somebody else to provide those numbers ?
>>
>> If you have a booting kernel, yes some more numbers would be good.
>
> I've used /boot/config-4.15.0-2-powerpc from my current debian
> package. Rebuild master with and without option, boot ok, load/unload
> module ok.
>
> $ size nick/vmlinux.with*
> text data bss dec hex filename
> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>
> This is not clear why with option the size of kernel is slightly bigger:
The file contains also debug symbols, which might differ.
Only the LOAD part of the file is interesting, that's the part you get
when doing ppc-linux-objcopy vmlinux vmlinux.bin -O binary
You can see it with readelf -l vmlinux
Christophe
>
> $ du -sk nick/vmlinux.with*
> 124488 nick/vmlinux.with
> 124004 nick/vmlinux.without
>
>
>> Thanks,
>> Nick
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-21 7:16 ` christophe leroy
(?)
@ 2018-04-23 11:01 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-23 11:01 UTC (permalink / raw)
To: christophe leroy
Cc: Nicholas Piggin, linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
Christophe,
On Sat, Apr 21, 2018 at 9:16 AM, christophe leroy
<christophe.leroy@c-s.fr> wrote:
>
>
> Le 20/04/2018 à 22:08, Mathieu Malaterre a écrit :
>>
>> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com>
>> wrote:
>>>
>>> On Fri, 20 Apr 2018 12:00:49 +0200
>>> Mathieu Malaterre <malat@debian.org> wrote:
>>>
>>>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com>
>>>> wrote:
>>>>>
>>>>> This requires further changes to linker script to KEEP some tables
>>>>> and wildcard compiler generated sections into the right place. This
>>>>> includes pp32 modifications from Christophe Leroy.
>>>>>
>>>>> When compiling powernv_defconfig with this option:
>>>>>
>>>>> text data bss dec filename
>>>>> 11827621 4810490 1341080 17979191 vmlinux
>>>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>>>
>>>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>>>
>>>>> [ppc32 numbers here]
>>>>
>>>>
>>>> ^^^
>>>>
>>>> Do you want somebody else to provide those numbers ?
>>>
>>>
>>> If you have a booting kernel, yes some more numbers would be good.
>>
>>
>> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> package. Rebuild master with and without option, boot ok, load/unload
>> module ok.
>>
>> $ size nick/vmlinux.with*
>> text data bss dec hex filename
>> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>>
>> This is not clear why with option the size of kernel is slightly bigger:
>
>
> The file contains also debug symbols, which might differ.
> Only the LOAD part of the file is interesting, that's the part you get when
> doing ppc-linux-objcopy vmlinux vmlinux.bin -O binary
>
> You can see it with readelf -l vmlinux
Here is what I see:
$ diff -u <(readelf -l nick/vmlinux.with) <(readelf -l nick/vmlinux.without)
--- /proc/self/fd/11 2018-04-23 12:59:52.413101612 +0200
+++ /proc/self/fd/12 2018-04-23 12:59:52.417101567 +0200
@@ -5,9 +5,9 @@
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
- LOAD 0x010000 0xc0000000 0x00000000 0x950f34 0xaad018 RWE 0x10000
- NOTE 0x867640 0xc0857640 0x00857640 0x00024 0x00024 0x4
- NOTE 0x867664 0xc0857664 0x00857664 0x0000c 0x0000c 0x1
+ LOAD 0x010000 0xc0000000 0x00000000 0x97ef34 0xadba68 RWE 0x10000
+ NOTE 0x87f640 0xc086f640 0x0086f640 0x00024 0x00024 0x4
+ NOTE 0x87f664 0xc086f664 0x0086f664 0x0000c 0x0000c 0x1
Section to Segment mapping:
Segment Sections...
> Christophe
>
>>
>> $ du -sk nick/vmlinux.with*
>> 124488 nick/vmlinux.with
>> 124004 nick/vmlinux.without
>>
>>
>>> Thanks,
>>> Nick
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-23 11:01 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-23 11:01 UTC (permalink / raw)
To: christophe leroy
Cc: linux-arch, Nicolas Pitre, linuxppc-dev, Nicholas Piggin, linux-kbuild
Christophe,
On Sat, Apr 21, 2018 at 9:16 AM, christophe leroy
<christophe.leroy@c-s.fr> wrote:
>
>
> Le 20/04/2018 à 22:08, Mathieu Malaterre a écrit :
>>
>> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com>
>> wrote:
>>>
>>> On Fri, 20 Apr 2018 12:00:49 +0200
>>> Mathieu Malaterre <malat@debian.org> wrote:
>>>
>>>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com>
>>>> wrote:
>>>>>
>>>>> This requires further changes to linker script to KEEP some tables
>>>>> and wildcard compiler generated sections into the right place. This
>>>>> includes pp32 modifications from Christophe Leroy.
>>>>>
>>>>> When compiling powernv_defconfig with this option:
>>>>>
>>>>> text data bss dec filename
>>>>> 11827621 4810490 1341080 17979191 vmlinux
>>>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>>>
>>>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>>>
>>>>> [ppc32 numbers here]
>>>>
>>>>
>>>> ^^^
>>>>
>>>> Do you want somebody else to provide those numbers ?
>>>
>>>
>>> If you have a booting kernel, yes some more numbers would be good.
>>
>>
>> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> package. Rebuild master with and without option, boot ok, load/unload
>> module ok.
>>
>> $ size nick/vmlinux.with*
>> text data bss dec hex filename
>> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>>
>> This is not clear why with option the size of kernel is slightly bigger:
>
>
> The file contains also debug symbols, which might differ.
> Only the LOAD part of the file is interesting, that's the part you get when
> doing ppc-linux-objcopy vmlinux vmlinux.bin -O binary
>
> You can see it with readelf -l vmlinux
Here is what I see:
$ diff -u <(readelf -l nick/vmlinux.with) <(readelf -l nick/vmlinux.without)
--- /proc/self/fd/11 2018-04-23 12:59:52.413101612 +0200
+++ /proc/self/fd/12 2018-04-23 12:59:52.417101567 +0200
@@ -5,9 +5,9 @@
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
- LOAD 0x010000 0xc0000000 0x00000000 0x950f34 0xaad018 RWE 0x10000
- NOTE 0x867640 0xc0857640 0x00857640 0x00024 0x00024 0x4
- NOTE 0x867664 0xc0857664 0x00857664 0x0000c 0x0000c 0x1
+ LOAD 0x010000 0xc0000000 0x00000000 0x97ef34 0xadba68 RWE 0x10000
+ NOTE 0x87f640 0xc086f640 0x0086f640 0x00024 0x00024 0x4
+ NOTE 0x87f664 0xc086f664 0x0086f664 0x0000c 0x0000c 0x1
Section to Segment mapping:
Segment Sections...
> Christophe
>
>>
>> $ du -sk nick/vmlinux.with*
>> 124488 nick/vmlinux.with
>> 124004 nick/vmlinux.without
>>
>>
>>> Thanks,
>>> Nick
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-04-23 11:01 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-04-23 11:01 UTC (permalink / raw)
To: christophe leroy
Cc: Nicholas Piggin, linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
Christophe,
On Sat, Apr 21, 2018 at 9:16 AM, christophe leroy
<christophe.leroy@c-s.fr> wrote:
>
>
> Le 20/04/2018 =C3=A0 22:08, Mathieu Malaterre a =C3=A9crit :
>>
>> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com>
>> wrote:
>>>
>>> On Fri, 20 Apr 2018 12:00:49 +0200
>>> Mathieu Malaterre <malat@debian.org> wrote:
>>>
>>>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com>
>>>> wrote:
>>>>>
>>>>> This requires further changes to linker script to KEEP some tables
>>>>> and wildcard compiler generated sections into the right place. This
>>>>> includes pp32 modifications from Christophe Leroy.
>>>>>
>>>>> When compiling powernv_defconfig with this option:
>>>>>
>>>>> text data bss dec filename
>>>>> 11827621 4810490 1341080 17979191 vmlinux
>>>>> 11752437 4598858 1338776 17690071 vmlinux.dcde
>>>>>
>>>>> Resulting kernel is almost 400kB smaller (and still boots).
>>>>>
>>>>> [ppc32 numbers here]
>>>>
>>>>
>>>> ^^^
>>>>
>>>> Do you want somebody else to provide those numbers ?
>>>
>>>
>>> If you have a booting kernel, yes some more numbers would be good.
>>
>>
>> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> package. Rebuild master with and without option, boot ok, load/unload
>> module ok.
>>
>> $ size nick/vmlinux.with*
>> text data bss dec hex filename
>> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>>
>> This is not clear why with option the size of kernel is slightly bigger:
>
>
> The file contains also debug symbols, which might differ.
> Only the LOAD part of the file is interesting, that's the part you get wh=
en
> doing ppc-linux-objcopy vmlinux vmlinux.bin -O binary
>
> You can see it with readelf -l vmlinux
Here is what I see:
$ diff -u <(readelf -l nick/vmlinux.with) <(readelf -l nick/vmlinux.without=
)
--- /proc/self/fd/11 2018-04-23 12:59:52.413101612 +0200
+++ /proc/self/fd/12 2018-04-23 12:59:52.417101567 +0200
@@ -5,9 +5,9 @@
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
- LOAD 0x010000 0xc0000000 0x00000000 0x950f34 0xaad018 RWE 0x10=
000
- NOTE 0x867640 0xc0857640 0x00857640 0x00024 0x00024 0x4
- NOTE 0x867664 0xc0857664 0x00857664 0x0000c 0x0000c 0x1
+ LOAD 0x010000 0xc0000000 0x00000000 0x97ef34 0xadba68 RWE 0x10=
000
+ NOTE 0x87f640 0xc086f640 0x0086f640 0x00024 0x00024 0x4
+ NOTE 0x87f664 0xc086f664 0x0086f664 0x0000c 0x0000c 0x1
Section to Segment mapping:
Segment Sections...
> Christophe
>
>>
>> $ du -sk nick/vmlinux.with*
>> 124488 nick/vmlinux.with
>> 124004 nick/vmlinux.without
>>
>>
>>> Thanks,
>>> Nick
>
>
> ---
> L'absence de virus dans ce courrier =C3=A9lectronique a =C3=A9t=C3=A9 v=
=C3=A9rifi=C3=A9e par le
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-21 2:48 ` Nicholas Piggin
@ 2018-05-02 9:17 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-05-02 9:17 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
Nick,
On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Fri, 20 Apr 2018 22:08:27 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > On Fri, 20 Apr 2018 12:00:49 +0200
>> > Mathieu Malaterre <malat@debian.org> wrote:
>> >
>> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> > This requires further changes to linker script to KEEP some tables
>> >> > and wildcard compiler generated sections into the right place. This
>> >> > includes pp32 modifications from Christophe Leroy.
>> >> >
>> >> > When compiling powernv_defconfig with this option:
>> >> >
>> >> > text data bss dec filename
>> >> > 11827621 4810490 1341080 17979191 vmlinux
>> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >> >
>> >> > Resulting kernel is almost 400kB smaller (and still boots).
>> >> >
>> >> > [ppc32 numbers here]
>> >>
>> >> ^^^
>> >>
>> >> Do you want somebody else to provide those numbers ?
>> >
>> > If you have a booting kernel, yes some more numbers would be good.
>>
>> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> package. Rebuild master with and without option, boot ok, load/unload
>> module ok.
>>
>> $ size nick/vmlinux.with*
>> text data bss dec hex filename
>> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>>
>> This is not clear why with option the size of kernel is slightly bigger:
>>
>> $ du -sk nick/vmlinux.with*
>> 124488 nick/vmlinux.with
>> 124004 nick/vmlinux.without
>
> Not sure. readelf -S vmlinux may show something.
>
> To really get lots of detail, you can add to the top level Makefile:
>
> LDFLAGS_vmlinux += -M
Here is what I did:
$ git diff
diff --git a/Makefile b/Makefile
index 619a85ad716b..1a2e3d142a59 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc3
NAME = Fearless Coyote
+LDFLAGS_vmlinux += -M
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
Then:
$ rm ppc32/arch/powerpc/kernel/vmlinux.lds
$ make O=ppc32 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- W=1 V=1
-> I did not see anything specific. I must be missing one step, but I
don't see which one.
> Then it will print the link map for you and other details. Actually
> it will output several times because we link vmlinux 2-3 times, so
> just take the last one. There is a lot of data there.
>
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-05-02 9:17 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-05-02 9:17 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
Nick,
On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Fri, 20 Apr 2018 22:08:27 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > On Fri, 20 Apr 2018 12:00:49 +0200
>> > Mathieu Malaterre <malat@debian.org> wrote:
>> >
>> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> > This requires further changes to linker script to KEEP some tables
>> >> > and wildcard compiler generated sections into the right place. This
>> >> > includes pp32 modifications from Christophe Leroy.
>> >> >
>> >> > When compiling powernv_defconfig with this option:
>> >> >
>> >> > text data bss dec filename
>> >> > 11827621 4810490 1341080 17979191 vmlinux
>> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >> >
>> >> > Resulting kernel is almost 400kB smaller (and still boots).
>> >> >
>> >> > [ppc32 numbers here]
>> >>
>> >> ^^^
>> >>
>> >> Do you want somebody else to provide those numbers ?
>> >
>> > If you have a booting kernel, yes some more numbers would be good.
>>
>> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> package. Rebuild master with and without option, boot ok, load/unload
>> module ok.
>>
>> $ size nick/vmlinux.with*
>> text data bss dec hex filename
>> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>>
>> This is not clear why with option the size of kernel is slightly bigger:
>>
>> $ du -sk nick/vmlinux.with*
>> 124488 nick/vmlinux.with
>> 124004 nick/vmlinux.without
>
> Not sure. readelf -S vmlinux may show something.
>
> To really get lots of detail, you can add to the top level Makefile:
>
> LDFLAGS_vmlinux += -M
Here is what I did:
$ git diff
diff --git a/Makefile b/Makefile
index 619a85ad716b..1a2e3d142a59 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc3
NAME = Fearless Coyote
+LDFLAGS_vmlinux += -M
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
Then:
$ rm ppc32/arch/powerpc/kernel/vmlinux.lds
$ make O=ppc32 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- W=1 V=1
-> I did not see anything specific. I must be missing one step, but I
don't see which one.
> Then it will print the link map for you and other details. Actually
> it will output several times because we link vmlinux 2-3 times, so
> just take the last one. There is a lot of data there.
>
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-05-02 9:17 ` Mathieu Malaterre
@ 2018-05-02 12:24 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-05-02 12:24 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Wed, 2 May 2018 11:17:52 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> Nick,
>
> On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > On Fri, 20 Apr 2018 22:08:27 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > On Fri, 20 Apr 2018 12:00:49 +0200
> >> > Mathieu Malaterre <malat@debian.org> wrote:
> >> >
> >> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> >> > This requires further changes to linker script to KEEP some tables
> >> >> > and wildcard compiler generated sections into the right place. This
> >> >> > includes pp32 modifications from Christophe Leroy.
> >> >> >
> >> >> > When compiling powernv_defconfig with this option:
> >> >> >
> >> >> > text data bss dec filename
> >> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >> >
> >> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >> >
> >> >> > [ppc32 numbers here]
> >> >>
> >> >> ^^^
> >> >>
> >> >> Do you want somebody else to provide those numbers ?
> >> >
> >> > If you have a booting kernel, yes some more numbers would be good.
> >>
> >> I've used /boot/config-4.15.0-2-powerpc from my current debian
> >> package. Rebuild master with and without option, boot ok, load/unload
> >> module ok.
> >>
> >> $ size nick/vmlinux.with*
> >> text data bss dec hex filename
> >> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> >> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
> >>
> >> This is not clear why with option the size of kernel is slightly bigger:
> >>
> >> $ du -sk nick/vmlinux.with*
> >> 124488 nick/vmlinux.with
> >> 124004 nick/vmlinux.without
> >
> > Not sure. readelf -S vmlinux may show something.
> >
> > To really get lots of detail, you can add to the top level Makefile:
> >
> > LDFLAGS_vmlinux += -M
>
> Here is what I did:
>
> $ git diff
> diff --git a/Makefile b/Makefile
> index 619a85ad716b..1a2e3d142a59 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -4,6 +4,7 @@ PATCHLEVEL = 17
> SUBLEVEL = 0
> EXTRAVERSION = -rc3
> NAME = Fearless Coyote
> +LDFLAGS_vmlinux += -M
That'll get overwritten further down. Put it down with another line
that starts with LDFLAGS_vmlinux +=
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-05-02 12:24 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-05-02 12:24 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Wed, 2 May 2018 11:17:52 +0200
Mathieu Malaterre <malat@debian.org> wrote:
> Nick,
>
> On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > On Fri, 20 Apr 2018 22:08:27 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > On Fri, 20 Apr 2018 12:00:49 +0200
> >> > Mathieu Malaterre <malat@debian.org> wrote:
> >> >
> >> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> >> > This requires further changes to linker script to KEEP some tables
> >> >> > and wildcard compiler generated sections into the right place. This
> >> >> > includes pp32 modifications from Christophe Leroy.
> >> >> >
> >> >> > When compiling powernv_defconfig with this option:
> >> >> >
> >> >> > text data bss dec filename
> >> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >> >
> >> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >> >
> >> >> > [ppc32 numbers here]
> >> >>
> >> >> ^^^
> >> >>
> >> >> Do you want somebody else to provide those numbers ?
> >> >
> >> > If you have a booting kernel, yes some more numbers would be good.
> >>
> >> I've used /boot/config-4.15.0-2-powerpc from my current debian
> >> package. Rebuild master with and without option, boot ok, load/unload
> >> module ok.
> >>
> >> $ size nick/vmlinux.with*
> >> text data bss dec hex filename
> >> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
> >> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
> >>
> >> This is not clear why with option the size of kernel is slightly bigger:
> >>
> >> $ du -sk nick/vmlinux.with*
> >> 124488 nick/vmlinux.with
> >> 124004 nick/vmlinux.without
> >
> > Not sure. readelf -S vmlinux may show something.
> >
> > To really get lots of detail, you can add to the top level Makefile:
> >
> > LDFLAGS_vmlinux += -M
>
> Here is what I did:
>
> $ git diff
> diff --git a/Makefile b/Makefile
> index 619a85ad716b..1a2e3d142a59 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -4,6 +4,7 @@ PATCHLEVEL = 17
> SUBLEVEL = 0
> EXTRAVERSION = -rc3
> NAME = Fearless Coyote
> +LDFLAGS_vmlinux += -M
That'll get overwritten further down. Put it down with another line
that starts with LDFLAGS_vmlinux +=
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-04-20 10:41 ` Nicholas Piggin
@ 2018-05-07 0:46 ` Masahiro Yamada
-1 siblings, 0 replies; 45+ messages in thread
From: Masahiro Yamada @ 2018-05-07 0:46 UTC (permalink / raw)
To: Nicholas Piggin
Cc: Mathieu Malaterre, linuxppc-dev, linux-arch, Nicolas Pitre,
Linux Kbuild mailing list
Hi Nicholas,
2018-04-20 19:41 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> On Fri, 20 Apr 2018 12:00:49 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > This requires further changes to linker script to KEEP some tables
>> > and wildcard compiler generated sections into the right place. This
>> > includes pp32 modifications from Christophe Leroy.
>> >
>> > When compiling powernv_defconfig with this option:
>> >
>> > text data bss dec filename
>> > 11827621 4810490 1341080 17979191 vmlinux
>> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >
>> > Resulting kernel is almost 400kB smaller (and still boots).
>> >
>> > [ppc32 numbers here]
>>
>> ^^^
>>
>> Do you want somebody else to provide those numbers ?
>
> If you have a booting kernel, yes some more numbers would be good.
>
> Thanks,
> Nick
I applied this series because I want it to be more tested in linux-next.
Some requests:
- Could you provide information to replace '[ppc32 numbers here]'?
(or just remove it)
- V2 is welcome if you have code improvement.
(I thought so from your comments)
Thanks.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-05-07 0:46 ` Masahiro Yamada
0 siblings, 0 replies; 45+ messages in thread
From: Masahiro Yamada @ 2018-05-07 0:46 UTC (permalink / raw)
To: Nicholas Piggin
Cc: Mathieu Malaterre, linux-arch, Linux Kbuild mailing list,
linuxppc-dev, Nicolas Pitre
Hi Nicholas,
2018-04-20 19:41 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> On Fri, 20 Apr 2018 12:00:49 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > This requires further changes to linker script to KEEP some tables
>> > and wildcard compiler generated sections into the right place. This
>> > includes pp32 modifications from Christophe Leroy.
>> >
>> > When compiling powernv_defconfig with this option:
>> >
>> > text data bss dec filename
>> > 11827621 4810490 1341080 17979191 vmlinux
>> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >
>> > Resulting kernel is almost 400kB smaller (and still boots).
>> >
>> > [ppc32 numbers here]
>>
>> ^^^
>>
>> Do you want somebody else to provide those numbers ?
>
> If you have a booting kernel, yes some more numbers would be good.
>
> Thanks,
> Nick
I applied this series because I want it to be more tested in linux-next.
Some requests:
- Could you provide information to replace '[ppc32 numbers here]'?
(or just remove it)
- V2 is welcome if you have code improvement.
(I thought so from your comments)
Thanks.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-05-07 0:46 ` Masahiro Yamada
@ 2018-05-07 9:53 ` Nicholas Piggin
-1 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-05-07 9:53 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mathieu Malaterre, linuxppc-dev, linux-arch, Nicolas Pitre,
Linux Kbuild mailing list
On Mon, 7 May 2018 09:46:43 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Nicholas,
>
> 2018-04-20 19:41 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> > On Fri, 20 Apr 2018 12:00:49 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > This requires further changes to linker script to KEEP some tables
> >> > and wildcard compiler generated sections into the right place. This
> >> > includes pp32 modifications from Christophe Leroy.
> >> >
> >> > When compiling powernv_defconfig with this option:
> >> >
> >> > text data bss dec filename
> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >
> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >
> >> > [ppc32 numbers here]
> >>
> >> ^^^
> >>
> >> Do you want somebody else to provide those numbers ?
> >
> > If you have a booting kernel, yes some more numbers would be good.
> >
> > Thanks,
> > Nick
>
>
>
> I applied this series because I want it to be more tested in linux-next.
Thank you.
> Some requests:
>
> - Could you provide information to replace '[ppc32 numbers here]'?
> (or just remove it)
Yes there were some numbers reported, I can give you an updated
changelog.
> - V2 is welcome if you have code improvement.
> (I thought so from your comments)
I'll see where it ended up and send you updated patches if necessary.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-05-07 9:53 ` Nicholas Piggin
0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Piggin @ 2018-05-07 9:53 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mathieu Malaterre, linux-arch, Linux Kbuild mailing list,
linuxppc-dev, Nicolas Pitre
On Mon, 7 May 2018 09:46:43 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Nicholas,
>
> 2018-04-20 19:41 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> > On Fri, 20 Apr 2018 12:00:49 +0200
> > Mathieu Malaterre <malat@debian.org> wrote:
> >
> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> >> > This requires further changes to linker script to KEEP some tables
> >> > and wildcard compiler generated sections into the right place. This
> >> > includes pp32 modifications from Christophe Leroy.
> >> >
> >> > When compiling powernv_defconfig with this option:
> >> >
> >> > text data bss dec filename
> >> > 11827621 4810490 1341080 17979191 vmlinux
> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
> >> >
> >> > Resulting kernel is almost 400kB smaller (and still boots).
> >> >
> >> > [ppc32 numbers here]
> >>
> >> ^^^
> >>
> >> Do you want somebody else to provide those numbers ?
> >
> > If you have a booting kernel, yes some more numbers would be good.
> >
> > Thanks,
> > Nick
>
>
>
> I applied this series because I want it to be more tested in linux-next.
Thank you.
> Some requests:
>
> - Could you provide information to replace '[ppc32 numbers here]'?
> (or just remove it)
Yes there were some numbers reported, I can give you an updated
changelog.
> - V2 is welcome if you have code improvement.
> (I thought so from your comments)
I'll see where it ended up and send you updated patches if necessary.
Thanks,
Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
2018-05-02 12:24 ` Nicholas Piggin
@ 2018-05-14 19:10 ` Mathieu Malaterre
-1 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-05-14 19:10 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, linux-arch, Nicolas Pitre, linux-kbuild
On Wed, May 2, 2018 at 2:24 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Wed, 2 May 2018 11:17:52 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> Nick,
>>
>> On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > On Fri, 20 Apr 2018 22:08:27 +0200
>> > Mathieu Malaterre <malat@debian.org> wrote:
>> >
>> >> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> > On Fri, 20 Apr 2018 12:00:49 +0200
>> >> > Mathieu Malaterre <malat@debian.org> wrote:
>> >> >
>> >> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> >> > This requires further changes to linker script to KEEP some tables
>> >> >> > and wildcard compiler generated sections into the right place. This
>> >> >> > includes pp32 modifications from Christophe Leroy.
>> >> >> >
>> >> >> > When compiling powernv_defconfig with this option:
>> >> >> >
>> >> >> > text data bss dec filename
>> >> >> > 11827621 4810490 1341080 17979191 vmlinux
>> >> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >> >> >
>> >> >> > Resulting kernel is almost 400kB smaller (and still boots).
>> >> >> >
>> >> >> > [ppc32 numbers here]
>> >> >>
>> >> >> ^^^
>> >> >>
>> >> >> Do you want somebody else to provide those numbers ?
>> >> >
>> >> > If you have a booting kernel, yes some more numbers would be good.
>> >>
>> >> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> >> package. Rebuild master with and without option, boot ok, load/unload
>> >> module ok.
>> >>
>> >> $ size nick/vmlinux.with*
>> >> text data bss dec hex filename
>> >> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> >> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>> >>
>> >> This is not clear why with option the size of kernel is slightly bigger:
>> >>
>> >> $ du -sk nick/vmlinux.with*
>> >> 124488 nick/vmlinux.with
>> >> 124004 nick/vmlinux.without
>> >
>> > Not sure. readelf -S vmlinux may show something.
>> >
>> > To really get lots of detail, you can add to the top level Makefile:
>> >
>> > LDFLAGS_vmlinux += -M
>>
>> Here is what I did:
>>
>> $ git diff
>> diff --git a/Makefile b/Makefile
>> index 619a85ad716b..1a2e3d142a59 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -4,6 +4,7 @@ PATCHLEVEL = 17
>> SUBLEVEL = 0
>> EXTRAVERSION = -rc3
>> NAME = Fearless Coyote
>> +LDFLAGS_vmlinux += -M
>
> That'll get overwritten further down. Put it down with another line
> that starts with LDFLAGS_vmlinux +=
Sorry about that, I was not paying attention :(
Anyway I cannot make sense of the output with -M.
Here is a quick summary if needed (with option / without option).
$ ./scripts/bloat-o-meter nick/vmlinux.without nick/vmlinux.with | head
add/remove: 0/647 grow/shrink: 852/1846 up/down: 11276/-95033 (-83757)
Function old new delta
SiSInitPtr 2212 2600 +388
xmon_core.isra 7540 7900 +360
ata_attach_transport 840 1032 +192
via_pmu_interrupt 2828 3004 +176
matroxfb_init 3000 3156 +156
fbcon_scroll 3092 3248 +156
__do_adjtimex 1716 1868 +152
fbcon_event_notify 2044 2184 +140
$ ./scripts/bloat-o-meter nick/vmlinux.without nick/vmlinux.with | tail
aty_set_pll18818 540 - -540
sel_ib_pkey_sid 556 - -556
pci_dev_acs_enabled 608 - -608
aa_label_find_merge 752 - -752
drmem_update_dt 796 - -796
powerpc_macros 1176 - -1176
ima_restore_measurement_list 1224 - -1224
rtas_os_term_buf 2048 - -2048
vle_opcodes 8200 - -8200
Total: Before=9927171, After=9843414, chg -0.84%
> Thanks,
> Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
@ 2018-05-14 19:10 ` Mathieu Malaterre
0 siblings, 0 replies; 45+ messages in thread
From: Mathieu Malaterre @ 2018-05-14 19:10 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-arch, linux-kbuild, linuxppc-dev, Nicolas Pitre
On Wed, May 2, 2018 at 2:24 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> On Wed, 2 May 2018 11:17:52 +0200
> Mathieu Malaterre <malat@debian.org> wrote:
>
>> Nick,
>>
>> On Sat, Apr 21, 2018 at 4:48 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> > On Fri, 20 Apr 2018 22:08:27 +0200
>> > Mathieu Malaterre <malat@debian.org> wrote:
>> >
>> >> On Fri, Apr 20, 2018 at 12:41 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> > On Fri, 20 Apr 2018 12:00:49 +0200
>> >> > Mathieu Malaterre <malat@debian.org> wrote:
>> >> >
>> >> >> On Fri, Apr 20, 2018 at 9:34 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
>> >> >> > This requires further changes to linker script to KEEP some tables
>> >> >> > and wildcard compiler generated sections into the right place. This
>> >> >> > includes pp32 modifications from Christophe Leroy.
>> >> >> >
>> >> >> > When compiling powernv_defconfig with this option:
>> >> >> >
>> >> >> > text data bss dec filename
>> >> >> > 11827621 4810490 1341080 17979191 vmlinux
>> >> >> > 11752437 4598858 1338776 17690071 vmlinux.dcde
>> >> >> >
>> >> >> > Resulting kernel is almost 400kB smaller (and still boots).
>> >> >> >
>> >> >> > [ppc32 numbers here]
>> >> >>
>> >> >> ^^^
>> >> >>
>> >> >> Do you want somebody else to provide those numbers ?
>> >> >
>> >> > If you have a booting kernel, yes some more numbers would be good.
>> >>
>> >> I've used /boot/config-4.15.0-2-powerpc from my current debian
>> >> package. Rebuild master with and without option, boot ok, load/unload
>> >> module ok.
>> >>
>> >> $ size nick/vmlinux.with*
>> >> text data bss dec hex filename
>> >> 7386425 2364370 1425432 11176227 aa8923 nick/vmlinux.with
>> >> 7461457 2475122 1428064 11364643 ad6923 nick/vmlinux.without
>> >>
>> >> This is not clear why with option the size of kernel is slightly bigger:
>> >>
>> >> $ du -sk nick/vmlinux.with*
>> >> 124488 nick/vmlinux.with
>> >> 124004 nick/vmlinux.without
>> >
>> > Not sure. readelf -S vmlinux may show something.
>> >
>> > To really get lots of detail, you can add to the top level Makefile:
>> >
>> > LDFLAGS_vmlinux += -M
>>
>> Here is what I did:
>>
>> $ git diff
>> diff --git a/Makefile b/Makefile
>> index 619a85ad716b..1a2e3d142a59 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -4,6 +4,7 @@ PATCHLEVEL = 17
>> SUBLEVEL = 0
>> EXTRAVERSION = -rc3
>> NAME = Fearless Coyote
>> +LDFLAGS_vmlinux += -M
>
> That'll get overwritten further down. Put it down with another line
> that starts with LDFLAGS_vmlinux +=
Sorry about that, I was not paying attention :(
Anyway I cannot make sense of the output with -M.
Here is a quick summary if needed (with option / without option).
$ ./scripts/bloat-o-meter nick/vmlinux.without nick/vmlinux.with | head
add/remove: 0/647 grow/shrink: 852/1846 up/down: 11276/-95033 (-83757)
Function old new delta
SiSInitPtr 2212 2600 +388
xmon_core.isra 7540 7900 +360
ata_attach_transport 840 1032 +192
via_pmu_interrupt 2828 3004 +176
matroxfb_init 3000 3156 +156
fbcon_scroll 3092 3248 +156
__do_adjtimex 1716 1868 +152
fbcon_event_notify 2044 2184 +140
$ ./scripts/bloat-o-meter nick/vmlinux.without nick/vmlinux.with | tail
aty_set_pll18818 540 - -540
sel_ib_pkey_sid 556 - -556
pci_dev_acs_enabled 608 - -608
aa_label_find_merge 752 - -752
drmem_update_dt 796 - -796
powerpc_macros 1176 - -1176
ima_restore_measurement_list 1224 - -1224
rtas_os_term_buf 2048 - -2048
vle_opcodes 8200 - -8200
Total: Before=9927171, After=9843414, chg -0.84%
> Thanks,
> Nick
^ permalink raw reply [flat|nested] 45+ messages in thread
end of thread, other threads:[~2018-05-14 19:16 UTC | newest]
Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 7:34 [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc Nicholas Piggin
2018-04-20 7:34 ` Nicholas Piggin
2018-04-20 7:34 ` [PATCH 1/4] kbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION Nicholas Piggin
2018-04-20 7:34 ` Nicholas Piggin
2018-04-20 7:34 ` [PATCH 2/4] kbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for module build Nicholas Piggin
2018-04-20 7:34 ` Nicholas Piggin
2018-04-20 7:34 ` [PATCH 3/4] kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled Nicholas Piggin
2018-04-20 7:34 ` Nicholas Piggin
2018-04-20 7:34 ` [PATCH 4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected Nicholas Piggin
2018-04-20 7:34 ` Nicholas Piggin
2018-04-20 10:00 ` Mathieu Malaterre
2018-04-20 10:00 ` Mathieu Malaterre
2018-04-20 10:41 ` Nicholas Piggin
2018-04-20 10:41 ` Nicholas Piggin
2018-04-20 20:08 ` Mathieu Malaterre
2018-04-20 20:08 ` Mathieu Malaterre
2018-04-21 2:48 ` Nicholas Piggin
2018-04-21 2:48 ` Nicholas Piggin
2018-05-02 9:17 ` Mathieu Malaterre
2018-05-02 9:17 ` Mathieu Malaterre
2018-05-02 12:24 ` Nicholas Piggin
2018-05-02 12:24 ` Nicholas Piggin
2018-05-14 19:10 ` Mathieu Malaterre
2018-05-14 19:10 ` Mathieu Malaterre
2018-04-21 7:16 ` christophe leroy
2018-04-21 7:16 ` christophe leroy
2018-04-23 11:01 ` Mathieu Malaterre
2018-04-23 11:01 ` Mathieu Malaterre
2018-04-23 11:01 ` Mathieu Malaterre
2018-05-07 0:46 ` Masahiro Yamada
2018-05-07 0:46 ` Masahiro Yamada
2018-05-07 9:53 ` Nicholas Piggin
2018-05-07 9:53 ` Nicholas Piggin
2018-04-20 10:01 ` Christophe LEROY
2018-04-20 10:01 ` Christophe LEROY
2018-04-20 10:36 ` Nicholas Piggin
2018-04-20 10:36 ` Nicholas Piggin
2018-04-20 13:21 ` Christophe LEROY
2018-04-20 13:21 ` Christophe LEROY
2018-04-20 10:39 ` Christophe LEROY
2018-04-20 10:39 ` Christophe LEROY
2018-04-20 9:59 ` [PATCH 0/4] LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc Mathieu Malaterre
2018-04-20 9:59 ` Mathieu Malaterre
2018-04-20 10:02 ` Christophe LEROY
2018-04-20 10:02 ` Christophe LEROY
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.