Skip to content

Commit

Permalink
x86/kconfig: Enable additional cpu optimizations for gcc v11.0+ kerne…
Browse files Browse the repository at this point in the history
…l v5.8+

WARNING
This patch works with gcc versions 11.0+ and with kernel version 5.8+ and should
NOT be applied when compiling on older versions of gcc due to key name changes
of the march flags introduced with the version 4.9 release of gcc.[1]

Use the older version of this patch hosted on the same github for older
versions of gcc.

FEATURES
This patch adds additional CPU options to the Linux kernel accessible under:
 Processor type and features  --->
  Processor family --->

The expanded microarchitectures include:
* AMD Improved K8-family
* AMD K10-family
* AMD Family 10h (Barcelona)
* AMD Family 14h (Bobcat)
* AMD Family 16h (Jaguar)
* AMD Family 15h (Bulldozer)
* AMD Family 15h (Piledriver)
* AMD Family 15h (Steamroller)
* AMD Family 15h (Excavator)
* AMD Family 17h (Zen)
* AMD Family 17h (Zen 2)
* AMD Family 17h (Zen 3)
* Intel Silvermont low-power processors
* Intel Goldmont low-power processors (Apollo Lake and Denverton)
* Intel Goldmont Plus low-power processors (Gemini Lake)
* Intel 1st Gen Core i3/i5/i7 (Nehalem)
* Intel 1.5 Gen Core i3/i5/i7 (Westmere)
* Intel 2nd Gen Core i3/i5/i7 (Sandybridge)
* Intel 3rd Gen Core i3/i5/i7 (Ivybridge)
* Intel 4th Gen Core i3/i5/i7 (Haswell)
* Intel 5th Gen Core i3/i5/i7 (Broadwell)
* Intel 6th Gen Core i3/i5/i7 (Skylake)
* Intel 6th Gen Core i7/i9 (Skylake X)
* Intel 8th Gen Core i3/i5/i7 (Cannon Lake)
* Intel 10th Gen Core i7/i9 (Ice Lake)
* Intel Xeon (Cascade Lake)
* Intel Xeon (Cooper Lake)
* Intel 3rd Gen 10nm++  i3/i5/i7/i9-family (Tiger Lake)

It also offers to compile passing the 'native' option which, "selects the CPU
to generate code for at compilation time by determining the processor type of
the compiling machine. Using -march=native enables all instruction subsets
supported by the local machine and will produce code optimized for the local
machine under the constraints of the selected instruction set."[2]

Do NOT try using the 'native' option on AMD Piledriver, Steamroller, or
Excavator CPUs (-march=bdver{2,3,4} flag). The build will error out due the
kernel's objtool issue with these.[3a,b]

MINOR NOTES
This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
changes. Note that upstream is using the deprecated 'match=atom' flags when I
believe it should use the newer 'march=bonnell' flag for atom processors.[4]

It is not recommended to compile on Atom-CPUs with the 'native' option.[5] The
recommendation is to use the 'atom' option instead.

BENEFITS
Small but real speed increases are measurable using a make endpoint comparing
a generic kernel to one built with one of the respective microarchs.

See the following experimental evidence supporting this statement:
https://github.com/graysky2/kernel_gcc_patch

REQUIREMENTS
linux version >=5.8
gcc version >=11.0

ACKNOWLEDGMENTS
This patch builds on the seminal work by Jeroen.[6]

REFERENCES
1.  https://gcc.gnu.org/gcc-4.9/changes.html
2.  https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
3a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95671#c11
3b. https://github.com/graysky2/kernel_gcc_patch/issues/55
4.  https://bugzilla.kernel.org/show_bug.cgi?id=77461
5.  https://github.com/graysky2/kernel_gcc_patch/issues/15
6.  http://www.linuxforge.net/docs/linux/linux-gcc.php
  • Loading branch information
graysky2 authored and xanmod committed Feb 15, 2021
1 parent 4ce6b24 commit 9971c77
Show file tree
Hide file tree
Showing 4 changed files with 418 additions and 35 deletions.

0 comments on commit 9971c77

Please sign in to comment.