Upreving Linux Kernel¶
Occasionally, the Gitlab CI needs a Linux Kernel update to enable new kernel features, device drivers, bug fixes etc to CI jobs. Kernel uprevs in Gitlab CI are relatively simple, but prone to lots of side-effects since many devices from different platforms are involved in the pipeline.
Kernel repository¶
The Linux Kernel used in the Gitlab CI is stored at the following repository: https://gitlab.freedesktop.org/gfx-ci/linux
It is common that Mesa kernel brings some patches that were not merged on the Linux mainline, that is why Mesa has its own kernel version which should be used as the base for newer kernels.
So, one should base the kernel uprev from the last tag used in the Mesa CI, please refer to .gitlab-ci.yml KERNEL_URL variable. Every tag has a standard naming: vX.YZ-for-mesa-ci-<commit_short_SHA>, which can be created via the command:
git tag vX.YZ-for-mesa-ci-$(git rev-parse --short HEAD)
Building Kernel¶
When Mesa CI generates a new rootfs image, the Linux Kernel is built based on the script located at .gitlab-ci/build-kernel.sh.
Updating Kconfigs¶
When a Kernel uprev happens, it is worth compiling and cross-compiling the Kernel locally, in order to update the Kconfigs accordingly. Remember that the resulting Kconfig is a merge between Mesa CI Kconfig and Linux tree defconfig made via merge_config.sh script located at Linux Kernel tree.
Kconfigs location¶
Platform |
Mesa CI Kconfig location |
Linux tree defconfig |
---|---|---|
arm |
.gitlab-ci/container/arm.config |
arch/arm/configs/multi_v7_defconfig |
arm64 |
.gitlab-ci/container/arm64.config |
arch/arm64/configs/defconfig |
x86-64 |
.gitlab-ci/container/x86_64.config |
arch/x86/configs/x86_64_defconfig |
Development routine¶
Compile the newer kernel locally for each platform.
Compile device trees for ARM platforms
Update Kconfigs. Are new Kconfigs necessary? Is CONFIG_XYZ_BLA deprecated? Does the merge_config.sh override an important config?
Push a new development branch to Kernel repository based on the latest kernel tag used in Gitlab CI
Hack build-kernel.sh script to clone kernel from your development branch
Update image tags. See Updating image tags
Run the entire CI pipeline, all the automatic jobs should be green. If some job is red or taking too long, you will need to investigate it and probably ask for help.
When the Kernel uprev is stable¶
Push a new tag to Mesa CI Kernel repository
Update KERNEL_URL debian/x86_test-gl job definition
Open a merge request, if it is not opened yet
Tips and Tricks¶
Compare pipelines¶
To have the most confidence that a kernel uprev does not break anything in Mesa, it is suggested that one runs the entire CI pipeline to check if the update affected the manual CI jobs.
Step-by-step¶
Create a local branch in the same git ref (should be the main branch) before branching to the kernel uprev kernel.
Push this test branch
Run the entire pipeline against the test branch, even the manual jobs
Now do the same for the kernel uprev branch
Compare the job results. If a CI job turned red on your uprev branch, it means that the kernel update broke the test. Otherwise, it should be fine.
Bare-metal custom kernels¶
Some CI jobs have support to plug in a custom kernel by simply changing a variable. This is great, since rebuilding the kernel and rootfs may takes dozens of minutes.
For example, freedreno jobs gitlab.yml manifest support a variable named BM_KERNEL. If one puts a gz-compressed kernel URL there, the job will use that kernel to boot the freedreno bare-metal devices. The same works for BM_DTB in the case of device tree binaries.
Careful reading of the job logs¶
Sometimes a job may turn to red for reasons unrelated to the kernel update, e.g. LAVA tftp timeout, problems with the freedesktop servers etc. So it is important to see the reason why the job turned red, and retry it if an infrastructure error has happened.