[PATCH] arm64: enable dead code elimination
Yuntao Liu
liuyuntao12 at huawei.com
Thu Jan 25 05:45:32 PST 2024
On 2023/7/17 17:24, Will Deacon wrote:
> On Mon, Jul 17, 2023 at 04:07:39PM +0800, Kefeng Wang wrote:
>> 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
>
> Is that a 0.009% improvement? Is it really worth the hassle?
>
> x86 doesn't select this and risc-v had to turn it off for LLD, so it feels
> like we're just creating a rod for our own back by selecting it.
I tested this patch and found that, the smaller the config file,the more
significant the reduction in file size of the builds. This may be useful
in scenarios such as embedded systems where size is particularly critical.
Just like Select CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION for RISC-V,
this boots well on qemu, with defconfig, it shrinks their builds by ~1.6%,
and with tinyconfig it shrinks their builds by ~18.7%.
defconfig:
text data bss dec hex
26839348 16695234 629456 44164038 2a1e3c6 before
26140556 16667058 628880 43436494 296c9ce after
tinyconfig:
text data bss dec hex
1259568 272100 104312 1635980 18f68c before
967056 258716 103824 1329596 1449bc after
| tinyconfig | defconfig
--------|------------------------|---------------------
No DCE | 1635980 | 44164038
DCE | 1329596 | 43436494
Shrink | 306384 (~18.7%) | 727544 (~1.6%)
>
> Will
>
More information about the linux-arm-kernel
mailing list