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.
  1. 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:
    1. Emerge the sources
    2. eselect the version
    3. make sure /boot is mounted
    4. genkernel all
    5. grub-mkconfig
  2. 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)
  3. eselect kernel list
  4. eselect kernel set (number corresponding to linux-6.6.15-gentoo)
  5. cd /usr/src/linux
  6. cp .config .config-working (or whatever identifier you prefer)
  7. wget https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6.15-rt22.patch.xz
  8. xzcat patch-6.6.15-rt22.patch.xz | patch -p1
  9. genkernel –menuconfig all
  10. Select General setup —> Configure standard kernel features (expert users)
  11. Select General setup —> Preemption Model (Fully Preemptible Kernel (Real Time))
  12. Deselect Mitigations for speculative execution vulnerabilities
  13. Select Power management and ACPI options —> CPU Frequency scaling —> Default CPUFreq governor (performance)
  14. Any other kernel config options you need, if you know you need them.
  15. 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.
  16. grub-mkconfig -o /boot/grub/grub.cfg
  17. Reboot
  18. Test by running Cadence or similar software that identifies your system’s RT status.