https://sourceware.org/bugzilla/show_bug.cgi?id=34544
Bug ID: 34544
Summary: run-stackprof-system.sh fails on idle/minimal systems
(0 samples)
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: general
Assignee: unassigned at sourceware dot org
Reporter: jaipaul.cheernam at est dot tech
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
The systemwide stackprof tests (run-stackprof-system.sh and
run-stackprof-system-gprof.sh) fail on minimal/embedded systems where no
userspace process is active during the sampling window.
eu-stackprof uses PERF_TYPE_SOFTWARE/PERF_COUNT_SW_CPU_CLOCK with
exclude_kernel=1, so it only samples userspace execution. On an idle minimal
system (e.g. qemu with core-image-minimal), all processes are sleeping in
kernel syscalls, resulting in 0 samples.
The user-mode tests (run-stackprof-user.sh) work fine because they spawn their
own busy workload ("while true; do true; done").
Reproducer:
- Boot a minimal Linux system (e.g. Yocto core-image-minimal in qemu)
- Run the test as root
- Result: "received 0 samples, lost 0 samples, loaded 0 processes"
- Workaround: run "while true; do true; done &" before the test
1. Failing run (the important lines):
timeout -p --kill-after=5 10 /usr/bin/eu-stackprof -v
perf_event_attr configuration type=1 config=0 sample_freq=1000
Starting stack profile collection systemwide
=== pid / sample counts ===
===
TOTAL -- received 0 samples, lost 0 samples, loaded 0 processes
2. Passing run with background load:
# while true; do true; done &
# timeout 10 eu-stackprof -v
perf_event_attr configuration type=1 config=0 sample_freq=1000
Starting stack profile collection systemwide
find_dwfl newly seen pid 13043 (sh): ...
=== pid / sample counts ===
13043 sh -- max 19 frames, received 9975 samples, lost 6 samples (0.1%)
===
TOTAL -- received 10570 samples, lost 6 samples, loaded 2 processes
3. Environment:
Yocto core-image-minimal, qemux86-64, elfutils 0.196
kernel perf_event_paranoid=2, PERF_EVENTS=y
Possible fixes:
1. Skip (exit 77) when 0 samples are collected:
grep -E "^[0-9]+ " test.out || (echo "no userspace activity to sample";
exit 77)
2. Spawn a background workload like the user-mode tests already do:
/bin/sh -c "while true; do true; done" &
BGLOAD_PID=$!
trap "kill $BGLOAD_PID 2>/dev/null; exit_cleanup" 0
Option 2 has the advantage of actually testing the systemwide profiling
functionality rather than skipping it.
--
You are receiving this mail because:
You are on the CC list for the bug.