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_spin.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 targets/kernel_spin.c (limited to 'targets/kernel_spin.c') diff --git a/targets/kernel_spin.c b/targets/kernel_spin.c new file mode 100644 index 0000000..206b0bd --- /dev/null +++ b/targets/kernel_spin.c @@ -0,0 +1,10 @@ +// A known amount of work: a loop of exactly four instructions, N times +// (argv[1], default ten million). What the counters are checked against, +// and the run that tracing overhead is measured on. +#include + +int main(int argc, char **argv) { + unsigned long n = argc > 1 ? strtoul(argv[1], 0, 0) : 10000000; + __asm__ volatile("1: dec %0\n nop\n nop\n jnz 1b" : "+r"(n) : : "cc"); + return 0; +} -- cgit v1.3