public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
* [RFT] bootlinux: add bisection support
@ 2025-04-24  0:09 Luis Chamberlain
  2025-04-24  5:47 ` Luis Chamberlain
  0 siblings, 1 reply; 14+ messages in thread
From: Luis Chamberlain @ 2025-04-24  0:09 UTC (permalink / raw)
  To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain

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>
---

Request For Testing as I've only gotten this to at least run up to the script,
and am debugging now to see if it actually does what I hope it should. The
other bug is that the first 'make bringup' boots into linux-next not the
good tag, but I can't see why yet. And so just two things are left here:

 1) figure out why make bringup fails to use the good tag
 2) see if we need to redo the simple boot script

I'm hoping we can use this to bisect why linux-next tag next-20250422
was hosed on boot.

 defconfigs/bisection                          |  9 +++
 playbooks/roles/bootlinux/defaults/main.yml   |  6 ++
 playbooks/roles/bootlinux/tasks/main.yml      | 45 +++++++++++
 .../bootlinux/templates/bisect-boot.sh.j2     |  7 ++
 workflows/linux/Kconfig                       | 80 ++++++++++++++++++-
 workflows/linux/Makefile                      | 15 ++++
 6 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 defconfigs/bisection
 create mode 100755 playbooks/roles/bootlinux/templates/bisect-boot.sh.j2

diff --git a/defconfigs/bisection b/defconfigs/bisection
new file mode 100644
index 000000000000..1c3112a0670e
--- /dev/null
+++ b/defconfigs/bisection
@@ -0,0 +1,9 @@
+CONFIG_GUESTFS=y
+CONFIG_LIBVIRT=y
+
+CONFIG_WORKFLOW_LINUX_CUSTOM=y
+CONFIG_BOOTLINUX=y
+CONFIG_BOOTLINUX_9P=y
+CONFIG_BOOTLINUX_BISECT_ENABLE=y
+
+CONFIG_DEVCONFIG_ENABLE_SYSTEMD_JOURNAL_REMOTE=y
diff --git a/playbooks/roles/bootlinux/defaults/main.yml b/playbooks/roles/bootlinux/defaults/main.yml
index fd5674b5fc19..245ae43c5f0d 100644
--- a/playbooks/roles/bootlinux/defaults/main.yml
+++ b/playbooks/roles/bootlinux/defaults/main.yml
@@ -52,3 +52,9 @@ kdevops_workflow_enable_cxl: False
 
 bootlinux_cxl_test: False
 bootlinux_tree_set_by_cli: False
+bootlinux_bisect_enable: False
+bootlinux_bisect_enable_cli: False
+bootlinux_bisect_ref_good_cli: False
+bootlinux_bisect_ref_bad_cli: False
+bootlinux_bisect_script_boot: False
+bootlinux_bisect_script_custom: False
diff --git a/playbooks/roles/bootlinux/tasks/main.yml b/playbooks/roles/bootlinux/tasks/main.yml
index 9ad675b3f278..afa533c011f8 100644
--- a/playbooks/roles/bootlinux/tasks/main.yml
+++ b/playbooks/roles/bootlinux/tasks/main.yml
@@ -650,3 +650,48 @@
   vars:
     running_kernel: "{{ uname_cmd.stdout_lines.0 }}"
   tags: [ 'linux', 'git', 'config', 'uname' ]
+
+- name: Copy git bisection script over
+  template:
+    src: "{{ bootlinux_bisect_script }}.j2"
+    dest: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
+    mode: 0644
+  tags: [ 'bisect' ]
+  when:
+    - bootlinux_bisect_enable|bool
+  run_once: true
+  delegate_to: localhost
+
+- name: Set up bisection for git
+  command: "git bisect start {{ bootlinux_bisect_ref_bad }} {{ bootlinux_bisect_ref_good }}"
+  register: build
+  changed_when: "build.rc == 0"
+  args:
+    chdir: "{{ bootlinux_9p_host_path }}"
+  tags: [ 'bisect' ]
+  when:
+    - bootlinux_bisect_enable|bool
+  run_once: true
+  delegate_to: localhost
+
+- name: Ensure bisection script is executable
+  file:
+    path: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
+    mode: '0755'
+    state: file
+  when: bootlinux_bisect_enable | bool
+  delegate_to: localhost
+  run_once: true
+  tags: [ 'bisect' ]
+
+- name: Run the the bisection script
+  command: "git bisect run {{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}"
+  register: build
+  changed_when: "build.rc == 0"
+  args:
+    chdir: "{{ bootlinux_9p_host_path }}"
+  tags: [ 'bisect' ]
+  when:
+    - bootlinux_bisect_enable|bool
+  run_once: true
+  delegate_to: localhost
diff --git a/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2 b/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2
new file mode 100755
index 000000000000..10dbacd307da
--- /dev/null
+++ b/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2
@@ -0,0 +1,7 @@
+#!/bin/bash
+# SPDX-License-Identifier: copyleft-next-0.3.1
+#
+# If make linux-deploy fails for reasons unrelated to the bug we're tracking
+# (e.g., a build error) we bail with exit code 125 to allow git to skip that
+# commit.
+make linux-deploy || exit 125
diff --git a/workflows/linux/Kconfig b/workflows/linux/Kconfig
index 797469e60d20..b30187c80e6e 100644
--- a/workflows/linux/Kconfig
+++ b/workflows/linux/Kconfig
@@ -10,6 +10,21 @@ config BOOTLINUX_TREE_REF_SET_BY_CLI
 	output yaml
 	default $(shell, scripts/check-cli-set-var.sh LINUX_TREE_REF)
 
+config BOOTLINUX_BISECT_ENABLE_CLI
+	bool
+	output yaml
+	default $(shell, scripts/check-cli-set-var.sh LINUX_BISECT)
+
+config BOOTLINUX_BISECT_REF_GOOD_CLI
+	bool
+	output yaml
+	default $(shell, scripts/check-cli-set-var.sh GOOD)
+
+config BOOTLINUX_BISECT_REF_BAD_CLI
+	bool
+	output yaml
+	default $(shell, scripts/check-cli-set-var.sh BAD)
+
 config BOOTLINUX_HAS_PURE_IOMAP_CONFIG
 	bool
 
@@ -173,7 +188,8 @@ config BOOTLINUX_TREE_CUSTOM_URL
 
 config BOOTLINUX_TREE_CUSTOM_REF
 	string "Custom Linux kernel tag or branch to use"
-	default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI
+	default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI && !BOOTLINUX_TREE_REF_SET_BY_CLI
+	default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI && !BOOTLINUX_BISECT_REF_GOOD_CLI
 	default "master" if !BOOTLINUX_TREE_REF_SET_BY_CLI
 	help
 	  The git ID or branch name to check out to compile linux.
@@ -278,9 +294,71 @@ config BOOTLINUX_TREE_LOCALVERSION
 	help
 	  The Linux local version to use (for uname).
 
+config BOOTLINUX_BISECT_ENABLE
+	bool "Do you want to bisect a broken kernel?"
+	default y
+	depends on BOOTLINUX_9P
+	output yaml
+	help
+	  Do you need to automate bisecting some broken kernel?
+
+if BOOTLINUX_BISECT_ENABLE
+
+choice
+	prompt "Bisection script to use"
+	default BOOTLINUX_BISECT_SCRIPT_BOOT
+
+config BOOTLINUX_BISECT_SCRIPT_BOOT
+	bool "Ensures we can at least boot"
+	help
+	  This helps ensure we can at laest boot into the host. That's it.
+
+config BOOTLINUX_BISECT_SCRIPT_CUSTOM
+	bool "You will provide your own bisection script"
+	help
+	  If you to test a new bisection script you can use this.
+
+endchoice
+
+config BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH
+	string "Custom path to git bisection script to use"
+	depends on BOOTLINUX_BISECT_SCRIPT_CUSTOM
+	default ""
+	output yaml
+	help
+	  The custom path to the bisect script we will use. Instead of building
+	  the kernel and booting it, 'make linux' will do the bisection
+	  automatically for you based on the script.
+
+config BOOTLINUX_BISECT_SCRIPT
+	string
+	output yaml
+	default "bisect-boot.sh" if BOOTLINUX_BISECT_SCRIPT_BOOT
+	default BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH if BOOTLINUX_BISECT_SCRIPT_BOOT
+
+
+config BOOTLINUX_BISECT_REF_GOOD
+	string "The last known good commit"
+	default BOOTLINUX_TREE_REF if !BOOTLINUX_BISECT_REF_GOOD_CLI
+	default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI
+	output yaml
+	help
+	  The known kernel commit to be good.
+
+config BOOTLINUX_BISECT_REF_BAD
+	string "The known broken commit"
+	default BOOTLINUX_TREE_STABLE_REF if !BOOTLINUX_BISECT_REF_BAD_CLI
+	default $(shell, ./scripts/append-makefile-vars.sh $(BAD)) if BOOTLINUX_BISECT_REF_BAD_CLI
+	output yaml
+	help
+	  The first broken tag.
+
+endif # BOOTLINUX_BISECT_ENABLE
+
 config BOOTLINUX_SHALLOW_CLONE
 	bool "Shallow git clone"
 	default y
+	depends on !BOOTLINUX_BISECT_ENABLE
 	help
 	  If enabled the git tree cloned with be cloned using a shallow tree
 	  with history truncated. You want to enable this if you really don't
diff --git a/workflows/linux/Makefile b/workflows/linux/Makefile
index ecce273a4f67..00ec13db74ca 100644
--- a/workflows/linux/Makefile
+++ b/workflows/linux/Makefile
@@ -104,6 +104,13 @@ linux-mount:
 		--tags vars,9p_mount \
 		--extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
 
+PHONY += linux-bisect
+linux-bisect:
+	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
+		$(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \
+		--tags vars,bisect \
+		--extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
+
 PHONY += linux-deploy
 linux-deploy:
 	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
@@ -176,6 +183,14 @@ linux-help-cxl:
 LINUX_HELP_EXTRA += linux-help-cxl
 endif
 
+ifeq (y,$(CONFIG_BOOTLINUX_BISECTION))
+PHONY += linux-help-bisection
+linux-help-bisection:
+	@echo "linux-bisection    - Bisects the kernel automatically for you"
+
+LINUX_HELP_EXTRA += linux-help-bisection
+endif
+
 HELP_TARGETS+=linux-help-menu
 HELP_TARGETS+=$(LINUX_HELP_EXTRA)
 HELP_TARGETS+=linux-help-end
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-05-07 18:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24  0:09 [RFT] bootlinux: add bisection support Luis Chamberlain
2025-04-24  5:47 ` Luis Chamberlain
2025-04-24  6:40   ` Daniel Gomez
2025-04-24  7:25     ` Daniel Gomez
2025-04-24 13:36       ` Daniel Gomez
2025-04-24 17:10         ` Luis Chamberlain
2025-04-24 18:37           ` Daniel Gomez
2025-04-24 17:08     ` Luis Chamberlain
2025-04-24 17:12       ` Luis Chamberlain
2025-04-24 18:41         ` Daniel Gomez
2025-05-01 22:21         ` Daniel Gomez
2025-05-05 19:25           ` Luis Chamberlain
2025-05-07 10:38             ` Daniel Gomez
2025-05-07 18:52               ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox