From: "liuyuntao (F)" <liuyuntao12@huawei.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-kbuild@vger.kernel.org>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
<masahiroy@kernel.org>, <nathan@kernel.org>, <nicolas@fjasle.eu>,
<peterz@infradead.org>, <jpoimboe@kernel.org>,
<leitao@debian.org>, <petr.pavlu@suse.com>,
<richard.weiyang@gmail.com>, <ruanjinjie@huawei.com>,
<ndesaulniers@google.com>, <jgross@suse.com>
Subject: Re: [PATCH] x86: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Date: Thu, 25 Apr 2024 17:41:42 +0800 [thread overview]
Message-ID: <75734e13-1f46-4cd4-85b5-d4074c242606@huawei.com> (raw)
In-Reply-To: <fa7f3c1b-7693-465c-9f24-e6176074a818@intel.com>
On 2024/4/25 17:21, Alexander Lobakin wrote:
> From: Liuyuntao (F) <liuyuntao12@huawei.com>
> Date: Thu, 25 Apr 2024 14:37:19 +0800
>
>>
>>
>> On 2024/4/24 19:06, Alexander Lobakin wrote:
>>> From: Yuntao Liu <liuyuntao12@huawei.com>
>>> Date: Mon, 22 Apr 2024 06:05:56 +0000
>>>
>>>> The current x86 architecture does not yet support the
>>>> HAVE_LD_DEAD_CODE_DATA_ELIMINATION feature. x86 is widely used in
>>>> embedded scenarios, and enabling this feature would be beneficial for
>>>> reducing the size of the kernel image.
>>>>
>>>> In order to make this work, 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.
>>>>
>>>> Enabling CONFIG_UNWINDER_ORC or CONFIG_MITIGATION_RETPOLINE will enable
>>>> the objtool's --orc and --retpoline parameters, which will alter the
>>>> layout of the binary file, thereby preventing gc-sections from
>>>> functioning
>>>> properly. Therefore, HAVE_LD_DEAD_CODE_DATA_ELIMINATION should only be
>>>> selected when they are not enabled.
>>>
>>> Dunno, I have DCE enabled for years on my home kernel, see commit [0]
>>> with both ORC and retpolines enabled, and I didn't have any issues.
>>> vmlinux still shrinks well, even with Clang LTO.
>>>
>>>>
>>>> Enabling CONFIG_LTO_CLANG or CONFIG_X86_KERNEL_IBT will use vmlinux.o
>>>> instead of performing the slow LTO link again. This can also prevent
>>>> gc-sections from functioning properly. Therefore, using this
>>>> optimization
>>>> when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled.
>>>>
>>>> The size comparison of zImage is as follows:
>>>> x86_def_defconfig i386_defconfig tinyconfig
>>>> 10892288 10826240 607232 no dce
>>>> 10748928 10719744 529408 dce
>>>> 1.3% 0.98% 12.8% shrink
>>>>
>>>> When using smaller config file, there is a significant reduction in the
>>>> size of the zImage.
>>>
>>> [0] https://github.com/solbjorn/linux/commit/25c4953ea73d
>>>
>>> Thanks,
>>> Olek
>>
>> I apply your patch, and use LLVM toolchain to compile the kernel, it not
>> boot on QEMU.
>> I use the following command.
>>> qemu-system-x86_64 -smp 2 -m 1024M -nographic -kernel
>>> mainline_linux/arch/x86/boot/bzImage -hda rootfs.img -append
>>> "root=/dev/sda console=ttyS0 rootfstype=ext4 init=/linuxrc rw"
>> Have you tested your patch on the latest mainline version?
>
> Nope, it was a year ago and I haven't touched it since then. Did the
> low-level code change a lot?
>
No, I'm not yet certain what changes have had an impact on it compared
to a year ago.
prev parent reply other threads:[~2024-04-25 9:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 6:05 [PATCH] x86: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Yuntao Liu
2024-04-22 16:01 ` Masahiro Yamada
2024-04-23 11:48 ` liuyuntao (F)
2024-04-22 19:24 ` Nathan Chancellor
2024-04-23 12:02 ` liuyuntao (F)
2024-04-23 0:59 ` Wei Yang
2024-04-23 12:10 ` liuyuntao (F)
2024-04-24 11:06 ` Alexander Lobakin
2024-04-25 6:37 ` liuyuntao (F)
2024-04-25 9:21 ` Alexander Lobakin
2024-04-25 9:41 ` liuyuntao (F) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=75734e13-1f46-4cd4-85b5-d4074c242606@huawei.com \
--to=liuyuntao12@huawei.com \
--cc=aleksander.lobakin@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jpoimboe@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=richard.weiyang@gmail.com \
--cc=ruanjinjie@huawei.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).