Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Patching gentoo-sources with RT patch
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6656
Location: The soundosphere

PostPosted: Wed Feb 21, 2024 5:11 pm    Post subject: Patching gentoo-sources with RT patch Reply with quote

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/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.
_________________
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
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1901

PostPosted: Wed Feb 21, 2024 5:40 pm    Post subject: Re: Patching gentoo-sources with RT patch Reply with quote

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.
Back to top
View user's profile Send private message
Suicidal
l33t
l33t


Joined: 30 Jul 2003
Posts: 959
Location: /dev/null

PostPosted: Thu Feb 22, 2024 2:04 pm    Post subject: Re: Patching gentoo-sources with RT patch Reply with quote

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.
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6656
Location: The soundosphere

PostPosted: Mon Mar 11, 2024 5:11 pm    Post subject: Re: Patching gentoo-sources with RT patch Reply with quote

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
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Mon Mar 11, 2024 6:05 pm    Post subject: Re: Patching gentoo-sources with RT patch Reply with quote

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:
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. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Mon Mar 11, 2024 6:11 pm    Post subject: Reply with quote

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. "
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6656
Location: The soundosphere

PostPosted: Mon Mar 11, 2024 9:35 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Mon Mar 11, 2024 9:46 pm    Post subject: Reply with quote

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. "
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3408

PostPosted: Mon Mar 11, 2024 11:52 pm    Post subject: Reply with quote

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 Computing Fun Again
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Tue Mar 12, 2024 10:45 am    Post subject: Reply with quote

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. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Sat Apr 06, 2024 5:48 pm    Post subject: Reply with quote

Code:
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. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Mon May 13, 2024 4:32 pm    Post subject: Reply with quote

Current failure with latest
Code:
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. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Mon May 13, 2024 5:45 pm    Post subject: Reply with quote

Removal of section
Code:
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. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Wed May 15, 2024 4:29 pm    Post subject: Reply with quote

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. "
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6656
Location: The soundosphere

PostPosted: Sat Jun 08, 2024 7:13 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3839

PostPosted: Sat Jun 08, 2024 8:50 pm    Post subject: Reply with quote

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. "
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum