Xanmod As a 3rd Party Option and The Pros and Cons

Hello all I am a linux veteran to some degree and I was an avid Linux Mandrake user way back when before they became Mandriva and I do like the direction that OpenMandriva has taken. I’ve been combing through this distro and thoroughly examining it to everything from stock cpu optimizations and compiler flags to how to further anonymize systemd while coming up with other ways to enhance real time audio performance, raise the gpu priority and nice levels, as well as tweaking kwin’s flags to make it more responsive, as well as zram optimizations and sysctl kernel optimizations for swappiness, the fs read / write and many other things, and with good results.

I am looking into the notion now of what would happen if a script existed which downloaded the OpenMandriva desktop kernel source as well as all depends, and then git cloned the Xanmod patches to build a custom kernel which is CLANG / LLVM just like OpenMandriva’s but with more optimizations for responsivenes and speed. For one the Xanmod kernel supports v2 and v3 out of the box by default and instead of using 1000hz ticks with preempt it uses 250hz but has its own custom timers which are faster than the default stock timers. I’ve compare this in Debian against liquorix before I left Debian and Xanmod was much more responsive. Why 250hz though ? Well, it does not ping the kernel every 1ms and bog it the cpu down as bad and the timers are more efficient. Instead it uses every 4ms to eliminate any bottlenecks providing a smoother response and smoother operation.

The takeaway here is that OpenMandriva is already built with CLANG / LLVM and the core libs have v2 and v3 compiled in. If your cpu has AVX and AVX2 ( and most do nowadays if they are 13 years old or newer ) then your cpu will support v2, v3, or posisbly v4 which Xanmod enables by default. My idea was to come up with a potental script which patches this in from git and builds the kernel, and then patches the latest CVE patches while using the OpenMandriva Kernel as the base source but adding in the other patches to enhance it. I do not think this should be stock but should be in a 3rd party repo option that can be checked and enabled or disabled as an option and should have prompts in the script to create a self updating cron job where the end user can choose how often they want it to check for updates for Xanmod and security patches.

It seems viable that for ROCK a LTS kernel base would be used and for ROME potentially the 7.x base by default but perhaps this could be a prompt in said script which asks which version and offers a choice based off of LTS or newer bleeding edge 7.x ?

These are just some ideas I had and wanted to offer the suggestion as many distros such as RHEL and Fedora. CachyOS already builds all of their packages with v2 and v3 baked in btw and propeller so they are already optimized. Perhaps that is even a future option for OpenMandriva as well ?

While OpenMandriva is already great, I did do the research earlier today and concluded that OpenMandriva with a Xanmod patched kernel and with prebuild v2 and v3 packages which are optimized would absolutely blow the doors off of Debian and many other distros potentially even CachyOS because their distro is not also built in CLANG / LLVM. This seems like the next logical optimization step for performance and for people who demand more out of their systems.

I can vouch that I did use Xanmod in Debian and in Devuan and loved Xanmod. The OpenMandriva kernel is already great but this would optimize it yet even further. I will also be looking into SELinux optimizations a bit more for kernel hardening. In Devuan I had Tomoyo, SELinux, and AppArmor all playing nice and working together perfectly but I realize that you really only need SELinux ( which OpenMandriva has already in audit / complain mode ) and SELinux is better than AppArmor in my honest opinion.

Here is an example snippet for the code idea I was looking into earlier regarding the script to compile Xanmod from git into the OpenMandriva kernel source as a 3rd party option.

[ #!/bin/bashset -e# --- Pre-flight: detect AND fix ---# CPU levelif g - Pastebin.com ]

You may or may not like the idea but the saying is that the squeaky wheel gets the grease, and so if nobody says anything it isn’t likely to happen and nothing will get done and so I am offering the idea here if anyone wants to look into it. I may mess with it on my own system but I will have to do more research.

This idea may or may not be well received but I thought it worth offering.

1 Like

When things in Cooker are perfect (hopefully), we do a “UM” that syncs the ROME repositories with the Cooker repositories. At that moment ROME is identical to Cooker. We try to do this on a regular basis.

Once in a while (after big changes), we do that and let everyone test ROME for a couple weeks. If everything works, we sync the ROCK repositories with the ROME repositories and that becomes the newest release of ROCK. It is just a snapshot of ROME. It does not get a special kernel or anything else. IF (that is a big if) you need an LTS kernel, we can certainly help you with the commands to make that happen. :grinning_face: However, we do backport security fixes to the standard kernel in ROCK and would not be pushing out those backported fixes to the non-standard LTS kernel.

Could the leadership here be convinced to switch the kernel to an LTS kernel after the snapshot and then only do backports for that one? I can’t answer that one.

1 Like

The problem you will run in to is that this is a very small, all part time, all volunteer, group. Finding someone that has the time to do this would be the problem. A community distribution of LInux is exactly what OMLx is.

What we need are more people doing things, we especially need more people with developing/coding knowledge.

This idea came to mind for me because I know there will be people who want to use the v2 and v3 features for the cpu in their kernel and from my own experience the Xanmod patches were pretty awesome. I did notice Rock has a 6.14.2 kernel and I had figured that it was because a certain version of the kernel may not have certain undesirable things in it and they built off of that kernel such as 6.12 updated to 6.14 with security patching. I do no know how to compile my own kernel of course and could manually get Xanmod’s stuff patched it or create a script which would take care of it but I just had this idea earlier because it may make for a way of keeping a Xanmod kernel variant updated and give the option to select or choose a specific version. I do know that some people have mentioned installing 7.x kernels in Rock and so it is possible I am sure but I love how stable Rock is which is why I would likely patch an LTS kernel with the Xanmod patches to obtain all of its optimizations as well as the OpenMandriva optimizations. If I could automate it then it would eliminate having to manually do it every time and would provide a method that just works and removes alot of hassle or anyone else who might want to use it. I created something like this in Salix 15 and also in regular Slackware and it git cloned, built, and installed the Xanmod kernel so I am thinking it would not be that much different. The only difference would be to add into the script the feature to create an rpm build and use the native tools to install it so that the package manager could track it. This would make for easier removal and installation.

These are just ideas of course.

Ok so this is something I managed to put together to use on my own system and it appears to be working. There will be more revisions and improvements to it. It is not finished yet as I am sure it can be improved upon but I am not typing this from a natively built CLANG / LLM Xanmod kernel with march=native and with v3 enabled and with the option to enable ThinLTO in the build. I used the .config that OpenMandriva used in the stock kernel but this script git clones the kernel source and builds a Xanmod kernel off of that and then has some other options as well which are available.

I personally like the audio and video performance and the schedulers in Xanmod and of course it is 250hz ticks but the schedulers handle the latency better than the stock kernel schedulers and 250hz ticks with this config does not bog the kernel down as badly so it makes for less bottlenecks and smoother functionality with lower latency. The fact that it is also natively a CLANG / LLVM kernel and can be built with ThinLTO also means that it is a perfect drop in replacement for the OM kernel for people who do gaming or want the Xanmod schedulers which in my opinion outperform the Liquorix kernel. I have not noticed anyone else in OpenMandriva using Xanmod yet so I created a way for it to be accomplished.

I named the script OMX-Kernel-Build-Script.sh on my system and ran it in the home folder but of course you can run it from anywhere you like. I did a chmod +x and ./OMX-Kernel-Build-Script.sh and it will do the rest. If you use -h it has the flags for running the script. Of course I claim no liability for this script but it is pretty safe. It builds an rpmbuild and makes for easy installation and easy removal using dnf. If it is something that interests you here it is. #!/usr/bin/env bash## omx-kernel v1.0.0# Free software under the GNU Gener - Pastebin.com <— this is the script I created to get Xanmod going in OpenMandriva. So far it is working well as I am using Xanmod right now while I am typing this.

I should add that you can get virtualbox modules to build with this but will have to use an older Xanmod 7.x kernel if you want the 7.x branch and want to use ROCK currently for that. There is the option to install the latest ROME version of Virtualbox 7.2 I suppose from ROME repos independently in ROCK and then the 7.2.x Xanmod kernel will build the modules for it. Xanmod 7.2 supports Virtualbox 7.1 but not the other way around is what the issue is and so the workaround is get the Oracle version directly from their website or install the ROME version perhaps if you want both in ROCK. In ROME this should not be an issue.

#!/usr/bin/env bash
set -euo pipefail
ulimit -s unlimited
free -h
cd ~

./OMX-Kernel-Build-Script.sh --cleanup

# True XanMod 7.x + ThinLTO; -y once is enough
# jobs 4 is OK in console if MemAvailable stays high; drop to 2 if clang dies
./OMX-Kernel-Build-Script.sh --xanmod-7 --force-thinlto --jobs 4 -y

# Hybrid alternative:
# ./OMX-Kernel-Build-Script.sh --hybrid --force-thinlto --jobs 4 -y

This may also be helpful to use with this script as well. I named it run-the-build.sh and did a chmod +x and just put it in the same folder as the OMX-Kernel_Build-Script.sh script and it will call the other script using whichever flags if you don’t want to type those flags out every time. It is a bit redundant but is a one and done command. I just edit it to use the right amount of parallel jobs and then whether to enable ThinLTO or not and you can uncomment hybrid mode in it if you want to test that. It isn’t necessary really if you are comfortable using the flags but it may be simpler for some people to use it this way. I started this thread out of curiosity as to whether it can be done and I am now using it, so that answered my question. :smile:

UPDATE : I am tweaking this script out a bit so I will upload the revised version when it builds a new kernel. The old one was using ld.bfd which is not LLVM it was using that with CLANG and I went back to change it to proper ld.lld instead. This is a reason why ld.bfd was not allowing ThinLTO to stick. Also 2 parallel jobs is a better default in graphical desktop for a build. The Polly option is disabled because it kept exiting with 134 code errors and I think maybe it could be related to ld.bfd being used before but I am not quite sure yet. I will keep everyone posted and clean up the post here a bit when I finish this compile. keeping fingers crossed I have the old script that compiled the xanmod kernel pre 1.0 as well still as a backup but the newer one also has rpmlint disabled because rpmlint was refusing to allow the build to finish during the package checking. It was giving a warning and not blocking it before but in the 1.0 revision it has been doing this so I disabled that feature for now until I sort that out, which I should get sorted out in the near future. When I finish this script I may also do one for liquorix and one for tkg as well to give people options. I could alternatively end up merging these into one script as well. The graphical manager that someone mentioned was a good idea. I am doing it this way to keep everything straight from git and so that nobody has to manage a new repo or new rpm’s. Just build them locally and it solves the issue of having to do all of that.

Here is an updated version of the OpenMandriva Xanmod Kernel Build Script OMX-Kernel-Build-Script.sh - Pastebin.com This is version 2.3.2

TMPDIR=$HOME/omx-tmp ./OMX-Kernel-Build-Script-2.3.sh --tag 7.1.13-xanmod1 \
  --force-thinlto --no-boot-hacks --jobs 2 -y

This is an example of how you would use the script.
The script has a patch or boot hack / workaround in it currently for a z offset issue which was stopping earlier builds but may not boot on some systems with it enabled.

" The NM swap affects how zoffset.h and voffset.h are computed, and the -T and kernel_info edits change how the compressed vmlinux is linked. If those offsets or the link are wrong, the usual result is a kernel that hangs right after the bootloader hands off, with nothing on screen." This is what Claude told me about it.

Disabling that option with the --no-boot-hacks flag may be helpful if the kernel is hanging and failing to boot the initial ramdisk. There is also a bisect option which strips all flags from the build and builds a generic Clang / LLVM kernel in case the user needs to debug or troubleshoot the build process.

I will try to use this same methodology to create a script for liquorix and one for tkg also.

The current version is now 2.4.2 and this command does build a working bfd linked xanmod kernel. I am typing this comment from that kernel right now TMPDIR=$HOME/omx-tmp ./OMX-Kernel-Build-Script-2.4.2.sh --tag 7.1.13-xanmod1 \ --v3 --native --use-bfd --no-thinlto --no-boot-hacks --jobs 4 -y stay posted because I am still testing this but if nothing else we have it working and I will be testing the native LLVM linker config flag next and if that works I will move forward with creating a ThinLTO version… and if that works then I am adding an autoFDO flag for autoFDO profile optimization. TMPDIR=$HOME/omx-tmp ./OMX-Kernel-Build-Script-2.4.2.sh --tag 7.1.13-xanmod1 \ --v3 --native --plain-lld --no-thinlto --no-boot-hacks --jobs 4 -y This is my next test. Here is where we are at currently with this


The Current version is 2.7.0 and omx-afdo-profile.sh - Pastebin.com is the link to the autoFDO helper script for Clang / LLVM ThinLTO builds of this kernel and the above script link is currently able to create a bootable Clang / LLVM Xanmod kernel using OpenMandriva’s native toolkit. This latest script makes it possible to tune the kernel with autoFDO and it is suggested to build the kernel first " TMPDIR=$HOME/omx-tmp ./OMX-Kernel-Build-Script-2.7.0.sh --tag 7.1.13-xanmod1
–force-thinlto --autofdo --no-boot-hacks --no-install --jobs 4 -y " and then run this when you are using your machine for daily usage when using your new Xanmod Clang / LLVM + ThinLTO kernel with autoFDO enabled " sudo bash omx-afdo-profile.sh record ~/rpmbuild/AFDO/vmlinux-7.1.13-xanmod1 ~/afdo/run1.afdo 300 "

Collecting the profile. The pass-1 build saves vmlinux to ~/rpmbuild/AFDO/vmlinux-7.1.13-xanmod1. After you boot the AutoFDO kernel, run this as root while you use the machine normally (browsing, compiling, video, whatever you do day to day.

It uses the Intel BR_INST_RETIRED.NEAR_TAKEN:k event from the kernel docs (and the AMD one on AMD CPUs). Run it a few times for different workloads and merge with merge. Then the second pass uses the same flags plus --afdo-profile ~/afdo/final.afdo. First verify LBR works on your CPU: perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -b -c 500009 -o /tmp/t.data -- sleep 3 should finish without an error. Also check command -v llvm-profgen llvm-profdata perf

There is still a bit more for me to do to this script as current revisions is 2.7.0 at the time of me writing this post but it is coming along. When I finish this I will work on versions of the same thing for liquorix and TKG with their schedulers and settings as well.

Update: the scripts have moved off Pastebin to a proper repo —
GitHub - ManOfMystery1981/omx-kernel-build: This repo is for a custom build script for building a finely tuned Xanmod Kernel for OpenMandriva · GitHub — now at v2.9.0.

Same build script + afdo profiler, plus a README covering the full 4-pass
AutoFDO/Propeller pipeline, and the llvm-propeller spec. The prebuilt
llvm-propeller RPM is attached to the propeller-rpm-v1 release there.

Still working toward liquorix/TKG variants next.


I definitely notice this being more snappy. I now am running a Xanmod 7.13.1 autoFDO propeller optimized Clang / LLVM ThinLTO kernel in OpenMandriva Rock Lx 6.0 with no issues. When Rock syncs and updates I will rebuild the same version of kernel from the tree that Rome uses so that I can build the virtualbox modules. This kernel probably would build the virtualbox modules but the current version of virtualbox in Rock 6.0 is incompatible with the newer kernel tree’s framework. It should be compatible immediately after the sync to Rock’s next version update. Also The llvm-propeller rpm which I’ve prebuilt and uploaded to my git repo is version 23 which is what Rome is using right now and what will be in Rock soon.

One issue I ran into in Rock building the kernel for propeller optimization was the g lines in the propeller profiles are not compatible with LLVM 19 so I had to strip them to get the kernel to build but other than that there was no difference and then it built just fine without any issues. The user will not have to use this workaround after the repos sync and Rock updates. LLVM 19 is doing the build with OM’s native LLVM while LLVM-Propeller 23 is creating the profiles. If anyone has any questions about getting this working, ask me and I should be able to assist. This is a 4 pass build which requires compiling 4 times. The first time is to get a ThinLTO native Clang / LLVM kernel which is autoFDO capable. The second time is to get the AutoFDO profile. The third time is to generate the propeller profiles. The 4th time is the final build with all optimizations. I am noticing the improvement for sure. It is suggested to use your system as you normally would and give the profile the difference between idling and a heavy heavy heavy workload that nearly crashes your system. I say that so that you have both extremes. You want a real profile and not a faked one. If you do this it creates an accurate map for your hardware to give the best mapping.

If you would like to know more about how the mapping works there are many resources out there on this but CachyOS is already doing this to their kernels and Fedora is about to. Many Distros are going this route. Now OpenMandriva has the capability to do it as well. I’ve given you the scripts and means to create the llvm-propeller rpm in ABF ( I tried but it was having connection problems ) and the script could be potentially used with ABF to generate x86-64-v3 kernels although they would not be propeller optimized so it would be necessary to do a two pass build perhaps and allow the user to run the autoFDO profile optimizations rebuild and the propeller optimization rebuild themselves on their own machine which is why I didn’t prepackage kernels. It is simpler to just grab the script and build your own kernel. The llvm-propeller rpm and the scripts are available in the repo however. Version 2.9.3 is the latest OMX-Kernel-Build-Script-2.9.3.sh I have also uploaded a omx-kernel-summary.sh in order to check your kernel flags and ensure that you have a kernel which is fully not only capable but fully tuned and optimized with these optimizations. Thank you all for your patience.

1 Like

I should update that I am having issues pushing the prebuild rpm to github but I have the spec file and abf.yml file in the github repo but it is not allowing me to upload the rpm archive or the llvm-propeller source, so for now here is another link to grab the rpm 36.59 MB file on MEGA let me know if this link expires or does not work and I will grab another upon request.

The spec file should be enough for anybody that wants to test your scripts to just rpmbuild llvm-propeller on their own system

Releases · ManOfMystery1981/omx-kernel-build · GitHub This will be useful. The sources are there as well although I may also include the xz archive also.

1 Like

I tried to do it with ABF but this happens after awhile