tools/perf/tests/shell/test_brstack.sh
Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/test_brstack.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/shell/test_brstack.sh- Extension
.sh- Size
- 7326 bytes
- Lines
- 249
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function is_arm64
Annotated Snippet
#!/bin/bash
# Check branch stack sampling
# SPDX-License-Identifier: GPL-2.0
# German Gomez <german.gomez@arm.com>, 2022
shelldir=$(dirname "$0")
# shellcheck source=lib/perf_has_symbol.sh
. "${shelldir}"/lib/perf_has_symbol.sh
# skip the test if the hardware doesn't support branch stack sampling
# and if the architecture doesn't support filter types: any,save_type,u
if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then
echo "skip: system doesn't support filter types: any,save_type,u"
exit 2
fi
skip_test_missing_symbol brstack_bench
err=0
TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
TESTPROG="perf test -w brstack"
cleanup() {
rm -rf $TMPDIR
trap - EXIT TERM INT
}
trap_cleanup() {
set +e
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
is_arm64() {
[ "$(uname -m)" = "aarch64" ];
}
has_kaslr_bug() {
[ "$(uname -m)" != "aarch64" ];
}
check_branches() {
if ! tr -s ' ' '\n' < "$TMPDIR/perf.script" | grep -E -m1 -q "$1"; then
echo "ERROR: Branches missing $1"
err=1
fi
}
test_user_branches() {
echo "Testing user branch stack sampling"
start_err=$err
err=0
perf record -o "$TMPDIR/perf.data" --branch-filter any,save_type,u -- ${TESTPROG} > "$TMPDIR/record.txt" 2>&1
perf script -i "$TMPDIR/perf.data" --fields brstacksym > "$TMPDIR/perf.script"
# example of branch entries:
# brstack_foo+0x14/brstack_bar+0x40/P/-/-/0/CALL
expected=(
"^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/IND_CALL/.*$"
"^brstack_foo\+[^ ]*/brstack_bar\+[^ ]*/CALL/.*$"
"^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/CALL/.*$"
"^brstack_bench\+[^ ]*/brstack_bar\+[^ ]*/CALL/.*$"
"^brstack_bar\+[^ ]*/brstack_foo\+[^ ]*/RET/.*$"
"^brstack_foo\+[^ ]*/brstack_bench\+[^ ]*/RET/.*$"
"^brstack_bench\+[^ ]*/brstack_bench\+[^ ]*/COND/.*$"
Annotation
- Detected declarations: `function is_arm64`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.