diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 12:17:50 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 12:19:28 -0300 |
| commit | 2e01933dc5c0c1903c1b7f86e453829fee9a541b (patch) | |
| tree | e3f1599a7c7bfafc4ebbc6a0b13e0134b4436706 /src/cli | |
| parent | 297943b01e18bb3d1dd41a8d3e220811de25228b (diff) | |
| download | computeranim-2e01933dc5c0c1903c1b7f86e453829fee9a541b.tar.gz computeranim-2e01933dc5c0c1903c1b7f86e453829fee9a541b.zip | |
kernel: smaller BPF records, syscall tracepoints sorted out in place, the README
Syscall entries and kprobes send the event alone (a kernel function's
registers are not the thread's; a syscall's are its arguments), a
probe's event is not inherited (it failed the target's clone). The
per-syscall tracepoints are told entry from exit on the events
themselves, not on a second set. The VM has two CPUs and a time limit.
README: the kernel's view, with what each mode costs.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/cli')
| -rw-r--r-- | src/cli/probe.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cli/probe.zig b/src/cli/probe.zig index f0e2d12..539af5c 100644 --- a/src/cli/probe.zig +++ b/src/cli/probe.zig @@ -16,7 +16,7 @@ pub const usage = \\kernel, into a recording (default out.ztrace). Needs CAP_BPF and \\CAP_PERFMON, which root has. \\ - \\ --syscalls every syscall, with the registers at its entry + \\ --syscalls every syscall \\ --sched every switch of a CPU to or from one of its threads \\ --kprobe FUNCTION \\ every call of a kernel function it makes: five arguments @@ -95,7 +95,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { const maps: bpf.Maps = .{ .ring = 0, .drops = 0 }; std.debug.print("for the process started from {s}:\n", .{path}); if (syscalls) { - list("raw tracepoint sys_enter: a syscall_enter and the registers", bpf.sysEnter(maps, 0)); + list("raw tracepoint sys_enter: a syscall_enter", bpf.sysEnter(maps, 0)); list("raw tracepoint sys_exit: a syscall_exit", bpf.sysExit(maps, 0)); } if (sched) { @@ -107,7 +107,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { if (p.usdt) |u| std.debug.print(", semaphore at +{x}, arguments {s}", .{ if (u.semaphore == 0) 0 else p.elf.?.offset(u.semaphore) orelse 0, u.args }); std.debug.print("\n", .{}); const id = zt.perf.stringId(p.name); - list("its program: a probe and the registers", if (p.usdt) |u| bpf.usdtProgram(maps, 0, id, u.args) catch fail("{s}: an argument of this probe ({s}) is in a form not understood yet\n", .{ p.name, u.args }) else bpf.probe(maps, 0, id, null)); + list("its program: a probe", if (p.usdt) |u| bpf.usdtProgram(maps, 0, id, u.args) catch fail("{s}: an argument of this probe ({s}) is in a form not understood yet\n", .{ p.name, u.args }) else bpf.probe(maps, 0, id, null, p.kind != .kprobe)); } std.debug.print("{s}\n", .{if (missing) |m| m else "nothing is missing to attach them"}); return; @@ -172,6 +172,7 @@ fn refused(err: anyerror, tracer: ?*bpf.Tracer) noreturn { const log = if (tracer) |t| std.mem.sliceTo(t.log, 0) else ""; switch (err) { error.PermissionDenied => fail("ztrace probe: bpf() refused though the capabilities are there: inside a user namespace or a container they do not count, the kernel wants them in the initial namespace\n", .{}), + error.SystemResources => fail("ztrace probe: the kernel has no memory to spare for a ring that large (--ring)\n", .{}), error.UnsafeProgram, error.InvalidProgram => fail("ztrace probe: the kernel's verifier refused a program ({t}):\n{s}\n", .{ err, log }), else => fail("ztrace probe: {t}\n{s}", .{ err, log }), } |
