That’s cool, in order to use this would I have to compile a kernel myself or could I set this in my distribution somewhere?
Linux
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Yes, to use the CONFIG_X86_NATIVE_CPU option, you will need to compile the kernel yourself with this option enabled. This is a compile-time setting that affects how the compiler optimizes the build specifically for your system. Prebuilt kernels from distro repositories usually do not have this enabled, since they are built for broad compatibility with many different processors.
I‘m assuming if I want updates I’d need to create my own repository?
Creating a repository is not absolutely necessary, but it will make the process of updating the kernel much easier in the future. If you plan to frequently update the kernel with custom settings, creating a repository is a smart choice. If you update the kernel very rarely, you can get by with manual compilation.
Yes, most likely need to compile it yourself. Or the distros would need a v1,v2,v3,v4 version. Also you need to know the feature set of you cpu. Distros will probably compile with the lowest common denominator, since those are compatible largest range of cpu's. Cachyos does compile it's packages for v3 optimization, I don't think that needs avx512. So can definitely see some distros trying something out.
I thought the whole point of this setting is not having to specify the features of the CPU. You can compile native versions now if you set things yourself.
Yes it is that, on gentoo I had set it like that for a while. Before I specified it to be sure. I Thought linus, didn't want to have this.
Great picture BTW.
Uh, so what's going on here?
This is a compile-time option that will tell the compiler to optimize for the CPU in your computer, rather than any CPU.
By default, the x86_64 kernel will build itself so that it can boot and run on any 64-bit Intel or AMD processor. This means it may have to ignore or check for newer instruction sets like (let’s say, totally at random) AVX512:
if (CPU supports AVX512)
do_efficient_avx512_thing (a, b, c)
else
a = something()
b = some_nonavx512_prep_work()
c = some_other_old_way_of_doing_things()
do_nonavx512_thing (a, b, c)
So, if you have an AVX512-capable CPU, it still has to check before using that instruction. Plus, your compiled kernel will be slightly larger because it needs to contain both ways of doing the thing.
Using this option tells the compiler to compile code optimized for your current processor:
do_efficient_avx512_thing (a, b, c)
This is a gross oversimplication. The compiler will also take things into consideration such as instruction sets, scheduling, core and thread counts, big and small cores, and more.
But the tl;dr is that optimized code is smaller, faster, and maybe a teensy bit more power efficient.
The downside? If you try to boot this optimized code on an older CPU (or rarely, a newer CPU), it will eventually say “illegal instruction” and crash.
This sounds nice but compiling the kernel takes a while on my machine. Whenever I try these custom kernels/config options I end up going back to the regular out of sheer lazyness :p
Any achievement requires sacrifice
...and????
End