Originally posted by coder
View Post
Announcement
Collapse
No announcement yet.
Proposed: Allow Building The Linux Kernel With x86-64 Microarchitecture Feature Levels
Collapse
X
-
-
I don't know enough about kernel building or CPU instructions to say I know better, but wouldn't it make more sense for software to just simply be told at launch time what the available instructions are so it can take advantage of them if able? Build one version that is capable of taking advantage of all instructions the developer implemented, but it only uses what it actually can use. I feel like that's just a little too obvious though, where there's some major reason why that can't be done.
- Likes 1
Comment
-
Originally posted by schmidtbag View PostI don't know enough about kernel building or CPU instructions to say I know better, but wouldn't it make more sense for software to just simply be told at launch time what the available instructions are so it can take advantage of them if able? Build one version that is capable of taking advantage of all instructions the developer implemented, but it only uses what it actually can use. I feel like that's just a little too obvious though, where there's some major reason why that can't be done.
Comment
-
Originally posted by skeevy420 View Post
That's what HWCAPS and the different V levels are for. The problem with the kernel is...well...there really isn't, or, rather, won't be. They just need to add a function to the initrd to get the system's V level and then load the appropriate kernel. Distributions will basically have to build 4 kernels (one for each level since 1 is also generic) to make it fire and forget.
The kernel does have different setup code for different hardware, switched on automatically at runtime and can be disabled via cmdline.
Adding such a switch probably aren’t that difficult.
- Likes 1
Comment
-
Originally posted by coder View Post... benefits to using -march=native...
Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite
Was 2018.Last edited by elatllat; 18 August 2021, 10:17 AM.
- Likes 1
Comment
-
Originally posted by schmidtbag View PostI don't know enough about kernel building or CPU instructions to say I know better, but wouldn't it make more sense for software to just simply be told at launch time what the available instructions are so it can take advantage of them if able? Build one version that is capable of taking advantage of all instructions the developer implemented, but it only uses what it actually can use. I feel like that's just a little too obvious though, where there's some major reason why that can't be done.
Originally posted by discordian View Post
compile your kernel in the initrams and kexec the new build.
In a way, this is already done for 32bit ARM, which dont have mandatory integer division, and the kernel will detect if it is available and patch out any calls to the software fallback. This is still alot worse than compiling it with intdiv support, because the compiler will expect a function call and cant optimize around that.
- Likes 4
Comment
-
Originally posted by flower View PostWouldn't it be better to just enable or disable features like sse3 or avx?
Usually only very small parts do profit from such features anyway. Might be feasible to include normal and optimized versions in the same build
- Likes 1
Comment
-
Originally posted by sinepgib View PostThere's currently a mechanism in place to overwrite existing code on runtime. I don't remember the name, sadly. What currently happens is that, for some expensive instrumentation, you don't want an actual feature check, but instead you fill the place where the call would happen with enough nops to overwrite with the function call when you enable it. You can do the same for intdiv: just put in place enough bytes so you can fit either the intdiv or the function call, put the appropriate one on initialization and fill any remaining space with nops.
Its more than just a buncha-nops, any instruction can be instrumented/replaced. Which is particularly horrible on x86 as instruction lengths are variable and instruction potentially not aligned, means there are alot cases where in the first step an int3 instruction is replacing the first byte, then the remainder is patched, then the first byte is patched. and if the code is executed inbetween a interrupt handler is involved.
I had to disable this functionality on realtime applications for safe operation.
- Likes 5
Comment
Comment