Patch Application
The first step of getting the PREEMPT_RT working with RISC-V architecture was to apply the official patch file to the mainline Linux kernel source tree. Usually, with correctly selected versions, this would be a very simple step of just using the patch command to apply a single patch file. However, in this case, there was a very specific version of the Linux kernel required to correctly support the StarFive JH-7110 DevKit. Now the StarFive JH-7110 DevKit Linux version is 5.15.0.
- 0001-patch-5.15-rt17.patch: This is the official real-time patch file provided
for Linux kernel v5.15.0, which contains real-time patch code in kernel that is unrelated
to the Linux kernel v5.15.0 architecture, as well as specific real-time patch code for
other architectures.For more information: https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.15/older/patch-5.15-rt17.patch.gzNote: Download kernel v6.6 patch from: This link.
- 0002-rt-for-dvk: There is an important configuration under RT Linux LAZY_
PREEMPT, which can improve the performance of non-RT workloads. Currently, RT Linux
does not support RISC-V architecture, but it can be achieved by referencing RT patches
from other architectures with this configuration. See LAZY_PREEMPT for more details. Note: 0002-rt-for-dvk contains the implementation of LAZY_PREEMPT and the modification of RT in Kconfig and starfive_jh7110_defconfig. In addition, this patch also disabled the CPU dynamic frequency policy to ensure real-time performance of the system.
After applying the 5.15.0 RT patch, apply the patches in Appendix A. These patches contain the LAZY_PREEMPT configuration for the RISC-V architecture and enable the PREEMPT_RT configuration for JH-7110 DevKit. Additionally, a modification has been made to the kernel/sched/cpupri.c file regarding task prioritization by patch: 0002-rt-for-dvk. This modification addresses an issue in the official RT patch where non-RT tasks would trigger a 'kernel panic' during a stress test. However, please note that this is a workaround.