2016-12-19 17:09:53

by Gustavo da Silva

[permalink] [raw]
Subject: [RFC] arch/x86/Kconfig.cpu: Update with new gcc disponible 64bits CPU uarchs.

Good afternon!

Are there reasons to 'Kconfig.cpu' and 'Makefile' not contains the
'gcc -mtune=???'
recent options?

Well, bellow I send some diffs (untested) just for clarifications.

Best regards,

Gustavo da Silva.

====================

--- old/arch/x86/Kconfig.cpu
+++ new/arch/x86/Kconfig.cpu
@@ -45,6 +45,14 @@
- "Core 2/newer Xeon" for all core2 and newer Intel CPUs.
- "Intel Atom" for the Atom-microarchitecture CPUs.
- "Generic-x86-64" for a kernel which runs on any x86-64 CPU.
+ - "Intel Nehalem" for the Nehalem-microarchitecture CPUs.
+ - "Intel Westmere" for the Westmere-microarchitecture CPUs.
+ - "Intel Sandy Bridge" for the Sandy Bridge-microarchitecture CPUs.
+ - "Intel Ivy Bridge" for the Ivy Bridge-microarchitecture CPUs.
+ - "Intel Haswell" for the Haswell-microarchitecture CPUs.
+ - "Intel Broadwell" for the Broadwell-microarchitecture CPUs.
+ - "Intel Skylake" for the Skylake-microarchitecture CPUs.
+ - "Intel Knight's Landing" for the Knight's Landing-microarchitecture CPUs.

See each option's help text for additional details. If you don't know
what to do, choose "486".
@@ -279,6 +287,62 @@
accordingly optimized code. Use a recent GCC with specific Atom
support in order to fully benefit from selecting this option.

+config MNEHALEM
+ bool "Intel Nehalem"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Nehalem-microarchitecture based CPUs.
+
+config MWESTMERE
+ bool "Intel Westmere"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Westmere-microarchitecture based CPUs.
+
+config MSANDYBRIDGE
+ bool "Intel Sandy Bridge"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Sandy Bridge-microarchitecture based CPUs.
+
+config MIVYBRIDGE
+ bool "Intel Ivy Bridge"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Ivy Bridge-microarchitecture based CPUs.
+
+config MHASWELL
+ bool "Intel Haswell"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Haswell-microarchitecture based CPUs.
+
+config MBROADWELL
+ bool "Intel Broadwell"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Broadwell-microarchitecture based CPUs.
+
+config MSKYLAKE
+ bool "Intel Skylake"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Skylake-microarchitecture based CPUs.
+
+config MKNL
+ bool "Intel Knight's Landing"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Knight's Landing-microarchitecture based CPUs.
+
config GENERIC_CPU
bool "Generic-x86-64"
depends on X86_64

====================

--- old/arch/x86/Makefile
+++ new/arch/x86/Makefile
@@ -103,15 +103,8 @@
# Use -mskip-rax-setup if supported.
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

- # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
- cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
- cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
-
- cflags-$(CONFIG_MCORE2) += \
- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
+ # CPU-specific tuning. Anything which can be shared with UML
should go here.
+ include arch/x86/Makefile_64.cpu
KBUILD_CFLAGS += $(cflags-y)

KBUILD_CFLAGS += -mno-red-zone

====================

NEW FILE: new/arch/x86/Makefile_64.cpu

# CPU tuning section - shared with UML.
# Must change only cflags-y (or [yn]), not CFLAGS! That makes a
difference for UML.

#-mtune exists since gcc 3.4
HAS_MTUNE := $(call cc-option-yn, -mtune=i386)
ifeq ($(HAS_MTUNE),y)
tune = $(call cc-option,-mtune=$(1),$(2))
else
tune = $(call cc-option,-mcpu=$(1),$(2))
endif

align := $(cc-option-align)

cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
cflags-$(CONFIG_MCORE2) += $(call cc-option,-march=core2,$(call
cc-option,-mtune=generic))
cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
cflags-$(CONFIG_MNEHALEM) += $(call
cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
cflags-$(CONFIG_MWESTMERE) += $(call
cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
cflags-$(CONFIG_MSANDYBRIDGE) += $(call
cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
cflags-$(CONFIG_MIVYBRIDGE) += $(call
cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
cflags-$(CONFIG_MHASWELL) += $(call
cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
cflags-$(CONFIG_MBROADWELL) += $(call
cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
cflags-$(CONFIG_MSKYLAKE) += $(call
cc-option,-march=skylake,$(call cc-option,-mtune=skylake))
cflags-$(CONFIG_MKNL) += $(call cc-option,-march=knl,$(call
cc-option,-mtune=knl))
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)

--
Atenciosamente,

Gustavo da Silva
[email protected]


2016-12-19 17:31:29

by Borislav Petkov

[permalink] [raw]
Subject: Re: [RFC] arch/x86/Kconfig.cpu: Update with new gcc disponible 64bits CPU uarchs.

On Mon, Dec 19, 2016 at 03:09:50PM -0200, Gustavo da Silva wrote:
> Good afternon!
>
> Are there reasons to 'Kconfig.cpu' and 'Makefile' not contains the
> 'gcc -mtune=???'
> recent options?

This keeps popping up every couple of months. I was wondering when it is
going to appear again and there you are. :)

Here's a major reason: 99% of the kernels are built with
-m(arch|tune)=generic. Think distros.

Also, I am still waiting for a proof that CPU-optimized kernels have any
advantages compared to the =generic ones.

HTH.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

2016-12-19 17:46:34

by Gustavo da Silva

[permalink] [raw]
Subject: Re: [RFC] arch/x86/Kconfig.cpu: Update with new gcc disponible 64bits CPU uarchs.

hehehe

Thanks, Petkov!

Instead distros, I was thinking in HPC vendors, (SGI, etc), where
those can ship an optmized kernel compiled to the target CPU inside
the HPC equipment, resulting in a better product.

Well, I've reading a HPC equipment vendor documentation explaining
that warrant will be lost if
user compile&install a new kernel for that equipment.

So, make sense the HPC vendor ships a optimized kernel for target HPC customer.

About the proof, HPC vendors would give us an answer.

:)



2016-12-19 15:31 GMT-02:00 Borislav Petkov <[email protected]>:
> On Mon, Dec 19, 2016 at 03:09:50PM -0200, Gustavo da Silva wrote:
>> Good afternon!
>>
>> Are there reasons to 'Kconfig.cpu' and 'Makefile' not contains the
>> 'gcc -mtune=???'
>> recent options?
>
> This keeps popping up every couple of months. I was wondering when it is
> going to appear again and there you are. :)
>
> Here's a major reason: 99% of the kernels are built with
> -m(arch|tune)=generic. Think distros.
>
> Also, I am still waiting for a proof that CPU-optimized kernels have any
> advantages compared to the =generic ones.
>
> HTH.
>
> --
> Regards/Gruss,
> Boris.
>
> Good mailing practices for 400: avoid top-posting and trim the reply.



--
Atenciosamente,

Gustavo da Silva
[email protected]