summaryrefslogtreecommitdiffstats
path: root/samples/bpf/trace_event_user.c
diff options
context:
space:
mode:
authorTeng Qin2018-03-06 19:55:02 +0100
committerDaniel Borkmann2018-03-08 02:22:34 +0100
commit12fe12253c56a26e591ceefbdf0998b391022003 (patch)
tree822b9bb7680c97b84f98f8d471b297637048d473 /samples/bpf/trace_event_user.c
parentbpf: add support to read sample address in bpf program (diff)
downloadkernel-qcow2-linux-12fe12253c56a26e591ceefbdf0998b391022003.tar.gz
kernel-qcow2-linux-12fe12253c56a26e591ceefbdf0998b391022003.tar.xz
kernel-qcow2-linux-12fe12253c56a26e591ceefbdf0998b391022003.zip
samples/bpf: add example to test reading address
This commit adds additional test in the trace_event example, by attaching the bpf program to MEM_UOPS_RETIRED.LOCK_LOADS event with PERF_SAMPLE_ADDR requested, and print the lock address value read from the bpf program to trace_pipe. Signed-off-by: Teng Qin <qinteng@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/bpf/trace_event_user.c')
-rw-r--r--samples/bpf/trace_event_user.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index bf4f1b6d9a52..56f7a259a7c9 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -215,6 +215,17 @@ static void test_bpf_perf_event(void)
/* Intel Instruction Retired */
.config = 0xc0,
};
+ struct perf_event_attr attr_type_raw_lock_load = {
+ .sample_freq = SAMPLE_FREQ,
+ .freq = 1,
+ .type = PERF_TYPE_RAW,
+ /* Intel MEM_UOPS_RETIRED.LOCK_LOADS */
+ .config = 0x21d0,
+ /* Request to record lock address from PEBS */
+ .sample_type = PERF_SAMPLE_ADDR,
+ /* Record address value requires precise event */
+ .precise_ip = 2,
+ };
printf("Test HW_CPU_CYCLES\n");
test_perf_event_all_cpu(&attr_type_hw);
@@ -236,6 +247,10 @@ static void test_bpf_perf_event(void)
test_perf_event_all_cpu(&attr_type_raw);
test_perf_event_task(&attr_type_raw);
+ printf("Test Lock Load\n");
+ test_perf_event_all_cpu(&attr_type_raw_lock_load);
+ test_perf_event_task(&attr_type_raw_lock_load);
+
printf("*** PASS ***\n");
}