summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/test_usdt_multispec.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2022-04-05 01:42:02 +0200
committerAlexei Starovoitov <ast@kernel.org>2022-04-05 22:16:08 +0200
commit00a0fa2d7d496824648b125256c5566f36b48dad (patch)
tree2a02939fd7eaea26ef23a126702cedad79752e80 /tools/testing/selftests/bpf/progs/test_usdt_multispec.c
parentselftests/bpf: Add basic USDT selftests (diff)
downloadlinux-00a0fa2d7d496824648b125256c5566f36b48dad.tar.xz
linux-00a0fa2d7d496824648b125256c5566f36b48dad.zip
selftests/bpf: Add urandom_read shared lib and USDTs
Extend urandom_read helper binary to include USDTs of 4 combinations: semaphore/semaphoreless (refcounted and non-refcounted) and based in executable or shared library. We also extend urandom_read with ability to report it's own PID to parent process and wait for parent process to ready itself up for tracing urandom_read. We utilize popen() and underlying pipe properties for proper signaling. Once urandom_read is ready, we add few tests to validate that libbpf's USDT attachment handles all the above combinations of semaphore (or lack of it) and static or shared library USDTs. Also, we validate that libbpf handles shared libraries both with PID filter and without one (i.e., -1 for PID argument). Having the shared library case tested with and without PID is important because internal logic differs on kernels that don't support BPF cookies. On such older kernels, attaching to USDTs in shared libraries without specifying concrete PID doesn't work in principle, because it's impossible to determine shared library's load address to derive absolute IPs for uprobe attachments. Without absolute IPs, it's impossible to perform correct look up of USDT spec based on uprobe's absolute IP (the only kind available from BPF at runtime). This is not the problem on newer kernels with BPF cookie as we don't need IP-to-ID lookup because BPF cookie value *is* spec ID. So having those two situations as separate subtests is good because libbpf CI is able to test latest selftests against old kernels (e.g., 4.9 and 5.5), so we'll be able to disable PID-less shared lib attachment for old kernels, but will still leave PID-specific one enabled to validate this legacy logic is working correctly. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Dave Marchevsky <davemarchevsky@fb.com> Link: https://lore.kernel.org/bpf/20220404234202.331384-8-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_usdt_multispec.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_usdt_multispec.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_usdt_multispec.c b/tools/testing/selftests/bpf/progs/test_usdt_multispec.c
index 3a090681f981..aa6de32b50d1 100644
--- a/tools/testing/selftests/bpf/progs/test_usdt_multispec.c
+++ b/tools/testing/selftests/bpf/progs/test_usdt_multispec.c
@@ -26,8 +26,6 @@ int BPF_USDT(usdt_100, int x)
__sync_fetch_and_add(&usdt_100_called, 1);
__sync_fetch_and_add(&usdt_100_sum, x);
- bpf_printk("X is %d, sum is %d", x, usdt_100_sum);
-
return 0;
}