Page MenuHomeFreeBSD

kinst: start moving towards per-probe trampolines
ClosedPublic

Authored by christos on Jul 10 2023, 8:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 3:40 AM
Unknown Object (File)
Fri, Apr 12, 3:02 PM
Unknown Object (File)
Fri, Apr 12, 2:18 PM
Unknown Object (File)
Fri, Apr 12, 5:21 AM
Unknown Object (File)
Wed, Apr 10, 11:11 PM
Unknown Object (File)
Wed, Apr 10, 4:53 AM
Unknown Object (File)
Wed, Apr 10, 4:10 AM
Unknown Object (File)
Mar 14 2024, 4:31 PM
Subscribers

Details

Summary

Using per-CPU and per-thread trampolines is expensive and error-prone,
since we're rewriting the same memory blocks constantly. Per-probe
trampolines solve this problem by giving each probe its own block of
executable memory, which more or less remains the same after the initial
write.

What this patch does, is get rid of the initialization code which
allocates a trampoline for each thread, and instead let each port of
kinst allocate a trampoline for each new probe created. It also sets up
the infrastructure needed to support the new trampoline scheme.

This change is not currently supported on amd64, as the amd64 port needs
further changes to work, so this is a temporary/gradual patch to fix the
riscv and arm64 ports.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Free trampoline when the probe is destroyed. Declare kinst_cpu_state to support
the double-breakpoint mechanism.

sys/cddl/dev/kinst/kinst.h
43

This definition should carry a comment explaining the states.

sys/cddl/dev/kinst/kinst.h
48

kp should be a pointer to const, i.e., declared const struct kinst_probe *kp. I noticed this while reviewing the riscv code a while back.

sys/cddl/dev/kinst/trampoline.c
154–155

This comment applies only to amd64 now. riscv and arm64 allocate trampolines at probe creation time. If that fails, an error can be signaled to libdtrace, and the user will get a nice error message.

In other words, I think there is no need to log anything on !amd64 if trampoline allocation fails.

christos marked 3 inline comments as done.

Address comments.

This revision is now accepted and ready to land.Jul 19 2023, 1:52 PM