1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00
freebsd/sys/arm
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
..
allwinner arm: Remove stray references to dev/sound/chip.h 2024-05-06 21:35:30 +02:00
altera/socfpga conf: deduplicate dwmmc config logic 2024-02-27 18:10:14 -04:00
annapurna/alpine sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
arm sdt: Implement SDT probes using hot-patching 2024-06-19 16:57:41 -04:00
broadcom/bcm2835 arm: Remove stray references to dev/sound/chip.h 2024-05-06 21:35:30 +02:00
conf LINT: Don't build bnxt on 32-bit platforms 2024-05-29 10:50:27 -06:00
freescale arm: Remove stray references to dev/sound/chip.h 2024-05-06 21:35:30 +02:00
include sdt: Implement SDT probes using hot-patching 2024-06-19 16:57:41 -04:00
mv new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE 2024-03-13 15:05:54 -07:00
nvidia arm: Convert drivers to use device_set_desc(f)() 2024-06-02 19:38:40 -04:00
qemu sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
qualcomm phy: Move phy code in dev/phy 2024-01-10 19:20:34 +01:00
rockchip conf: deduplicate dwmmc config logic 2024-02-27 18:10:14 -04:00
ti ti/am335x: Fix the device_set_descf() call in dmtpps_probe() 2024-06-09 10:08:31 -04:00
xilinx sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00