From: Alan Maguire <almagui@kernel.org>
To: dwarves@vger.kernel.org
Cc: Alan Maguire <almagui@kernel.org>
Subject: [PATCH dwarves 4/6] tests: Expect no DWARF loader threads in reproducible_build.sh when CUs are merged
Date: Mon, 16 Nov 2026 11:20:41 +0000 [thread overview]
Message-ID: <20261116112043.3831978-5-almagui@kernel.org> (raw)
In-Reply-To: <20261116112043.3831978-1-almagui@kernel.org>
reproducible_build.sh checks that "pahole -jN" starts N threads. When
pahole merges all CUs into one, as it does for LTO kernels, DWARF is
loaded serially and no worker threads are started, so the test fails
on a clang ThinLTO vmlinux, as seen in the CI clang-lto-thin x86_64
job:
ERROR: pahole asked to start 1 encoding threads, started 0
Add a dwarf_cus_merged() helper to test_lib.sh mirroring
cus__merging_cu(): the kernel's LINUX_ELFNOTE_LTO_INFO note is set, or
the DWARF uses DW_FORM_ref_addr. When CUs are merged, expect zero
worker threads; the serial vs parallel BTF comparison is still done.
The helper walks the .notes section itself using the 4-byte layout of
the kernel's ELFNOTE() notes rather than relying on readelf -n. On
kernels whose linker script does not discard .note.gnu.property (it is
discarded since kernel commit f7ba52f302fd ("vmlinux.lds.h: Discard
.note.gnu.property section")), .notes picks up the 8-byte alignment of
that section and readelf -n misparses the 4-byte aligned notes.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
tests/reproducible_build.sh | 17 +++++++++++++++--
tests/test_lib.sh | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/tests/reproducible_build.sh b/tests/reproducible_build.sh
index 532b320..8b7b8eb 100755
--- a/tests/reproducible_build.sh
+++ b/tests/reproducible_build.sh
@@ -27,6 +27,16 @@ export PAHOLE_LANG_EXCLUDE=rust
pahole --btf_features=default --btf_encode_detached=$outdir/vmlinux.btf.serial $vmlinux
bpftool btf dump file $outdir/vmlinux.btf.serial > $outdir/bpftool.output.vmlinux.btf.serial
+# When CUs are merged (e.g. LTO kernels) pahole loads DWARF serially and
+# starts no loader threads whatever -j says; the encoding must still be
+# reproducible.
+if dwarf_cus_merged $vmlinux ; then
+ verbose_log "CUs are merged (LTO?); DWARF loading is serial, expecting no worker threads"
+ merged_cus=1
+else
+ merged_cus=0
+fi
+
nr_proc=$(getconf _NPROCESSORS_ONLN)
# Clamp to 1 so single-core machines don't produce -j0
half_proc=$(( nr_proc / 2 > 0 ? nr_proc / 2 : 1 ))
@@ -43,8 +53,11 @@ for threads in $thread_list ; do
nr_threads_started=$(ls /proc/$pahole/task 2>/dev/null | wc -l)
nr_threads_started=$((nr_threads_started - 1)) # subtract main thread
- if [ $threads != $nr_threads_started ] ; then
- error_log "ERROR: pahole asked to start $threads encoding threads, started $nr_threads_started"
+ expected_threads=$threads
+ [ $merged_cus = 1 ] && expected_threads=0
+
+ if [ $expected_threads != $nr_threads_started ] ; then
+ error_log "ERROR: pahole asked to start $threads encoding threads, expected $expected_threads, started $nr_threads_started"
test_fail
fi
diff --git a/tests/test_lib.sh b/tests/test_lib.sh
index e2d0b0c..bd3784e 100755
--- a/tests/test_lib.sh
+++ b/tests/test_lib.sh
@@ -464,6 +464,42 @@ get_perf_with_debug()
fi
}
+# Return success if pahole's DWARF loader will merge all CUs of $1 into
+# one and load them serially rather than with -j worker threads. This
+# mirrors cus__merging_cu() in dwarf_loader.c: the kernel's
+# LINUX_ELFNOTE_LTO_INFO note says it was built with LTO, or the DWARF
+# uses DW_FORM_ref_addr (references across CUs, as with clang LTO).
+#
+# readelf -n gives up on the kernel's .notes section (4-byte aligned
+# notes in an 8-byte aligned section), so walk the notes directly.
+dwarf_cus_merged()
+{
+ local obj=$1 notes
+
+ notes=$(mktemp)
+ if objcopy -O binary --only-section=.notes "$obj" "$notes" 2>/dev/null &&
+ od -An -v -tu4 -w4 "$notes" | awk '
+ # namesz, descsz, type, name (padded to 4), desc (padded to 4)
+ { w[n++] = $1 }
+ END {
+ for (i = 0; i + 3 <= n; ) {
+ namesz = w[i]; descsz = w[i+1]; type = w[i+2]
+ i += 3 + int((namesz + 3) / 4)
+ # LINUX_ELFNOTE_LTO_INFO, owner "Linux"
+ if (type == 257 && namesz == 6 && descsz == 4 && w[i] != 0)
+ exit 0
+ i += int((descsz + 3) / 4)
+ }
+ exit 1
+ }'; then
+ rm -f "$notes"
+ return 0
+ fi
+ rm -f "$notes"
+
+ readelf --debug-dump=abbrev "$obj" 2>/dev/null | grep -q DW_FORM_ref_addr
+}
+
make_tmpdir()
{
# Ensure master test directory exists
--
2.56.0
next prev parent reply other threads:[~2026-11-16 11:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 11:20 [PATCH dwarves 0/6] Add support for LTO kernel builds, other CI fixes Alan Maguire
2026-11-16 11:20 ` [PATCH dwarves 1/6] CI: Make kernel source fetch tolerant of git host failures Alan Maguire
2026-11-16 11:20 ` [PATCH dwarves 2/6] tests: Match BTF and DWARF functions with set operations in btf_functions.sh Alan Maguire
2026-11-16 11:20 ` [PATCH dwarves 3/6] CI: Scope workflow concurrency groups to the branch for push runs Alan Maguire
2026-11-16 11:20 ` Alan Maguire [this message]
2026-11-16 11:20 ` [PATCH dwarves 5/6] CI: Fix ondemand workflow inputs and LLVM version in function comparison Alan Maguire
2026-11-16 11:20 ` [PATCH dwarves 6/6] CI: Add clang ThinLTO kernel build to test matrix Alan Maguire
2026-11-18 19:39 ` [PATCH dwarves 0/6] Add support for LTO kernel builds, other CI fixes Alan Maguire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116112043.3831978-5-almagui@kernel.org \
--to=almagui@kernel.org \
--cc=dwarves@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox