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)
Fri, Nov 1, 2:48 PM
Unknown Object (File)
Mon, Oct 28, 12:08 PM
Unknown Object (File)
Mon, Oct 28, 12:08 PM
Unknown Object (File)
Oct 4 2024, 11:03 AM
Unknown Object (File)
Oct 4 2024, 5:09 AM
Unknown Object (File)
Oct 3 2024, 4:08 PM
Unknown Object (File)
Sep 30 2024, 3:54 PM
Unknown Object (File)
Sep 28 2024, 6:28 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 52549
Build 49440: arc lint + arc unit

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
158

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