sys-kernel/gentoo-sources is a very nicely patched flavor of the vanilla Linux kernel. The Gentoo patch set contains bug and security fixes, as well as extras, including some extra hardware support and some feature patches. sys-kernel/rt-sources is a vanilla kernel patched with the RT patch. While trying to figure out what driver was missing from the genkernel default and causing the kernel to not find the root device on an MSI Pulse 15 laptop, I started thinking that while I was here, what if I applied the RT patch to gentoo-sources?
Turns out it’s pretty simple.
Exact versions must match. Check https://cdn.kernel.org/pub/linux/kernel/projects/rt/ and compare with eix gentoo-sources.
Example: As of 20 Feb 2024, there is both gentoo-sources-6.6.15 and patch-6.6.15-rt22.patch.xz.
Notes:
- Make sure your portage is up-to-date and your system has been depcleaned.
- rm -rf unused kernel dirs in /usr/src – but double check that they are unused (unmerged or depcleaned).
- rm .old stuff in /boot if not needed.
- First, make sure the unpatched kernel works on your computer. While it most likely will work with genkernel, this is not a 100% safe assumption. As a general reminder of procedures:
- Emerge the sources
- eselect the version
- make sure /boot is mounted
- genkernel all
- grub-mkconfig
- reboot. If it fails to find your root device, you either need to find which driver was not compiled in by default, and/or check to make sure nvme is compiled in, not compiled as module(s).
emerge =gentoo-sources-6.6.15 (no use flags enabled) - eselect kernel list
- eselect kernel set (number corresponding to linux-6.6.15-gentoo)
- cd /usr/src/linux
- cp .config .config-working (or whatever identifier you prefer)
- wget https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6.15-rt22.patch.xz
- xzcat patch-6.6.15-rt22.patch.xz | patch -p1
- genkernel –menuconfig all
- Select General setup —> Configure standard kernel features (expert users)
- Select General setup —> Preemption Model (Fully Preemptible Kernel (Real Time))
- Deselect Mitigations for speculative execution vulnerabilities
- Select Power management and ACPI options —> CPU Frequency scaling —> Default CPUFreq governor (performance)
- Any other kernel config options you need, if you know you need them.
- Exit out of menuconfig, chose Yes to save config, and let genkernel work. This will create new kernel images with “rt” in the filenames, so no need to worry about overwriting your working existing images.
- grub-mkconfig -o /boot/grub/grub.cfg
- Reboot
- Test by running Cadence or similar software that identifies your system’s RT status.