Re: [PATCH] mm: optimize once judgment with clang
From: Xie Yuanbin
Date: Sat Mar 07 2026 - 09:42:30 EST
On Sat, 7 Mar 2026 10:12:18 +0200, Mike Rapoport wrote:
> On Sat, Mar 07, 2026 at 02:54:04PM +0800, Xie Yuanbin wrote:
>> commit 242b872239f6a7deacbc ("include/linux/once_lite.h: fix judgment in
>> WARN_ONCE with clang") helps optimize performance and size under the
>> clang compiler, but the modification is not complete.
>
> How much does it actually optimize for size?
Basing on commit a0ae2a256046c0c5d377 ("Add linux-next specific
files for 20260306"), compiler "Debian clang version 21.1.8 (5)",
arm64 default defconfig, and setting CONFIG_CC_OPTIMIZE_FOR_SIZE=y,
the size result is:
| | size |
| -| -|
| Image.gz | 14256146 |
| size of ".text" section in vmlinex | 17035264 |
Basing on above, revert the commit 242b872239f6a7deacbc
("include/linux/once_lite.h: fix judgment in WARN_ONCE with clang"),
and build again:
| | size |
| -| -|
| Image.gz | 14258152(+2006) |
| size of ".text" section in vmlinex | 17039360(+4096) |
> Note that performance is really not critical here because we are already
> dealing with slow path of debug code.
It seems that WARN_ON_ONCE_GFP() is not affected by in CONFIG_DEBUG_VM,
and it is used in __alloc_frozen_pages_noprof(), which seems to be a hot
path.