From: Tor Vic <torvic9@mailbox.org>
To: Arnd Bergmann <arnd@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] arch/x86: Add an option to build the kernel with '-march=native' on x86-64
Date: Sat, 22 Mar 2025 13:08:47 +0100 [thread overview]
Message-ID: <9f0da222-f75b-46a2-97d6-24f6e2da7abd@mailbox.org> (raw)
In-Reply-To: <e37ee471-0b10-48d4-ad20-871e585c98f6@app.fastmail.com>
On 3/22/25 12:40, Arnd Bergmann wrote:
> On Fri, Mar 21, 2025, at 15:28, Tor Vic wrote:
>> Add a 'native' option that allows users to build an optimized kernel for
>> their local machine (i.e. the machine which is used to build the kernel)
>> by passing '-march=native' to the CFLAGS.
>>
>> The idea comes from Linus' reply to Arnd's initial proposal in [1].
>>
>> This patch is based on Arnd's x86 cleanup series, which is now in -tip [2].
>
> Thanks for having another look at this and for including the
> benchmarks. I ended up dropping this bit of my series because
> there were too many open questions around things like
> reproducible builds, but there is clearly a demand for having
> this included.
>
>> hackbench (lower is better):
>> 102.27 --> 99.50 (-2.709 %)
>>
>> - stress-ng, bogoops, average of 3 15-second runs:
>> fork:
>> 111'744 --> 115'509 (+3.397 %)
>> bsearch:
>> 7'211 --> 7'436 (+3.120 %)
>> vm:
>> 1'442'256 --> 1'486'615 (+3.076 %)
>
> 3% in userspace benchmarks does seem significant enough to
> spend more time on seeing what exactly made the difference
> here, and possibly including it as separate options.
I didn't have a lot of time, so I only started 3 runs, and that is
probably not enough to get accurate results as some tests are quite
fluctuating.
I'm also not sure if those stress-ng tests are appropriate for this kind
of testing, but I decided to include the results.
Suggestions for other benchmarks are welcome!
>
>> +ifdef CONFIG_NATIVE_CPU
>> + KBUILD_CFLAGS += -march=native
>> + KBUILD_RUSTFLAGS += -Ctarget-cpu=native
>> +else
>> KBUILD_CFLAGS += -march=x86-64 -mtune=generic
>> KBUILD_RUSTFLAGS += -Ctarget-cpu=x86-64 -Ztune-cpu=generic
>> +endif
>
> I assume that the difference here is that -march=native on
> your machine gets turned into -march=skylake, which then turns
> on both additional instructions and a different instruction
> scheduler.
IIRC, '-march=native' on Skylake turns into '-march=skylake -mabm' with gcc.
>
> 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
>
Unfortunately that poor old laptop is quite slow, but I intend to run
more tests on my much faster Zen2 machine next week.
I'll report back.
> Arnd
next prev parent reply other threads:[~2025-03-22 12:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 14:28 Tor Vic
2025-03-21 17:35 ` H. Peter Anvin
2025-03-22 11:40 ` Arnd Bergmann
2025-03-22 12:08 ` Tor Vic [this message]
2025-03-22 21:53 ` David Laight
2025-03-22 22:03 ` H. Peter Anvin
2025-03-23 15:14 ` Tor Vic
2025-03-24 8:45 ` Arnd Bergmann
2025-04-03 13:33 ` [tip: x86/kconfig] x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native' tip-bot2 for Tor Vic
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=9f0da222-f75b-46a2-97d6-24f6e2da7abd@mailbox.org \
--to=torvic9@mailbox.org \
--cc=arnd@kernel.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®