Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Patching gentoo-sources with RT patch

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
16 posts • Page 1 of 1
Author
Message
audiodef
Watchman
Watchman
User avatar
Posts: 6656
Joined: Wed Jul 06, 2005 1:02 pm
Location: The soundosphere
Contact:
Contact audiodef
Website

Patching gentoo-sources with RT patch

  • Quote

Post by audiodef » Wed Feb 21, 2024 5:11 pm

I went looking for info about patching gentoo-sources with the RT patch, and found exactly what I was looking for. I prefer a step-by-step guide, so I wrote one of my own. Hope it's useful.

(Why? Well, it made sense to me to want a kernel patched with Gentoo patches and the RT patch. Why does it have to be either a Gentoo-patched kernel or a vanilla kernel patched with RT? Turns out it was a pretty simple thing to do.)

----------------------------------

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:

a. Emerge the sources
b. eselect the version
c. make sure /boot is mounted
d. genkernel all
e. grub-mkconfig
f. 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).

2. 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 ... 2.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.
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Top
grknight
Retired Dev
Retired Dev
Posts: 2568
Joined: Fri Feb 20, 2015 9:36 pm

Re: Patching gentoo-sources with RT patch

  • Quote

Post by grknight » Wed Feb 21, 2024 5:40 pm

audiodef wrote:8. xzcat patch-6.6.15-rt22.patch.xz | patch -p1
Why not just unpack this to /etc/portage/patches/sys-kernel/gentoo-sources-6.6.15/ ? Then it gets auto-applied during emerge.
Top
Suicidal
l33t
l33t
User avatar
Posts: 959
Joined: Wed Jul 30, 2003 4:55 am
Location: /dev/null

Re: Patching gentoo-sources with RT patch

  • Quote

Post by Suicidal » Thu Feb 22, 2024 2:04 pm

grknight wrote:
audiodef wrote:8. xzcat patch-6.6.15-rt22.patch.xz | patch -p1
Why not just unpack this to /etc/portage/patches/sys-kernel/gentoo-sources-6.6.15/ ? Then it gets auto-applied during emerge.
The rt patchset seems to have over 100 patches. From a manageability perspective, it seems like dropping genpatches into /etc/portage/patches/sys-kernel/gentoo-sources-6.6.15/ would be less work if someting goes sideways. I do this with the experimental genpatches on gentoo-kernel.
Top
audiodef
Watchman
Watchman
User avatar
Posts: 6656
Joined: Wed Jul 06, 2005 1:02 pm
Location: The soundosphere
Contact:
Contact audiodef
Website

Re: Patching gentoo-sources with RT patch

  • Quote

Post by audiodef » Mon Mar 11, 2024 5:11 pm

grknight wrote:
audiodef wrote:8. xzcat patch-6.6.15-rt22.patch.xz | patch -p1
Why not just unpack this to /etc/portage/patches/sys-kernel/gentoo-sources-6.6.15/ ? Then it gets auto-applied during emerge.
This is much better idea. Thanks.
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

Re: Patching gentoo-sources with RT patch

  • Quote

Post by CaptainBlood » Mon Mar 11, 2024 6:05 pm

audiodef wrote: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.
Almost.
A specific patch may work with later kernel minor version:

Code: Select all

patch-6.7.1-r1-rc5-rt5.patch.xz -> patch-6.7-rc5-rt5.patch.xz
did work for sys-kernel/gentoo-sources-6.7.1-r1.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Mon Mar 11, 2024 6:11 pm

Using patch-xxxxx here too instead of patches-xxxxx.
I've never understood how to work with patches-xxxxx, which failed when applied in a straight forward way.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
audiodef
Watchman
Watchman
User avatar
Posts: 6656
Joined: Wed Jul 06, 2005 1:02 pm
Location: The soundosphere
Contact:
Contact audiodef
Website

  • Quote

Post by audiodef » Mon Mar 11, 2024 9:35 pm

I tried patches myself, and I suspect all of the patches need to be directly in /etc/portage/patches/sys-kernel/gentoo-sources-x.y.z/ instead of in a subdir called "patches", which is what you get when you unpack the patches archive.
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Mon Mar 11, 2024 9:46 pm

Do you have any idea of an advantage of patches-xxxx over patch-xxxx, as patches is much bigger, iirc?

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Mon Mar 11, 2024 11:52 pm

Bonus point, if you omit version number in the directory name, emerge will attempt to apply those patches to all versions of the package (gentoo-sources in this case).
Obviously, this may or may not result in conflicts, but it is a nice feature when it works.
Make Pipewire a system service
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Tue Mar 12, 2024 10:45 am

szatox wrote:Bonus point, if you omit version number in the directory name, emerge will attempt to apply those patches to all versions of the package (gentoo-sources in this case).
Obviously, this may or may not result in conflicts, but it is a nice feature when it works.
As far as patch-xxxxx is concerned I'd mostly expect failures when versionning doesn't match.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Sat Apr 06, 2024 5:48 pm

Code: Select all

patch-6.8.4-rt11.patch.xz -> patch-6.8.2-rt11.patch.xz
builds fine here.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Mon May 13, 2024 4:32 pm

Current failure with latest

Code: Select all

amd64 /usr/src/linux-6.9.0-gentoo # xzcat /usr/local/share/kernel/patches/rt/patch-6.9.0-rc6-rt4.patch.xz | patch --dry-run -p1
checking file Documentation/admin-guide/kernel-parameters.txt
Hunk #1 succeeded at 6552 (offset 1 line).
checking file arch/arm/Kconfig
checking file arch/arm/mm/fault.c
checking file arch/arm/vfp/vfpmodule.c
checking file arch/arm64/Kconfig
checking file arch/powerpc/Kconfig
checking file arch/powerpc/include/asm/stackprotector.h
checking file arch/powerpc/kernel/traps.c
checking file arch/powerpc/kvm/Kconfig
checking file arch/powerpc/platforms/pseries/Kconfig
checking file arch/powerpc/platforms/pseries/iommu.c
checking file arch/riscv/Kconfig
checking file arch/riscv/include/asm/thread_info.h
checking file arch/x86/Kconfig
checking file arch/x86/include/asm/thread_info.h
checking file drivers/acpi/processor_idle.c
checking file drivers/block/zram/zram_drv.c
checking file drivers/block/zram/zram_drv.h
checking file drivers/gpu/drm/i915/Kconfig
checking file drivers/gpu/drm/i915/display/intel_crtc.c
checking file drivers/gpu/drm/i915/display/intel_display_trace.h
checking file drivers/gpu/drm/i915/display/intel_vblank.c
checking file drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
checking file drivers/gpu/drm/i915/gt/intel_execlists_submission.c
checking file drivers/gpu/drm/i915/gt/uc/intel_guc.h
checking file drivers/gpu/drm/i915/i915_request.c
checking file drivers/gpu/drm/i915/i915_trace.h
checking file drivers/gpu/drm/i915/i915_utils.h
checking file drivers/gpu/drm/ttm/tests/ttm_bo_test.c
checking file drivers/net/ethernet/chelsio/cxgb4/sge.c
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] y
Hunk #1 FAILED at 2670.
Hunk #2 FAILED at 2710.
2 out of 2 hunks FAILED
checking file drivers/tty/serial/8250/8250_core.c
checking file drivers/tty/serial/8250/8250_port.c
checking file drivers/tty/serial/amba-pl011.c
checking file drivers/tty/serial/serial_core.c
checking file drivers/tty/tty_io.c
checking file fs/proc/consoles.c
checking file include/linux/bottom_half.h
checking file include/linux/console.h
checking file include/linux/entry-common.h
checking file include/linux/entry-kvm.h
checking file include/linux/interrupt.h
checking file include/linux/netdevice.h
checking file include/linux/perf_event.h
checking file include/linux/printk.h
checking file include/linux/sched.h
checking file include/linux/sched/idle.h
checking file include/linux/serial_8250.h
checking file include/linux/serial_core.h
checking file include/linux/thread_info.h
checking file include/linux/trace_events.h
checking file kernel/Kconfig.preempt
checking file kernel/entry/common.c
checking file kernel/entry/kvm.c
checking file kernel/events/core.c
checking file kernel/ksysfs.c
checking file kernel/locking/lockdep.c
checking file kernel/panic.c
checking file kernel/printk/internal.h
checking file kernel/printk/nbcon.c
checking file kernel/printk/printk.c
checking file kernel/printk/printk_ringbuffer.h
checking file kernel/printk/printk_safe.c
checking file kernel/rcu/rcutorture.c
checking file kernel/rcu/tree_exp.h
checking file kernel/rcu/tree_stall.h
checking file kernel/sched/core.c
checking file kernel/sched/debug.c
checking file kernel/sched/fair.c
checking file kernel/sched/features.h
checking file kernel/sched/idle.c
checking file kernel/sched/rt.c
checking file kernel/sched/sched.h
checking file kernel/softirq.c
Hunk #2 succeeded at 637 (offset 4 lines).
Hunk #3 succeeded at 667 (offset 4 lines).
Hunk #4 succeeded at 1007 (offset 4 lines).
checking file kernel/time/hrtimer.c
checking file kernel/time/tick-sched.c
checking file kernel/time/timer.c
checking file kernel/trace/trace.c
checking file kernel/trace/trace_output.c
checking file localversion-rt
checking file net/core/dev.c
checking file net/core/skbuff.c
Hunk #1 succeeded at 7050 (offset 11 lines).
Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Mon May 13, 2024 5:45 pm

Removal of section

Code: Select all

drivers/net/ethernet/chelsio/cxgb4/sge.c
from the patch file builds and boots fine here, as expected.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Wed May 15, 2024 4:29 pm

Updated source builds fine here.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
audiodef
Watchman
Watchman
User avatar
Posts: 6656
Joined: Wed Jul 06, 2005 1:02 pm
Location: The soundosphere
Contact:
Contact audiodef
Website

  • Quote

Post by audiodef » Sat Jun 08, 2024 7:13 pm

Thanks for the info. I was looking at 6.9 and wondering if it would work out.
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Sat Jun 08, 2024 8:50 pm

vmlinuz-6.9.1-gentoo-rt here,

doesn't work on later version here.

Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
Post Reply

16 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic