As per this issue in bcachefs Kernel BUG at bch2_bio_compress · Issue #883 · koverstreet/bcachefs · GitHub , the developer wanted the line number for further investigation.
I obtained the faddr2line script from linux/scripts/faddr2line at master · torvalds/linux · GitHub and then ran this command on regular kernel and xanmod kernel.
/tmp/faddr2line /nix/store/hfgrxxhrzax6n0yp33rxsjq7vzs5w86w-linux-6.14.5-dev/vmlinux bch2_bio_compress+0x527/0x530
/tmp/faddr2line /nix/store/anmfvh9s852h7lkmrv919jvf75bsjhw4-linux-xanmod-6.14.5-dev/vmlinux bch2_bio_compress+0x4a6/0x5b0
I did not find any line numbers.
Instead I got these errors
(faddr2line v6.14) sed: Arg is too long
(faddr2line v6.7) no match for bch2_bio_compress+0x4a6/0x5b0
I followed this reddit post to get the store path of the current kernel.
https://www.reddit.com/r/NixOS/comments/1gm5xg5/comment/lw0ffzm/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
❯ ll $(nix-store --realise $(nix --experimental-features nix-command derivation show /run/booted-system/kernel | jq -r '.[].outputs.dev.path'))/vmlinux
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
.r-xr-xr-x 376M root 1 Jan 1970 /nix/store/hfgrxxhrzax6n0yp33rxsjq7vzs5w86w-linux-6.14.5-dev/vmlinux
Is this user(me) error or faddr2line does not work on NixOS kernels?
It’s been a while since I needed this, but I have a small wrapper for scripts/decode_stacktrace.sh
(which i believe calls faddr2line internally)
{ config, pkgs, lib, ... }:
let
decode_stacktrace =
let
kernel = config.boot.kernelPackages.kernel;
in
pkgs.writeShellApplication {
name = "decode_stacktrace.sh";
runtimeInputs = with pkgs; [
stdenv
gcc
util-linux
];
text = ''
exec ${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/scripts/decode_stacktrace.sh \
${kernel.dev}/vmlinux \
/build/source/build/.. \
/run/booted-system/kernel-modules/lib/modules/${kernel.modDirVersion} \
;
'';
};
in
{
environment.systemPackages = [
decode_stacktrace
];
}
I’m also setting the below on my kernel build:
- I had to build bcachefs as a built-in, not as a module (something about not being able to decompress the modules IIRC)
- I don’t remember why the other options were necessary
structuredExtraConfig = with lib.kernel; {
BCACHEFS_FS = yes;
# for scripts/decode_stacktrace.sh
IKHEADERS = module;
DEBUG_KERNEL = yes;
DEBUG_INFO = yes;
};
With this setup, I can do:
# echo bch2_rebalance_thread+0xce/0x130 | decode_stacktrace.sh
bch2_rebalance_thread (fs/bcachefs/rebalance.c:626 (discriminator 1))
or
# cat /sys/fs/bcachefs/*/rebalance_status | decode_stacktrace.sh
pending work: 528 MiB
waiting
io wait duration: 7.28 GiB
io wait remaining: 3.27 GiB
duration waited: 84 m
bch2_rebalance_thread (fs/bcachefs/rebalance.c:626 (discriminator 1))
kthread (kernel/kthread.c:464)
ret_from_fork (arch/x86/kernel/process.c:153)
ret_from_fork_asm (arch/x86/entry/entry_64.S:258)
Hope this helps!
I’m definitely interested if someone has a cleaner/easier method
1 Like