Debian Codegraph @

docs/ci/kernel.rst

raw
1 Upreving Linux Kernel
2 =====================
3
4 Occasionally, the GitLab CI needs a Linux Kernel update to enable new kernel
5 features, device drivers, bug fixes etc to CI jobs.
6 Kernel uprevs in GitLab CI are relatively simple, but prone to lots of
7 side-effects since many devices from different platforms are involved in the
8 pipeline.
9
10 Kernel repository
11 -----------------
12
13 The Linux Kernel used in the GitLab CI is stored at the following repository:
14 https://gitlab.freedesktop.org/gfx-ci/linux
15
16 It is common that Mesa kernel brings some patches that were not merged on the
17 Linux mainline, that is why Mesa has its own kernel version which should be used
18 as the base for newer kernels.
19
20 So, one should base the kernel uprev from the last tag used in the Mesa CI,
21 please refer to ``.gitlab-ci/image-tags.yml`` ``KERNEL_TAG`` variable.
22 Every tag has a standard naming: ``vX.YZ-for-mesa-ci-<commit_short_SHA>``, which
23 can be created via the command:
24
25 :code:`git tag vX.YZ-for-mesa-ci-$(git rev-parse --short HEAD)`
26
27 Building Kernel
28 ---------------
29
30 The kernel files are loaded from the artifacts uploaded to S3 from gfx-ci/linux.
31
32 Updating Kconfigs
33 ^^^^^^^^^^^^^^^^^
34
35 When a Kernel uprev happens, it is worth compiling and cross-compiling the
36 Kernel locally, in order to update the Kconfigs accordingly. Remember that the
37 resulting Kconfig is a merge between *Mesa CI Kconfig* and *Linux tree
38 defconfig* made via ``merge_config.sh`` script located at Linux Kernel tree.
39
40 Kconfigs location
41 """""""""""""""""
42
43 +------------+------------------------------------------------------+-------------------------------------+
44 | Platform | Mesa CI Kconfig location | Linux tree defconfig |
45 +============+======================================================+=====================================+
46 | arm | kernel/configs/mesa3d-ci_arm.config\@gfx-ci/linux | arch/arm/configs/multi_v7_defconfig |
47 +------------+------------------------------------------------------+-------------------------------------+
48 | arm64 | kernel/configs/mesa3d-ci_arm64.config\@gfx-ci/linux | arch/arm64/configs/defconfig |
49 +------------+------------------------------------------------------+-------------------------------------+
50 | x86-64 | kernel/configs/mesa3d-ci_x86_64.config\@gfx-ci/linux | arch/x86/configs/x86_64_defconfig |
51 +------------+------------------------------------------------------+-------------------------------------+
52
53 Updating image tags
54 -------------------
55
56 Every kernel uprev should update the following tag:
57
58 :code:`.gitlab-ci/image-tags.yml` tag
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 - **KERNEL_TAG** to use the new kernel
61
62 Development routine
63 -------------------
64
65 1. Compile the newer kernel locally for each platform.
66 2. Compile device trees for ARM platforms
67 3. Update Kconfigs. Are new Kconfigs necessary? Is CONFIG_XYZ_BLA deprecated? Does the ``merge_config.sh`` override an important config?
68 4. Push a new development branch to `Kernel repository`_ based on the latest kernel tag used in GitLab CI
69 5. Hack ``build-kernel.sh`` script to clone kernel from your development branch
70 6. Update image tags. See `Updating image tags`_
71 7. 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.
72
73 When the Kernel uprev is stable
74 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75
76 1. Push a new tag to Mesa CI `Kernel repository`_
77 2. Update KERNEL_URL ``debian/x86_test-gl`` job definition
78 3. Open a merge request, if it is not opened yet
79
80 Tips and Tricks
81 ---------------
82
83 Compare pipelines
84 ^^^^^^^^^^^^^^^^^
85
86 To have the most confidence that a kernel uprev does not break anything in Mesa,
87 it is suggested that one runs the entire CI pipeline to check if the update affected the manual CI jobs.
88
89 Step-by-step
90 """"""""""""
91
92 1. Create a local branch in the same git ref (should be the main branch) before branching to the kernel uprev kernel.
93 2. Push this test branch
94 3. Run the entire pipeline against the test branch, even the manual jobs
95 4. Now do the same for the kernel uprev branch
96 5. 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.
97
98 Bare-metal custom kernels
99 ^^^^^^^^^^^^^^^^^^^^^^^^^
100
101 Some CI jobs have support to plug in a custom kernel by simply changing a variable.
102 This is great, since rebuilding the kernel and rootfs may takes dozens of minutes.
103
104 For example, Freedreno jobs ``gitlab.yml`` manifest support a variable named
105 ``BM_KERNEL``. If one puts a gz-compressed kernel URL there, the job will use that
106 kernel to boot the Freedreno bare-metal devices. The same works for ``BM_DTB`` in
107 the case of device tree binaries.
108
109 Careful reading of the job logs
110 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111
112 Sometimes a job may turn to red for reasons unrelated to the kernel update, e.g.
113 LAVA ``tftp`` timeout, problems with the freedesktop servers etc.
114 So it is important to see the reason why the job turned red, and retry it if an
115 infrastructure error has happened.