linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: enable dead code elimination
@ 2023-07-17  8:07 Kefeng Wang
  2023-07-17  9:24 ` Will Deacon
  2023-07-17  9:42 ` Marc Zyngier
  0 siblings, 2 replies; 8+ messages in thread
From: Kefeng Wang @ 2023-07-17  8:07 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon; +Cc: linux-arm-kernel, linux-kernel, Kefeng Wang

Select CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION for arm64, allowing the
user to enable dead code elimination. In order for this to work, ensure
that we keep the necessary tables by annotating them with KEEP, also it
requires further changes to linker script to KEEP some tables and wildcard
compiler generated sections into the right place.

The following comparison is based 6.5-rc2 with defconfig,

$ ./scripts/bloat-o-meter vmlinux-base vmlinux-new
add/remove: 3/1106 grow/shrink: 4102/6964 up/down: 35704/-99980 (-64276)
Function                                     old     new   delta
...
Total: Before=17888959, After=17824683, chg -0.36%

add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-44 (-44)
Data                                         old     new   delta
...
Total: Before=4820808, After=4820764, chg -0.00%

add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-1096 (-1096)
RO Data                                      old     new   delta
...
Total: Before=5179123, After=5178027, chg -0.02%

$ size vmlinux-base vmlinux
   text	   data	     bss      dec       hex	filename
25433734  15385766  630656  41450156  2787aac	vmlinux-base
24756738  15360870  629888  40747496  26dc1e8	vmlinux-new

Memory available after booting, saving 704k on qemu,
base: 8084532K/8388608K
new:  8085236K/8388608K

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm64/Kconfig              | 1 +
 arch/arm64/kernel/vmlinux.lds.S | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a2511b30d0f6..73bb908ec62f 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -148,6 +148,7 @@ config ARM64
 	select GENERIC_VDSO_TIME_NS
 	select HARDIRQS_SW_RESEND
 	select HAS_IOPORT
+	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
 	select HAVE_MOVE_PMD
 	select HAVE_MOVE_PUD
 	select HAVE_PCI
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 3cd7e76cc562..bb4ce6cd6896 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -238,7 +238,7 @@ SECTIONS
 	. = ALIGN(4);
 	.altinstructions : {
 		__alt_instructions = .;
-		*(.altinstructions)
+		KEEP(*(.altinstructions))
 		__alt_instructions_end = .;
 	}
 
@@ -258,8 +258,9 @@ SECTIONS
 		INIT_CALLS
 		CON_INITCALL
 		INIT_RAM_FS
-		*(.init.altinstructions .init.bss)	/* from the EFI stub */
+		KEEP(*(.init.altinstructions .init.bss*))	/* from the EFI stub */
 	}
+
 	.exit.data : {
 		EXIT_DATA
 	}
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-25 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17  8:07 [PATCH] arm64: enable dead code elimination Kefeng Wang
2023-07-17  9:24 ` Will Deacon
2023-07-17 11:20   ` Kefeng Wang
2024-01-25 13:45   ` Yuntao Liu
2023-07-17  9:42 ` Marc Zyngier
2023-07-17 11:56   ` Kefeng Wang
2023-07-17 12:15     ` Marc Zyngier
2023-07-18 11:11       ` Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).