tools/perf/tests/shell/test_intel_pt.sh
Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/test_intel_pt.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/shell/test_intel_pt.sh- Extension
.sh- Size
- 17719 bytes
- Lines
- 722
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
time.hpthread.hsys/mman.hsys/types.hstddef.hstdio.hstdint.hunistd.hstring.hjitdump.h
Detected Declarations
function workfunction mainfunction can_cpu_widefunction rdtscfunction write_jitdumpfunction close_jitdumpfunction main
Annotated Snippet
void work(void) {
struct timespec tm = {
.tv_nsec = 1000000,
};
int i;
/* Run for about 30 seconds */
for (i = 0; i < 30000; i++)
nanosleep(&tm, NULL);
}
void *threadfunc(void *arg) {
work();
return NULL;
}
int main(void) {
pthread_t th;
pthread_create(&th, NULL, threadfunc, NULL);
work();
pthread_join(th, NULL);
return 0;
}
_end_of_file_
can_cpu_wide()
{
echo "Checking for CPU-wide recording on CPU $1"
if ! perf_record_no_decode -o "${tmpfile}" -e dummy:u -C "$1" true >/dev/null 2>&1 ; then
echo "No so skipping"
return 2
fi
echo OK
return 0
}
test_system_wide_side_band()
{
echo "--- Test system-wide sideband ---"
# Need CPU 0 and CPU 1
can_cpu_wide 0 || return $?
can_cpu_wide 1 || return $?
# Record on CPU 0 a task running on CPU 1
perf_record_no_decode -o "${perfdatafile}" -e intel_pt//u -C 0 -- taskset --cpu-list 1 uname
# Should get MMAP events from CPU 1 because they can be needed to decode
mmap_cnt=$(perf script -i "${perfdatafile}" --no-itrace --show-mmap-events -C 1 2>/dev/null | grep -c MMAP)
if [ "${mmap_cnt}" -gt 0 ] ; then
echo OK
return 0
fi
echo "Failed to record MMAP events on CPU 1 when tracing CPU 0"
return 1
}
can_kernel()
{
if [ -z "${can_kernel_trace}" ] ; then
can_kernel_trace=0
perf_record_no_decode -o "${tmpfile}" -e dummy:k true >/dev/null 2>&1 && can_kernel_trace=1
fi
if [ ${can_kernel_trace} -eq 0 ] ; then
echo "SKIP: no kernel tracing"
return 2
fi
Annotation
- Immediate include surface: `time.h`, `pthread.h`, `sys/mman.h`, `sys/types.h`, `stddef.h`, `stdio.h`, `stdint.h`, `unistd.h`.
- Detected declarations: `function work`, `function main`, `function can_cpu_wide`, `function rdtsc`, `function write_jitdump`, `function close_jitdump`, `function main`.
- 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.