On Thu, Sep 17, 2026 at 05:06:14PM +0100, Lorenzo Stoakes (ARM) wrote:
> Unless instructed otherwise, nm sorts by name.
> 
> There are places where this is unnecessary - an invocation from
> scripts/sorttable every vmlinux link, scripts/check-function-names.sh run
> after every vmlinux.o link, and the x86 VOFFSET and ZOFFSET listings
> between vmlinux and bzImage.
> 
> Both GNU nm and llvm-nm accept the same '-p' parameter to disable sorting
> in these instances, so use that to prevent this unnecessary work.
> 
> Each nm run on its own, x86-64, median of 5:
> 
>                              GNU nm 2.47              llvm-nm 22
>                           before  after   delta    before  after   delta
>   defconfig
>   sorttable, nm -S vmlinux 0.080s 0.039s -0.041s   0.265s 0.113s -0.152s
>   check-function-names.sh  0.072s 0.033s -0.039s   0.244s 0.102s -0.142s
>   VOFFSET                  0.077s 0.034s -0.043s   0.261s 0.113s -0.148s
>   ZOFFSET                  0.007s 0.005s -0.002s   0.005s 0.005s  0.000s
>   TOTAL                                  -0.125s                 -0.442s
> 
>   allmodconfig
>   sorttable, nm -S vmlinux 0.156s 0.063s -0.093s   0.539s 0.223s -0.316s
>   check-function-names.sh  0.149s 0.054s -0.095s   0.537s 0.217s -0.320s
>   VOFFSET                  0.146s 0.052s -0.094s   0.524s 0.221s -0.303s
>   ZOFFSET                  0.007s 0.005s -0.002s   0.006s 0.004s -0.002s
>   TOTAL                                  -0.284s                 -0.941s
> 
> llvm-nm appears to be a lot slower than GNU nm, so these builds naturally
> improve the most.
> 
> The four run one after another in the serial tail of every build that links
> vmlinux so impact kernel builds directly.
> 
> In an allmodconfig the decompressor is built in parallel while the modules,
> so only the two before the vmlinux link contribute to build time.
> 
> The build outputs remain unchanged.
> 
> Whole build, 128-thread Threadripper 9980X, best of N runs:
> 
>                                           before    after     delta
>                                         ---------------------------------
>   x86 defconfig, touch mm/vma.c, gcc        9.7s     9.5s    -0.18s (-2%)
>   x86 defconfig, touch mm/vma.c, clang      9.3s     9.0s    -0.27s (-3%)
>   x86 defconfig, clean, gcc                30.3s    30.1s    -0.16s (-1%)
>   x86 defconfig, clean, clang              31.7s    31.2s    -0.55s (-2%)
>   x86 allmodconfig, touch mm/vma.c, clang  36.4s    35.8s    -0.67s (-2%)
> 
> Assisted-by: LLM
> Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
> ---
>  arch/x86/boot/Makefile            | 2 +-
>  arch/x86/boot/compressed/Makefile | 2 +-
>  scripts/check-function-names.sh   | 3 ++-
>  scripts/link-vmlinux.sh           | 2 +-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 

Thanks!

Reviewed-by: Nicolas Schier <[email protected]>

-- 
Nicolas

Reply via email to