tools/perf/tests/shell/test_stat_intel_tpebs.sh
Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/test_stat_intel_tpebs.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/shell/test_stat_intel_tpebs.sh- Extension
.sh- Size
- 1893 bytes
- Lines
- 86
- 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_with_record_tpebs
Annotated Snippet
#!/bin/bash
# test Intel TPEBS counting mode (exclusive)
# SPDX-License-Identifier: GPL-2.0
set -e
ParanoidAndNotRoot() {
[ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
}
if ! grep -q GenuineIntel /proc/cpuinfo
then
echo "Skipping non-Intel"
exit 2
fi
if ParanoidAndNotRoot 0
then
echo "Skipping paranoid >0 and not root"
exit 2
fi
stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
cleanup() {
rm -rf "${stat_output}"
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cat "${stat_output}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
# Event to be used in tests
event=cache-misses
if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_output}" 2>&1
then
echo "Missing ${event} support"
cleanup
exit 2
fi
test_with_record_tpebs() {
echo "Testing with --record-tpebs"
if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 > "${stat_output}" 2>&1
then
echo "Testing with --record-tpebs [Failed perf stat]"
cat "${stat_output}"
exit 1
fi
# Expected output:
# $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
# Events enabled
# [ perf record: Woken up 2 times to write data ]
# [ perf record: Captured and wrote 0.056 MB - ]
#
# Performance counter stats for 'system wide':
#
# 0 cache-misses:R
#
# 0.013963299 seconds time elapsed
if ! grep "perf record" "${stat_output}"
then
echo "Testing with --record-tpebs [Failed missing perf record]"
Annotation
- Detected declarations: `function test_with_record_tpebs`.
- 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.