From: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] x86/cpu: Add support for modern x86-64-v* march
Date: Fri, 7 Jul 2023 11:56:00 +0100 [thread overview]
Message-ID: <20230707105601.133221-1-dimitri.ledkov@canonical.com> (raw)
Add support for setting march to x86-64-v2, x86-64-v3, x86-64-v4 with
tuning set to an early family of CPUs that support such instruction
levels. By default gcc sets generic tuning for x86-64-v*, which is
suboptimal for all brands of CPUs with such instruction set support.
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
---
arch/x86/Kconfig.cpu | 23 ++++++++++++++++++++++-
arch/x86/Makefile | 11 +++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 00468adf18..70e70b4733 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -294,6 +294,27 @@ config GENERIC_CPU
Generic x86-64 CPU.
Run equally well on all x86-64 CPUs.
+config X86_64_V2
+ bool "x86-64-v2"
+ depends on X86_64
+ help
+ x86-64-v2 CPU.
+ Run well on x86-64-v2 capable CPUs.
+
+config X86_64_V3
+ bool "x86-64-v3"
+ depends on X86_64
+ help
+ x86-64-v3 CPU.
+ Run well on x86-64-v3 capable CPUs.
+
+config X86_64_V4
+ bool "x86-64-v4"
+ depends on X86_64
+ help
+ x86-64-v4 CPU.
+ Run well on x86-64-v4 capable CPUs.
+
endchoice
config X86_GENERIC
@@ -318,7 +339,7 @@ config X86_INTERNODE_CACHE_SHIFT
config X86_L1_CACHE_SHIFT
int
default "7" if MPENTIUM4 || MPSC
- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
+ default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU || X86_64_V2 || X86_64_V3 || X86_64_V4
default "4" if MELAN || M486SX || M486 || MGEODEGX1
default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index fdc2e3abd6..ee97501970 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -154,6 +154,14 @@ else
cflags-$(CONFIG_MCORE2) += -march=core2
cflags-$(CONFIG_MATOM) += -march=atom
cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic
+ # Note gcc for -march=x86-64-v* sets genetic tuning only,
+ # rather than something sensible / minimum tuning from the
+ # same family. Set mtune to early family of CPUs that support
+ # such instructions, which works better across all CPU brands.
+ cflags-$(CONFIG_X86_64_V2) += -march=x86-64-v2 -mtune=nehalem
+ cflags-$(CONFIG_X86_64_V3) += -march=x86-64-v3 -mtune=skylake
+ cflags-$(CONFIG_X86_64_V4) += -march=x86-64-v4 -mtune=skylake-avx512
+
KBUILD_CFLAGS += $(cflags-y)
rustflags-$(CONFIG_MK8) += -Ctarget-cpu=k8
@@ -161,6 +169,9 @@ else
rustflags-$(CONFIG_MCORE2) += -Ctarget-cpu=core2
rustflags-$(CONFIG_MATOM) += -Ctarget-cpu=atom
rustflags-$(CONFIG_GENERIC_CPU) += -Ztune-cpu=generic
+ rustflags-$(CONFIG_X86_64_V2) += -Ctarget-cpu=x86-64-v2
+ rustflags-$(CONFIG_X86_64_V3) += -Ctarget-cpu=x86-64-v3
+ rustflags-$(CONFIG_X86_64_V4) += -Ctarget-cpu=x86-64-v4
KBUILD_RUSTFLAGS += $(rustflags-y)
KBUILD_CFLAGS += -mno-red-zone
--
2.34.1
next reply other threads:[~2023-07-07 10:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 10:56 Dimitri John Ledkov [this message]
2023-07-07 11:28 ` Borislav Petkov
2023-07-07 11:46 ` Dimitri John Ledkov
2023-07-07 12:05 ` Borislav Petkov
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=20230707105601.133221-1-dimitri.ledkov@canonical.com \
--to=dimitri.ledkov@canonical.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--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®