Re: [PATCH] arch/x86: Add an option to build the kernel with '-march=native' on x86-64
From: Arnd Bergmann
Date: Mon Mar 24 2025 - 04:46:25 EST
On Sun, Mar 23, 2025, at 16:14, Tor Vic wrote:
> On 3/22/25 12:40, Arnd Bergmann wrote:
>> On Fri, Mar 21, 2025, at 15:28, Tor Vic wrote:
>>
>> Are you able to quickly run the same tests again using
>> just one of the two?
>>
>> a) -march=x86-64 -mtune=skylake
>> b) -march=skylake -mtune=generic
>>
>
> I ran the tests on Zen2 (znver2), but this time the kernel was built
> with clang-20+lto (the skylake tests were with gcc-14).
>
> It turned out that with '-march=native', there is almost no difference
> compared to '-march=x86-64'.
> All results are within +0.8% and -0.6%, most of which are probably
> noise. Hackbench, stress-ng fork and xz compression seem to profit the
> most from 'native'.
>
> The vmlinux image is 0.03% bigger with 'native'.
>
> I guess that 'native' can be somewhat useful on some architectures, but
> not on all...
It certainly depends on configuration, toolchain and target machine,
so it's very hard to say anything general about -march=native.
znver2 and skylake are quite similar in the supported instructions,
so my guess would be that the clang-20+lto doesn't behave that differently
between march=x86-64 and march=znver2.
Of course if you don't have the same kernel version and configuration
that you are testing, the results between the two machines, the
results would be fairly random as well.
Arnd