Compiling optimized kernel

Hi,

I have been searching the web about compiling FreeBSD kernel with optimized compiler flags and for Intel SSE2, but coulnd't find any relevant information; seems like make script uses -mno-sse2. I would also like to use a newer compiler, gcc45, if possible. I would like to compile this kernel only for my computer. That aside, I am not sure whether SSE2 kernel outperforms a non-sse2 kernel dramatically and how much CPU time does kernel use, compared to user apps. But I think my wish still is relevant.

I would be very happy to know whether what I wish is possible. Is it possible to alter compiler flags for kernel compilation, at least parts of kernel compilation? Does it lead to weird things, if not crashes?

Regards,
Jason
 
killasmurf86; no offense, but I asked a question whether it's possible to optimize the kernel, and not an inquiry whether there is any benefit. It may as well be my own pleasure as well.

I do not think kernel is the culprit, as mentioned before. I believe it's mostly KDE, may be xorg, and other apps that may not be efficient. I also observed too high interrupts, particularly when I run Eclipse (I have to use Java at job, though I am doing C++). This suggests may be I should try polling option (or something else? got suggestions?). I couldn't find connection between interrupts and JVM, though. As far as I can see, disk access is somewhat slower than my colleagues' machines running Linux. We all use same hardware and almost the same environment. However, most of those guys use Ubuntu, running Gnome. I, too, have Gnome but I prefer KDE for historic reasons. Nevertheless, while I haven't read kernel source code, it probably does not perform computationally intensive operations, in particular with floating point types, therefore SIMD optimization may not give anything at all. So, answer to your question; no, I do not expect anything from SIMD, but may be something from -O3 of gcc. SIMD may be useful in sound card driver, which may do some floating point math.

I want my machine to perform optimum. I have selected optimized cflags for as many apps as possible and also set environment variable CFLAGS (though I am not sure whether it's overridden by make) to get optimized binaries.

danger; I've made a fresh install on Friday and currently making packages of my currently installed ports. As soon as they are done, I will give it a shot. Thanks for the documentation.

Is there a particular reason why it may not boot, if it compiles? Is it because compiler generates wrong code?

I am following C++0x drafts and discussions, and keeping my gcc45 up to date. I may not use this version since it isn't stable yet. But I want to try -O3.

Thank you both for help!
Regards,
Jason
 
bumperman said:
Is there a particular reason why it may not boot, if it compiles?
Because in the process of making the optimal configuration and excluding useless devices, you may - by accident or lack of knowledge - disable one device that is required by other devices to function properly (or even boot the system), or include the wrong CPU architecture, for instance.
But you can always unload the bad kernel and boot from a backup...
 
I have no intention to remove drivers (yet). My last kernel compilation was with 4.7, IIRC. I will stick to GENERIC kernel - no addition or removal - but I want to modify optimization flags, if possible... We will see the result within this week.

Thanks for heads up; I will pay extra attention to drivers I modify.
 
Just FYI, there's a nextboot command that will tell FreeBSD to load your new kernel for only the next boot. If it fails, simply reboot and your original kernel starts back up. If it works, you can then make it permanent.
 
Back
Top