[PATCH] arm64: enable dead code elimination

Kefeng Wang wangkefeng.wang at huawei.com
Tue Jul 18 04:11:06 PDT 2023



On 2023/7/17 20:15, Marc Zyngier wrote:
> On Mon, 17 Jul 2023 12:56:39 +0100,
> Kefeng Wang <wangkefeng.wang at huawei.com> wrote:
>>
>>
>>
>> On 2023/7/17 17:42, Marc Zyngier wrote:
>>> On 2023-07-17 09:07, 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,
>>>>
...
>>>
>>> I took this patch for a spin in my tree, and ended up with:
>>>
>>>     CC      .vmlinux.export.o
>>>     UPD     include/generated/utsversion.h
>>>     CC      init/version-timestamp.o
>>>     LD      .tmp_vmlinux.kallsyms1
>>> ld: init/main.o(__patchable_function_entries): error: need linked-to
>>> section for --gc-sections
>>> make[2]: *** [scripts/Makefile.vmlinux:36: vmlinux] Error 1
>>> make[1]: *** [/home/maz/hot-poop/arm-platforms/Makefile:1238:
>>> vmlinux] Error 2
>>> make: *** [Makefile:234: __sub-make] Error 2
>>
>> I don't find this error with CONFIG_FTRACE_MCOUNT_RECORD or
>> allyesconfig, does it need special config or gcc version?
> 
> You tell me!
> 
> gcc (Debian 10.2.1-6) 10.2.1 20210110
> Copyright (C) 2020 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> so hardly something special. This is built with the current state of
> my NV tree, available here[1] As for the configuration, have a look
> here[2].

1) With gcc 10.3.1/ld (GNU Binutils) 2.37, it could be reproduced,
but there is no issue for cross-compiler gcc 9.3/ld (GNU Binutils for
Ubuntu) 2.34.

2) There is same issue like commit f7584322e4fe ("riscv: disable 
HAVE_LD_DEAD_CODE_DATA_ELIMINATION for LLD") said with allyesconfig on
arm64, it takes too long in bfd_flavour_name()

Samples: 257K of event 'cycles', Event count (approx.): 203974259359 

   Overhead  Shared Object             Symbol 
               IPC   [IPC Coverage]
-   61.11%  libbfd-2.34-arm64.so      [.] bfd_flavour_name 
              -      -
      bfd_flavour_name 

-    6.55%  libbfd-2.34-arm64.so      [.] bfd_hash_traverse 
              -      -


Just like you said, it is not ready for prime time, so please ignore
this patch :(


> 
> 	M.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.6-WIP
> [2] https://paste.debian.net/1286106/
> 



More information about the linux-arm-kernel mailing list