freebsd-src/sys/arm64/include
Mark Johnston ddf0ed09bd sdt: Implement SDT probes using hot-patching
The idea here is to avoid a memory access and conditional branch per
probe site.  Instead, the probe is represented by an "unreachable"
unconditional function call.  asm goto is used to store the address of
the probe site (represented by a no-op sled) and the address of the
function call into a tracepoint record.  Each SDT probe carries a list
of tracepoints.

When the probe is enabled, the no-op sled corresponding to each
tracepoint is overwritten with a jmp to the corresponding label.  The
implementation uses smp_rendezvous() to park all other CPUs while the
instruction is being overwritten, as this can't be done atomically in
general.  The compiler moves argument marshalling code and the
sdt_probe() function call out-of-line, i.e., to the end of the function.

Per gallatin@ in D43504, this approach has less overhead when probes are
disabled.  To make the implementation a bit simpler, I removed support
for probes with 7 arguments; nothing makes use of this except a
regression test case.  It could be re-added later if need be.

The approach taken in this patch enables some more improvements:
1. We can now automatically fill out the "function" field of SDT probe
   names.  The SDT macros let the programmer specify the function and
   module names, but this is really a bug and shouldn't have been
   allowed.  The intent was to be able to have the same probe in
   multiple functions and to let the user restrict which probes actually
   get enabled by specifying a function name or glob.
2. We can avoid branching on SDT_PROBES_ENABLED() by adding the ability
   to include blocks of code in the out-of-line path.  For example:

	if (SDT_PROBES_ENABLED()) {
		int reason = CLD_EXITED;

		if (WCOREDUMP(signo))
			reason = CLD_DUMPED;
		else if (WIFSIGNALED(signo))
			reason = CLD_KILLED;
		SDT_PROBE1(proc, , , exit, reason);
	}

could be written

	SDT_PROBE1_EXT(proc, , , exit, reason,
		int reason;

		reason = CLD_EXITED;
		if (WCOREDUMP(signo))
			reason = CLD_DUMPED;
		else if (WIFSIGNALED(signo))
			reason = CLD_KILLED;
	);

In the future I would like to use this mechanism more generally, e.g.,
to remove branches and marshalling code used by hwpmc, and generally to
make it easier to add new tracepoint consumers without having to add
more conditional branches to hot code paths.

Reviewed by:	Domagoj Stolfa, avg
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D44483
2024-06-19 16:57:41 -04:00
..
_align.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
_bus.h _bus.h: Use standard licnese text 2023-11-13 12:25:30 -07:00
_inttypes.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
_limits.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
_stdint.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
_types.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
acle-compat.h arm64 lib32: prepare arm64 headers to redirect to arm 2023-07-25 18:59:26 -05:00
acpica_machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
armreg.h arm64: Fix indentation to be consistent 2024-06-10 15:16:10 +00:00
asan.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
asm.h arm64: Add PAC instruction macros 2023-10-20 17:01:05 +01:00
atomic.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
bus_dma_impl.h arm64: Implement busdma bits for KMSAN 2024-02-08 11:35:11 -05:00
bus_dma.h arm64: Implement busdma bits for KMSAN 2024-02-08 11:35:11 -05:00
bus.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
clock.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
cmn600_reg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
counter.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
cpu.h am64: Allow cpu.h to be included from assembly 2024-05-10 09:29:24 +00:00
cpufunc.h arm64: Use void pointers for arguments to arm64_get_writable_addr 2024-03-15 10:10:24 -07:00
cpuinfo.h arm64 lib32: prepare arm64 headers to redirect to arm 2023-07-25 18:59:26 -05:00
csan.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
db_machdep.h arm64: Support hardware breakpoints 2024-04-12 09:32:56 +00:00
debug_monitor.h arm64: Support hardware breakpoints 2024-04-12 09:32:56 +00:00
disassem.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dump.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
efi.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
elf.h arm64: Add more HWCAP2 values 2023-11-10 16:01:13 +00:00
endian.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
exec.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
float.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
floatingpoint.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
fpu.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
frame.h freebsd32: struct siginfo32 -> struct __siginfo32 2024-03-19 23:13:26 +00:00
gdb_machdep.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
hypervisor.h arm64: Add a macro to find a VM fault address 2024-02-21 18:55:32 +00:00
ieeefp.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
ifunc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
in_cksum.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
intr.h intrng: Extract arm/arm64 IPI->PIC glue code 2024-01-24 23:49:53 +00:00
iodev.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
iommu.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
kdb.h arm64: Support hardware breakpoints 2024-04-12 09:32:56 +00:00
machdep.h arm64: Add in_vhe() to find if the kernel is in VHE 2024-02-21 11:26:29 +00:00
md_var.h arm64: Create a Linux view of the ID registers 2023-11-10 16:01:13 +00:00
memdev.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
metadata.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
minidump.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
msan.h arm64: Add msan.h 2024-02-08 11:35:11 -05:00
ofw_machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
param.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
pcb.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pci_cfgreg.h pci_cfgreg: Add a PCI domain argument to the low-level register API 2023-11-29 10:31:47 -08:00
pcpu_aux.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pcpu.h arm64: Delete stale comment 2024-03-27 15:43:38 -04:00
pmap.h arm64, riscv: removed unused struct pv_addr 2024-05-24 10:55:24 -03:00
pmc_mdep.h pmc: better distinguish pmu-events allocation path 2023-09-03 13:27:21 -07:00
proc.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
procctl.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
profile.h arm64: Add a BTI landing pad to .mcount 2023-10-30 17:55:45 +00:00
psl.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
pte.h arm64: set ATTR_CONTIGUOUS on the DMAP's L2 blocks 2024-05-22 22:09:43 -05:00
ptrace.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
reg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
reloc.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
resource.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
runq.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sdt_machdep.h sdt: Implement SDT probes using hot-patching 2024-06-19 16:57:41 -04:00
setjmp.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sf_buf.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sigframe.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
signal.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
smp.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
stack.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
stdarg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sysarch.h Add a BTI sysarch 2024-02-22 16:27:47 +00:00
sysreg.h arm64 lib32: prepare arm64 headers to redirect to arm 2023-07-25 18:59:26 -05:00
tls.h arm64 lib32: prepare arm64 headers to redirect to arm 2023-07-25 18:59:26 -05:00
trap.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
ucontext.h arm64: Support passing more registers to signals 2024-03-21 10:13:16 +00:00
undefined.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vdso.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vfp.h arm64: Create a version of vfp_save_state for cpu_switch 2024-06-12 14:09:14 +01:00
vm.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vmm_dev.h Import the kernel parts of bhyve/arm64 2024-02-21 18:55:32 +00:00
vmm_instruction_emul.h Import the kernel parts of bhyve/arm64 2024-02-21 18:55:32 +00:00
vmm_snapshot.h Import the kernel parts of bhyve/arm64 2024-02-21 18:55:32 +00:00
vmm.h arm64/vmm: Avoid unnecessary indirection in vmmops_modinit() 2024-06-13 21:19:00 -04:00
vmparam.h vm_phys: Fix a typo 2024-06-16 13:33:00 -04:00