Add Intel PT full trace mode basic test case
PATCH v5 1/1 Add Intel PT full trace mode basic test case
This test will do Intel PT full trace mode with test case PID to check if enable/stop/trace generation works with Intel PT.
--- runtest/tracing | 1 + testcases/kernel/tracing/pt_test/.gitignore | 1 + testcases/kernel/tracing/pt_test/Makefile | 6 ++ testcases/kernel/tracing/pt_test/pt_test.c | 153 ++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 testcases/kernel/tracing/pt_test/.gitignore create mode 100644 testcases/kernel/tracing/pt_test/Makefile create mode 100644 testcases/kernel/tracing/pt_test/pt_test.c
runtest/tracing +1 -0
@@ -3,3 +3,4 @@ ftrace_regression01 ftrace_regression01.sh ftrace_regression02 ftrace_regression02.sh ftrace-stress-test ftrace_stress_test.sh 90 dynamic_debug01 dynamic_debug01.sh +pt_full_trace_basic pt_test
testcases/kernel/tracing/pt_test/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/pt_test
testcases/kernel/tracing/pt_test/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/tracing/pt_test/pt_test.c new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v5 1/1 Add Intel PT full trace mode basic test case
Hi!
Pushed with following changes, thanks.
testcases/kernel/tracing/pt_test/pt_test.c +4 -1
@@ -7,7 +7,10 @@/* * This test will check if Intel PT(Intel Processer Trace) full trace mode is -* working. It is only applied on X86 platforms. +* working. +* +* Intel CPU of 5th-generation Core (Broadwell) or newer is required for the test. +* * kconfig requirement: CONFIG_PERF_EVENTS */
I found out that the perf manual says we need at least broadwell to run the test, so I documented it here (and I had to borow recent enough machine to check the test, since the newest I have is Ivy Bridge).
@@ -93,11 +96,11 @@ static void intel_pt_full_trace_check(void)
/* stop tracing */
SAFE_IOCTL(fde, PERF_EVENT_IOC_DISABLE);
- // check if there is some trace generated
+ /* check if there is some trace generated */
pmp = (struct perf_event_mmap_page *)bufm[0]; aux_head = *(volatile uint64_t *)&pmp->aux_head; if (aux_head == 0) {
- tst_res(TFAIL, "There is no trace, so failed!");
+ tst_res(TFAIL, "There is no trace!");
return;
}
@@ -109,10 +112,13 @@ static void setup(void)
struct perf_event_attr attr = {};
buhsz = 2 * PAGESIZE;
- if (tst_dir_is_empty(INTEL_PT_PATH, 1))
- tst_brk(TCONF, "PT not enabled, please check kconfig!");
+ if (access(INTEL_PT_PATH, F_OK)) {
+ tst_brk(TCONF,
+ "Requires Intel Core 5th+ generation (Broadwell and newer)"
+ " and CONFIG_PERF_EVENTS enabled.");
+ }
The tst_dir_is_empty() does not work here because the directory does not exists, at least on my machines, if the CPU does not support PT.
We usually use acess() with F_OK in these cases.
- //set attr for Intel PT trace
+ /* set attr for Intel PT trace */
attr.type = intel_pt_pmu_value(INTEL_PT_PMU_TYPE);
attr.read_format = PERF_FORMAT_ID | PERF_FORMAT_TOTAL_TIME_RUNNING |
PERF_FORMAT_TOTAL_TIME_ENABLED;
@@ -124,7 +130,7 @@ static void setup(void)
attr.exclude_user = 0;
attr.mmap = 1;
- //only get trace for own pid
+ /* only get trace for own pid */
fde = tst_syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0); if (fde < 0) {
tst_res(TINFO, "Open Intel PT event failed!");
Signature · 2 lines
Cyril Hrubis [email protected]