Skip to content

Instantly share code, notes, and snippets.

@leifmadsen
Created October 23, 2018 20:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leifmadsen/5d1edc283e6d67083209bce5b59a6d90 to your computer and use it in GitHub Desktop.
Save leifmadsen/5d1edc283e6d67083209bce5b59a6d90 to your computer and use it in GitHub Desktop.
Building Realtime Kernel and Starling-X Patches

Building Realtime Kernel For CentOS

Notes below are steps I followed to build the realtime (RT) kernel for CentOS. Additional notes are included for patching and building the Starling-X changes against the CentOS realtime kernel.

Dependencies

You'll need a physical (or virtual) machine running CentOS 7.5. Others probably work but this is what I used.

  • mock
  • rpmbuild
  • git
  • patch
  • probably others...

Setup mockbuild User

ssh root@buildhost
adduser mockbuild
usermod -a -G mock mockbuild
yum install mock rpmbuild git patch -y
sudo su - mockbuild

Setup Tooling

git clone https://git.centos.org/git/centos-git-common.git
mkdir -p ~/.local/bin
ln -s ~/centos-git-common/get_sources.sh ~/.local/bin/
ln -s ~/centos-git-common/into_srpm.sh ~/.local/bin/
ln -s ~/centos-git-common/centos.git.repolist.py ~/.local/bin/
ln -s ~/centos-git-common/return_disttag.sh ~/.local/bin/
ln -s ~/centos-git-common/rpm-tree-prep.sh ~/.local/bin/
ln -s ~/centos-git-common/show_possible_srpms.sh ~/.local/bin/

Build Realtime Kernel (stock)

git clone https://git.centos.org/git/rpms/kernel-rt
cd kernel-rt/
git fetch --all
git checkout origin/c7-rt
git log    # note the commit hash for the version of the kernel you want
git checkout a7516c3fe0241f3d74efbf2bcedf267764c0c789
git checkout -b c7
get_sources.sh
into_srpm.sh
mock --root epel-7-x86_64 \
  --rebuild \
  --resultdir ./RPMS \
  --rootdir ~/builddir \
  SRPMS/kernel-rt-3.10.0-862.11.6.rt56.819.el7.src.rpm

Apply Starling-X Changes

git clone https://git.centos.org/git/rpms/kernel-rt kernel-rt-stx
cd kernel-rt-stx/
git fetch --all
git checkout origin/c7-rt
git checkout a7516c3fe0241f3d74efbf2bcedf267764c0c789
git checkout -b c7
get_sources.sh

cd ~
git clone https://github.com/openstack/stx-integ.git
cat stx-integ/kernel/kernel-rt/meta_patches/PATCH_ORDER
cd ~/kernel-rt-stx
patch -p1 < ~/stx-integ/kernel/kernel-rt/centos/meta_patches/Build-logic-and-sources-for-TiC.patch
patch -p1 < ~/stx-integ/kernel/kernel-rt/centos/meta_patches/Kernel-source-patches-for-TiC.patch
patch -p1 < ~/stx-integ/kernel/kernel-rt/centos/meta_patches/Compile-issues.patch
cp ~/stx-integ/kernel/kernel-rt/files/* ./SOURCES/
cp ~/stx-integ/kernel/kernel-rt/centos/patches/* ./SOURCES/

# then I needed to change ~/.local/bin/into_srpm.sh
# to add `--define "tis_patch_ver 43" to the `rpmbuild` command

into_srpm.sh
mock --root epel-7-x86_64 \
  --define "tis_patch_ver 43" \
  --rootdir=$HOME/builddir  \
  --rebuild \
  --resultdir ./RPMS \
  SRPMS/kernel-rt-3.10.0-862.11.6.rt56.819.el7.tis.43.src.rpm

Installing RT kernels

Boot up a CentOS 7.5 virtual machine (or physical host) and copy over the resulting RPMs from the ~/kernel-rt/RPMS/ and/or ~/kernel-rt-stx/RPMS/ directories to the testing machine.

Add the CentOS RT repository.

sudo tee /etc/yum.repos.d/CentOS-rt.repo >/dev/null <<EOF
[rt]
name=CentOS-7 - rt
baseurl=http://mirror.centos.org/centos/\$releasever/rt/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF

Then we need to downgrade tuned to version 2.8.0 as required by the kernel.

sudo yum downgrade --enablerepo=rt tuned-2.8.0-5.el7.noarch

At this point we can install the RT kernel and reboot. You won't be able to install everything at this point as you'll get conflicts. You likely only need the kernel anyways, but if you need the kernel-tools and other packages, you'll need to remove the conflicting kernel-tools from the non-RT kernel installed, and then add the RT kernel tools. I did this after rebooting into the RT kernel, but you can likely do this before rebooting as well.

sudo yum install --enablerepo=rt kernel-rt-3.10.0-862.11.6.rt56.819.el7.tis.43.x86_64.rpm
sudo yum install deltarpm
sudo systemctl reboot
sudo yum remove kernel-tools-libs-3.10.0-862.14.4.el7.x86_64 kernel-tools-3.10.0-862.14.4.el7.x86_64
sudo yum install --enablerepo=rt kernel-rt-stx/*.x86_64.rpm
sudo yum install --enablerepo=rt rt-tests

Running cyclictest

We can start running our tests now with cyclictest. The -l is a value is number of loops to run. I found that 10000 seemed to equate to roughly 10 seconds, so apply the value most appropriate.

sudo bash -c 'time cyclictest -t1 -p 99 -i 1000 -n -l 10000 -d 86400 -m -a 1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment