tools/perf/tests/shell/record_bpf_filter.sh
Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/record_bpf_filter.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/shell/record_bpf_filter.sh- Extension
.sh- Size
- 4473 bytes
- Lines
- 203
- 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 test_bpf_filter_priv
Annotated Snippet
#!/bin/bash
# perf record sample filtering (by BPF) tests
# SPDX-License-Identifier: GPL-2.0
set -e
err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
cleanup() {
rm -f "${perfdata}"
rm -f "${perfdata}".old
trap - EXIT TERM INT
}
trap_cleanup() {
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
test_bpf_filter_priv() {
echo "Checking BPF-filter privilege"
if ! perf record -e task-clock --filter 'period > 1' \
-o /dev/null --quiet true 2>&1
then
if [ "$(id -u)" != 0 ]
then
echo "try 'sudo perf record --setup-filter pin' first."
echo "bpf-filter test [Skipped permission]"
err=2
return
fi
echo "bpf-filter test [Skipped missing BPF support]"
err=2
return
fi
}
test_bpf_filter_basic() {
echo "Basic bpf-filter test"
if ! perf record -e task-clock -c 10000 --filter 'ip < 0xffffffff00000000' \
-o "${perfdata}" true 2> /dev/null
then
echo "Basic bpf-filter test [Failed record]"
err=1
return
fi
if perf script -i "${perfdata}" -F ip | grep 'ffffffff[0-9a-f]*'
then
if uname -r | grep -q ^6.2
then
echo "Basic bpf-filter test [Skipped unsupported kernel]"
err=2
return
fi
echo "Basic bpf-filter test [Failed invalid output]"
err=1
return
fi
echo "Basic bpf-filter test [Success]"
}
test_bpf_filter_fail() {
echo "Failing bpf-filter test"
# 'cpu' requires PERF_SAMPLE_CPU flag
if ! perf record -e task-clock --filter 'cpu > 0' \
Annotation
- Detected declarations: `function test_bpf_filter_priv`.
- 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.