Skip to content

Instantly share code, notes, and snippets.

@pbosetti
Last active May 28, 2024 11:36
Show Gist options
  • Save pbosetti/1792b53086a1852b535151256e71fcff to your computer and use it in GitHub Desktop.
Save pbosetti/1792b53086a1852b535151256e71fcff to your computer and use it in GitHub Desktop.
Build RT linux kernel
KVER=6.5.2
RTVER=8
mkdir kernel && cd kernel
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-${KVER}.tar.gz
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.5/patch-${KVER}-rt${RTVER}.patch.gz
tar xzf linux-${KVER}.tar.gz
cd linux-${KVER}
gzip -cd ../patch-${KVER}-rt${RTVER}.patch.gz|patch -p1
cp -v /boot/config-$(uname -r) .config
yes '' | make oldconfig
make menuconfig

and set the following:

# Enable CONFIG_PREEMPT_RT
 -> General Setup
  -> Preemption Model (Fully Preemptible Kernel (Real-Time))
   (X) Fully Preemptible Kernel (Real-Time)

# Enable CONFIG_HIGH_RES_TIMERS
 -> General setup
  -> Timers subsystem
   [*] High Resolution Timer Support

# Enable CONFIG_NO_HZ_FULL
 -> General setup
  -> Timers subsystem
   -> Timer tick handling (Full dynticks system (tickless))
    (X) Full dynticks system (tickless)

# Set CONFIG_HZ_1000 (note: this is no longer in the General Setup menu, go back twice)
 -> Processor type and features
  -> Timer frequency (1000 HZ)
   (X) 1000 HZ

# Set CPU_FREQ_DEFAULT_GOV_PERFORMANCE [=y]
 ->  Power management and ACPI options
  -> CPU Frequency scaling
   -> CPU Frequency scaling (CPU_FREQ [=y])
    -> Default CPUFreq governor (<choice> [=y])
     (X) performance

Save and Exit menuconfig, then disable kernel signing:

scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS

Finally, make then install generatd packages:

make -j8 bindeb-pkg
sudo dpkg -i ../*.deb

Then have a look at https://wiki.linuxfoundation.org/realtime/documentation/howto/applications/application_base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment