diff mbox series

[4/4] powerpc: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected

Message ID 20180420073414.23169-5-npiggin@gmail.com (mailing list archive)
State Superseded
Headers show
Series LD_DEAD_CODE_DATA_ELIMINATION fixes and enabling for powerpc | expand

Commit Message

Nicholas Piggin April 20, 2018, 7:34 a.m. UTC
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(-)

Comments

Mathieu Malaterre April 20, 2018, 10 a.m. UTC | #1
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
>
Christophe Leroy April 20, 2018, 10:01 a.m. UTC | #2
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 = .;
>   	}
>   
>
Nicholas Piggin April 20, 2018, 10:36 a.m. UTC | #3
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
Christophe Leroy April 20, 2018, 10:39 a.m. UTC | #4
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 = .;
>   	}
>   
>
Nicholas Piggin April 20, 2018, 10:41 a.m. UTC | #5
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
Christophe Leroy April 20, 2018, 1:21 p.m. UTC | #6
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
>
Mathieu Malaterre April 20, 2018, 8:08 p.m. UTC | #7
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
Nicholas Piggin April 21, 2018, 2:48 a.m. UTC | #8
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.
Christophe Leroy April 21, 2018, 7:16 a.m. UTC | #9
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
Mathieu Malaterre April 23, 2018, 11:01 a.m. UTC | #10
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
>
Mathieu Malaterre May 2, 2018, 9:17 a.m. UTC | #11
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.
>
Nicholas Piggin May 2, 2018, 12:24 p.m. UTC | #12
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
Masahiro Yamada May 7, 2018, 12:46 a.m. UTC | #13
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.
Nicholas Piggin May 7, 2018, 9:53 a.m. UTC | #14
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
Mathieu Malaterre May 14, 2018, 7:10 p.m. UTC | #15
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
diff mbox series

Patch

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 = .;
 	}