From db923fa823354270217362db06356f2b1a41315e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 11:39:20 -0300 Subject: ztrace perf: the kernel's view of a program, unprivileged perf_event_open on a held child: counters, a sampling profile, every page fault with its registers, maps, threads, context switches, every syscall (the per-syscall tracepoints, the only ones open to a user), and the debug registers as watchpoints and breakpoints that do not stop the target. One time-ordered stream of Events into a Sink; --threads follows with a ring per CPU. usdt.zig: the notes of and their arguments from a Regs and a memory reader, independent of BPF. test-kernel runs all of it on targets/kernel_*. Co-Authored-By: Claude Fable 5.2 --- targets/kernel_usdt_tick.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 targets/kernel_usdt_tick.c (limited to 'targets/kernel_usdt_tick.c') diff --git a/targets/kernel_usdt_tick.c b/targets/kernel_usdt_tick.c new file mode 100644 index 0000000..29a7ed8 --- /dev/null +++ b/targets/kernel_usdt_tick.c @@ -0,0 +1,15 @@ +// The probe of kernel_usdt.c that has a semaphore: a file is all with or +// all without. +#define _SDT_HAS_SEMAPHORES 1 +#include + +unsigned short ztrace_tick_semaphore __attribute__((section(".probes"))); + +long work(long n) { + long sum = 0; + for (long i = 0; i < n; i++) { + sum += i * i; + if (ztrace_tick_semaphore) DTRACE_PROBE2(ztrace, tick, i, sum); + } + return sum; +} -- cgit v1.3