Page MenuHomeFreeBSD

kinst: start moving towards per-probe trampolines

Authored by christos on Jul 10 2023, 8:34 PM.
Referenced Files
Unknown Object (File)
Jan 8 2024, 6:06 AM
Unknown Object (File)
Jan 8 2024, 6:06 AM
Unknown Object (File)
Dec 22 2023, 10:21 PM
Unknown Object (File)
Dec 10 2023, 6:15 PM
Unknown Object (File)
Nov 21 2023, 4:08 AM
Unknown Object (File)
Nov 21 2023, 4:06 AM
Unknown Object (File)
Nov 21 2023, 4:02 AM
Unknown Object (File)
Nov 21 2023, 3:59 AM



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

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

rG FreeBSD src repository
Lint Skipped
Tests Skipped
Build Status
Buildable 52669
Build 49560: arc lint + arc unit

Event Timeline

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


This definition should carry a comment explaining the states.


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.


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