Skip to content

Commit be85dfd

Browse files
mcgrofKPD
authored andcommitted
bootlinux: add bisection support
This adds automatic bisection support first through the CLI by using simple command line options. The first target goal to test is very simple, check if the kernel boots or not. There is no need for a custom workflow for this. We just enable the user to set the values through the command line interface like this: git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git \ --reference /mirror/linux-next.git linux make defconfig-bisection \ GOOD=v6.15-rc2 \ BAD=next-20250422 \ KDEVOPS_HOSTS_PREFIX="bisect" \ LINUX_TREE="git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git" -j128 make -j128 make bringup make linux # Boots to good at first make linux-bisection # Runs the bisection script For now confine this feature to BOOTLINUX_9P as its not clear what to do about terraform yet. We can add that support later. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent a7241fe commit be85dfd

File tree

6 files changed

+161
-1
lines changed

6 files changed

+161
-1
lines changed

defconfigs/bisection

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_GUESTFS=y
2+
CONFIG_LIBVIRT=y
3+
4+
CONFIG_WORKFLOW_LINUX_CUSTOM=y
5+
CONFIG_BOOTLINUX=y
6+
CONFIG_BOOTLINUX_9P=y
7+
CONFIG_BOOTLINUX_BISECT_ENABLE=y
8+
9+
CONFIG_DEVCONFIG_ENABLE_SYSTEMD_JOURNAL_REMOTE=y

playbooks/roles/bootlinux/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ kdevops_workflow_enable_cxl: False
5252

5353
bootlinux_cxl_test: False
5454
bootlinux_tree_set_by_cli: False
55+
bootlinux_bisect_enable: False
56+
bootlinux_bisect_enable_cli: False
57+
bootlinux_bisect_ref_good_cli: False
58+
bootlinux_bisect_ref_bad_cli: False
59+
bootlinux_bisect_script_boot: False
60+
bootlinux_bisect_script_custom: False

playbooks/roles/bootlinux/tasks/main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,48 @@
650650
vars:
651651
running_kernel: "{{ uname_cmd.stdout_lines.0 }}"
652652
tags: [ 'linux', 'git', 'config', 'uname' ]
653+
654+
- name: Copy git bisection script over
655+
template:
656+
src: "{{ bootlinux_bisect_script }}.j2"
657+
dest: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
658+
mode: 0644
659+
tags: [ 'bisect' ]
660+
when:
661+
- bootlinux_bisect_enable|bool
662+
run_once: true
663+
delegate_to: localhost
664+
665+
- name: Set up bisection for git
666+
command: "git bisect start {{ bootlinux_bisect_ref_bad }} {{ bootlinux_bisect_ref_good }}"
667+
register: build
668+
changed_when: "build.rc == 0"
669+
args:
670+
chdir: "{{ bootlinux_9p_host_path }}"
671+
tags: [ 'bisect' ]
672+
when:
673+
- bootlinux_bisect_enable|bool
674+
run_once: true
675+
delegate_to: localhost
676+
677+
- name: Ensure bisection script is executable
678+
file:
679+
path: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
680+
mode: '0755'
681+
state: file
682+
when: bootlinux_bisect_enable | bool
683+
delegate_to: localhost
684+
run_once: true
685+
tags: [ 'bisect' ]
686+
687+
- name: Run the the bisection script
688+
command: "git bisect run {{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
689+
register: build
690+
changed_when: "build.rc == 0"
691+
args:
692+
chdir: "{{ bootlinux_9p_host_path }}"
693+
tags: [ 'bisect' ]
694+
when:
695+
- bootlinux_bisect_enable|bool
696+
run_once: true
697+
delegate_to: localhost
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: copyleft-next-0.3.1
3+
#
4+
# If make linux-deploy fails for reasons unrelated to the bug we're tracking
5+
# (e.g., a build error) we bail with exit code 125 to allow git to skip that
6+
# commit.
7+
make linux-deploy || exit 125

workflows/linux/Kconfig

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ config BOOTLINUX_TREE_REF_SET_BY_CLI
1010
output yaml
1111
default $(shell, scripts/check-cli-set-var.sh LINUX_TREE_REF)
1212

13+
config BOOTLINUX_BISECT_ENABLE_CLI
14+
bool
15+
output yaml
16+
default $(shell, scripts/check-cli-set-var.sh LINUX_BISECT)
17+
18+
config BOOTLINUX_BISECT_REF_GOOD_CLI
19+
bool
20+
output yaml
21+
default $(shell, scripts/check-cli-set-var.sh GOOD)
22+
23+
config BOOTLINUX_BISECT_REF_BAD_CLI
24+
bool
25+
output yaml
26+
default $(shell, scripts/check-cli-set-var.sh BAD)
27+
1328
config BOOTLINUX_HAS_PURE_IOMAP_CONFIG
1429
bool
1530

@@ -173,7 +188,8 @@ config BOOTLINUX_TREE_CUSTOM_URL
173188

174189
config BOOTLINUX_TREE_CUSTOM_REF
175190
string "Custom Linux kernel tag or branch to use"
176-
default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI
191+
default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI && !BOOTLINUX_TREE_REF_SET_BY_CLI
192+
default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI && !BOOTLINUX_BISECT_REF_GOOD_CLI
177193
default "master" if !BOOTLINUX_TREE_REF_SET_BY_CLI
178194
help
179195
The git ID or branch name to check out to compile linux.
@@ -278,9 +294,71 @@ config BOOTLINUX_TREE_LOCALVERSION
278294
help
279295
The Linux local version to use (for uname).
280296

297+
config BOOTLINUX_BISECT_ENABLE
298+
bool "Do you want to bisect a broken kernel?"
299+
default y
300+
depends on BOOTLINUX_9P
301+
output yaml
302+
help
303+
Do you need to automate bisecting some broken kernel?
304+
305+
if BOOTLINUX_BISECT_ENABLE
306+
307+
choice
308+
prompt "Bisection script to use"
309+
default BOOTLINUX_BISECT_SCRIPT_BOOT
310+
311+
config BOOTLINUX_BISECT_SCRIPT_BOOT
312+
bool "Ensures we can at least boot"
313+
help
314+
This helps ensure we can at laest boot into the host. That's it.
315+
316+
config BOOTLINUX_BISECT_SCRIPT_CUSTOM
317+
bool "You will provide your own bisection script"
318+
help
319+
If you to test a new bisection script you can use this.
320+
321+
endchoice
322+
323+
config BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH
324+
string "Custom path to git bisection script to use"
325+
depends on BOOTLINUX_BISECT_SCRIPT_CUSTOM
326+
default ""
327+
output yaml
328+
help
329+
The custom path to the bisect script we will use. Instead of building
330+
the kernel and booting it, 'make linux' will do the bisection
331+
automatically for you based on the script.
332+
333+
config BOOTLINUX_BISECT_SCRIPT
334+
string
335+
output yaml
336+
default "bisect-boot.sh" if BOOTLINUX_BISECT_SCRIPT_BOOT
337+
default BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH if BOOTLINUX_BISECT_SCRIPT_BOOT
338+
339+
340+
config BOOTLINUX_BISECT_REF_GOOD
341+
string "The last known good commit"
342+
default BOOTLINUX_TREE_REF if !BOOTLINUX_BISECT_REF_GOOD_CLI
343+
default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI
344+
output yaml
345+
help
346+
The known kernel commit to be good.
347+
348+
config BOOTLINUX_BISECT_REF_BAD
349+
string "The known broken commit"
350+
default BOOTLINUX_TREE_STABLE_REF if !BOOTLINUX_BISECT_REF_BAD_CLI
351+
default $(shell, ./scripts/append-makefile-vars.sh $(BAD)) if BOOTLINUX_BISECT_REF_BAD_CLI
352+
output yaml
353+
help
354+
The first broken tag.
355+
356+
endif # BOOTLINUX_BISECT_ENABLE
357+
281358
config BOOTLINUX_SHALLOW_CLONE
282359
bool "Shallow git clone"
283360
default y
361+
depends on !BOOTLINUX_BISECT_ENABLE
284362
help
285363
If enabled the git tree cloned with be cloned using a shallow tree
286364
with history truncated. You want to enable this if you really don't

workflows/linux/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ linux-mount:
104104
--tags vars,9p_mount \
105105
--extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
106106

107+
PHONY += linux-bisect
108+
linux-bisect:
109+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
110+
$(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \
111+
--tags vars,bisect \
112+
--extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
113+
107114
PHONY += linux-deploy
108115
linux-deploy:
109116
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
@@ -176,6 +183,14 @@ linux-help-cxl:
176183
LINUX_HELP_EXTRA += linux-help-cxl
177184
endif
178185

186+
ifeq (y,$(CONFIG_BOOTLINUX_BISECTION))
187+
PHONY += linux-help-bisection
188+
linux-help-bisection:
189+
@echo "linux-bisection - Bisects the kernel automatically for you"
190+
191+
LINUX_HELP_EXTRA += linux-help-bisection
192+
endif
193+
179194
HELP_TARGETS+=linux-help-menu
180195
HELP_TARGETS+=$(LINUX_HELP_EXTRA)
181196
HELP_TARGETS+=linux-help-end

0 commit comments

Comments
 (0)