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.

Dependency Surface

Detected Declarations

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

Implementation Notes