Skip to content

Instantly share code, notes, and snippets.

Last active September 25, 2022 16:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Bisect bugs in the Linux kernel -- Arch Linux
# git bisect start
# git bisect good v5.19.8-arch1 # not working
# git bisect bad v5.19.9-arch1 # start working again
# git bisect run ../../ yourlocalhost.local
if [[ $1 == "" ]]; then
echo "[i] provide your host as the first argument"
exit 125
bisect_line=`git bisect visualize --oneline|wc -l|perl -MPOSIX -lne 'print "Bisecting: ".floor(($_-1)/2)." revisions left to test after this (roughly ".(floor(log($_-1)/log(2))-1)." steps)" if $_'`
echo "[>] INIT: $bisect_line"
echo "[>] Building" && pushd ../../ && yes '' | makepkg -efs --noconfirm # swy: press enter to accept the default menu config, it will pick Y or M automatically
last_tar_file=`ls -c1 -t | grep linux.*\.tar | head -n1`
echo "[-] Built $last_tar_file. Copying and installing."
scp $last_tar_file $remote_host:~/linux-git
ssh $remote_host "sudo pacman -U linux-git/$last_tar_file --noconfirm"
echo "[-] Installed $last_tar_file; rebooting."
ssh $remote_host "sudo reboot"; sleep 1
until ssh $remote_host -o ConnectTimeout=1 "echo 1" > /dev/null && [[ $? == 0 ]]; do # 255 when it fails to connect, 0 when succeeding
sleep 1
echo "[-] Rebooted; testing for card"
ssh $remote_host "pactl list cards" | grep 'Kaveri HDMI/DP Audio Controller'
status=$?; echo "[>] status: $status"
if [[ $status == 0 ]]; then
echo "[i] Kaveri HDMI/DP Audio is present"
ssh $remote_host "echo \"<body bgcolor=darkseagreen><h1 style=color:green;font-size:560%>Kaveri HDMI/DP Audio is present</h1><br><br>$last_tar_file<br>$bisect_line</body>\" > /tmp/pg.html"
ssh $remote_host "sh -c 'XAUTHORITY=/run/user/1000/gdm/Xauthority DISPLAY=:0 nohup chromium --kiosk /tmp/pg.html > /dev/null 2>&1 &'"
exit 1 # bad bisect revision - reversed
echo "[e] Kaveri HDMI/DP Audio missing"
ssh $remote_host "echo \"<body bgcolor=pink><h1 style=color:red;font-size:560%>Kaveri HDMI/DP Audio missing</h1><br><br>$last_tar_file<br>$bisect_line</body>\" > /tmp/pg.html"
ssh $remote_host "sh -c 'XAUTHORITY=/run/user/1000/gdm/Xauthority DISPLAY=:0 nohup chromium --kiosk /tmp/pg.html > /dev/null 2>&1 &'" # swy:
exit 0 # good bisect revision - reversed
# Note that the script (my_script in the above example) should exit with code 0 if the current source code is good/old,
# and exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad/new.
exit 125
yay -S modprobed-db
modprobed store
systemctl --user enable modprobed-db.service
makepkg # swy: let it download the git repo and prepare
pushd src/linux
make mrproper
zcat /proc/config.gz > .config
make LSMOD=$HOME/linux-git/modprobed.db localmodconfig
makepkg -efsi --noconfirm # swy: or makepkg -efs to avoid installing it
git bisect start
# status: waiting for both good and bad commits
# good: [4b0986a3613c92f4ec1bdc7f60ec66fea135991f] Linux 5.18
git bisect good 4b0986a3613c92f4ec1bdc7f60ec66fea135991f
# status: waiting for bad commit, 1 good commit known
# bad: [3d7cb6b04c3f3115719235cc6866b10326de34cd] Linux 5.19
git bisect bad 3d7cb6b04c3f3115719235cc6866b10326de34cd
# good: [c011dd537ffe47462051930413fed07dbdc80313] Merge tag 'arm-soc-5.19' of git://
git bisect good c011dd537ffe47462051930413fed07dbdc80313
# skip: [5d4af9c1f04ab0411ba5818baad9a68e87f33099] Merge branch 'mv88e6xxx-fixes-for-reading-serdes-state'
git bisect skip 5d4af9c1f04ab0411ba5818baad9a68e87f33099
# good: [bf23729c7a5f44f0e863666b9364a64741fd3241] Merge tag 'amd-drm-next-5.19-2022-05-26-2' of into drm-next
git bisect good bf23729c7a5f44f0e863666b9364a64741fd3241
# skip: [0737e018a05e2aa352828c52bdeed3b02cff2930] net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list
git bisect skip 0737e018a05e2aa352828c52bdeed3b02cff2930
# skip: [1e308c6fb7127371f48a0fb9770ea0b30a6b5698] ice: Fix max VLANs available for VF
git bisect skip 1e308c6fb7127371f48a0fb9770ea0b30a6b5698
# bad: [03c765b0e3b4cb5063276b086c76f7a612856a9a] Linux 5.19-rc4
git bisect bad 03c765b0e3b4cb5063276b086c76f7a612856a9a
# bad: [a111daf0c53ae91e71fd2bfe7497862d14132e3e] Linux 5.19-rc3
git bisect bad a111daf0c53ae91e71fd2bfe7497862d14132e3e
# Maintainer: Jonathan Wright <>
# Contributor: Boohbah <boohbah at>
# Contributor: Jan Alexander Steffens (heftig) <>
pkgdesc='Linux (Git)'
bc kmod libelf git pahole
xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
config # the main kernel config file
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
pkgver() {
cd $_srcname
git describe --long | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g;s/\.rc/rc/'
prepare() {
cd $_srcname
echo "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux}" > localversion.20-pkgname
local src
for src in "${source[@]}"; do
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
echo "Setting config..."
cp ../config .config
#make olddefconfig
# swy: added this here; make sure to install modprobe-db from the aur
# and run sudo systemctl --user enable modprobe-db
make LSMOD=$HOME/.config/modprobed.db localmodconfig
make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
build() {
cd $_srcname
make all
_package() {
pkgdesc="The $pkgdesc kernel and modules"
depends=(coreutils kmod initramfs)
optdepends=('crda: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
cd $_srcname
# swy: duplicate the version file generation here to avoid rm failing at the end
make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"
echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
echo "Installing modules..."
make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
# remove build and source links
rm "$modulesdir"/{source,build}
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
# vim:set ts=8 sts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment