History log of /freebsd-current/sys/sys/sdt.h
Revision Date Author Comments
# 4afce447 01-May-2024 Mark Johnston <markj@FreeBSD.org>

sdt: Add macros which expand to probe and provider structure names

No functional change intended.

MFC after: 1 week


# 60d8dbbe 18-Jan-2024 Kristof Provost <kp@FreeBSD.org>

netinet: add a probe point for IP, IP6, ICMP, ICMP6, UDP and TCP stats counters

When debugging network issues one common clue is an unexpectedly
incrementing error counter. This is helpful, in that it gives us an
idea of what might be going wrong, but often these counters may be
incremented in different functions.

Add a static probe point for them so that we can use dtrace to get
futher information (e.g. a stack trace).

For example:
dtrace -n 'mib:ip:count: { printf("%d", arg0); stack(); }'

This can be disabled by setting the following kernel option:
options KDTRACE_NO_MIB_SDT

Reviewed by: gallatin, tuexen (previous version), gnn (previous version)
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D43504


# 3b795e64 03-Apr-2024 Mark Johnston <markj@FreeBSD.org>

sdt: Use designated initializers for various definitions

No functional change intended.

MFC after: 1 week


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 7f337c94 21-Feb-2023 Mateusz Guzik <mjg@FreeBSD.org>

sdt: add __sdt_used

To pacify set-but-not-used warns when compiling without sdt probes.

Reviewed by:
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision:


# 832cb4ca 19-Dec-2018 Mateusz Guzik <mjg@FreeBSD.org>

Provide SDT_PROBES_ENABLED for kernels without KDTRACE.

Sponsored by: The FreeBSD Foundation


# 13a45e4b 07-Dec-2018 Mateusz Guzik <mjg@FreeBSD.org>

Provide SDT_PROBES_ENABLED macro.

Sponsored by: The FreeBSD Foundation


# c4e20cad 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 5a17c552 22-Oct-2017 Mateusz Guzik <mjg@FreeBSD.org>

sdt: make all sdt probe sites test one variable

This saves on cache misses at the expense of a slight grow of .text.

Note this is a bandaid for lack of hotpatching.

Discussed with: markj


# 4f7663af 22-Oct-2017 Mateusz Guzik <mjg@FreeBSD.org>

sdt: whack unused SDT_PROBE_ENABLED


# 3b6f6c27 08-Feb-2017 Mateusz Guzik <mjg@FreeBSD.org>

Implement LOCKSTAT_OOL_PROFILE_ENABLED

For use in uninlined locking primitives to decide whether lockstat
or profiling needs to be taken care of.


# 08da2677 05-Feb-2017 Mateusz Guzik <mjg@FreeBSD.org>

mtx: move lockstat handling out of inline primitives

Lockstat requires checking if it is enabled and if so, calling a 6 argument
function. Further, determining whether to call it on unlock requires
pre-reading the lock value.

This is problematic in at least 3 ways:
- more branches in the hot path than necessary
- additional cacheline ping pong under contention
- bigger code

Instead, check first if lockstat handling is necessary and if so, just fall
back to regular locking routines. For this purpose a new macro is introduced
(LOCKSTAT_PROFILE_ENABLED).

LOCK_PROFILING uninlines all primitives. Fold in the current inline lock
variant into the _mtx_lock_flags to retain the support. With this change
the inline variants are not used when LOCK_PROFILING is defined and thus
can ignore its existence.

This results in:
text data bss dec hex filename
22259667 1303208 4994976 28557851 1b3c21b kernel.orig
21797315 1303208 4994976 28095499 1acb40b kernel.patched

i.e. about 3% reduction in text size.

A remaining action is to remove spurious arguments for internal kernel
consumers.


# 1201d0bc 15-Jun-2016 Mateusz Guzik <mjg@FreeBSD.org>

sdt: annotate the probe test as likely to fail

This saves a jump in plenty of cases.

Approved by: re (kib)
MFC after: 1 week


# 6557a3b7 28-Sep-2015 Andriy Gapon <avg@FreeBSD.org>

sdt.h: no need for argtype_list_head

MFC after: 12 days


# 5439a715 02-Sep-2014 Mark Johnston <markj@FreeBSD.org>

Define _DTRACE_VERSION in sdt.h rather than setting it manually. This is
similar to what illumos does, and makes it easier to enable USDT probes
in third-party software that doesn't make use of the system makefiles.


# 0f912c5a 11-Jul-2014 Rui Paulo <rpaulo@FreeBSD.org>

Remove _DTRACE_VERSION from sdt.h. It will now come from the command line
(bsd.dep.mk).

MFC after: 3 weeks


# a776a1c1 26-Nov-2013 Andriy Gapon <avg@FreeBSD.org>

sdt: add support for solaris/illumos style DTRACE_PROBE macros

The new macros are implemented in terms of SDT_PROBE_DEFINE and SDT_PROBE.
Probes defined in this way will appear under SDT provider named "sdt".
Parameter types are exposed via SDT_PROBE_ARGTYPE.
This is something that illumos does not have by default.

This kind of SDT probes is already present in ZFS code, so those probes
will now be available if KDTRACE_HOOKS options is enabled.

A potential future illumos compatibility enhancement is to encode a provider
name as a prefix in a probe name.

Reviewed by: markj
MFC after: 3 weeks
X-MFC after: r258622


# d9fae5ab 26-Nov-2013 Andriy Gapon <avg@FreeBSD.org>

dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE

In its stead use the Solaris / illumos approach of emulating '-' (dash)
in probe names with '__' (two consecutive underscores).

Reviewed by: markj
MFC after: 3 weeks


# 9c06d5a0 26-Oct-2013 Mark Johnston <markj@FreeBSD.org>

Do some cleanup of the SDT code. In particular,

* Remove the unused sdt cdev.
* Don't bother keeping a list of probes in struct sdt_prov; it's not needed.
* Invoke sdt_load and sdt_unload from the module handler instead of
registering separate SYSINITs.
* Keep to within 80 columns.
* Check for errors from dtrace_unregister().


# 5605b69c 21-Sep-2013 Mark Johnston <markj@FreeBSD.org>

Give argtype struct names a different prefix than probe struct names.
Otherwise it's possible to declare SDT probes in such a way that a name
collision occurs, causing an unexpected compilation error.

Approved by: re (gjb)
MFC after: 1 week


# 7bc992c0 17-Aug-2013 Mark Johnston <markj@FreeBSD.org>

Add a "translated type" argument to SDT_PROBE_ARGTYPE() and add some macros
which allow one to define SDT probes that specify translated types. The idea
is to make it easy to write SDT probe definitions that can work across
multiple operating systems. In particular, this makes it possible to port
illumos SDT probes to FreeBSD without changing their argument types, so long
as the appropriate translators are defined. Then DTrace scripts written for
Solaris/illumos will work on FreeBSD without any changes.

MFC after: 1 week


# 8776669b 12-Aug-2013 Mark Johnston <markj@FreeBSD.org>

FreeBSD's DTrace implementation has a few problems with respect to handling
probes declared in a kernel module when that module is unloaded. In
particular,

* Unloading a module with active SDT probes will cause a panic. [1]
* A module's (FBT/SDT) probes aren't destroyed when the module is unloaded;
trying to use them after the fact will generally cause a panic.

This change fixes both problems by porting the DTrace module load/unload
handlers from illumos and registering them with the corresponding
EVENTHANDLER(9) handlers. This allows the DTrace framework to destroy all
probes defined in a module when that module is unloaded, and to prevent a
module unload from proceeding if some of its probes are active. The latter
problem has already been fixed for FBT probes by checking lf->nenabled in
kern_kldunload(), but moving the check into the DTrace framework generalizes
it to all kernel providers and also fixes a race in the current
implementation (since a probe may be activated between the check and the
call to linker_file_unload()).

Additionally, the SDT implementation has been reworked to define SDT
providers/probes/argtypes in linker sets rather than using SYSINIT/SYSUNINIT
to create and destroy SDT probes when a module is loaded or unloaded. This
simplifies things quite a bit since it means that pretty much all of the SDT
code can live in sdt.ko, and since it becomes easier to integrate SDT with
the DTrace framework. Furthermore, this allows FreeBSD to be quite flexible
in that SDT providers spanning multiple modules can be created on the fly
when a module is loaded; at the moment it looks like illumos' SDT
implementation requires all SDT probes to be statically defined in a single
kernel table.

PR: 166927, 166926, 166928
Reported by: davide [1]
Reviewed by: avg, trociny (earlier version)
MFC after: 1 month


# 55d78cc7 07-Jul-2013 Mark Johnston <markj@FreeBSD.org>

Also define SDT_PROBE_DEFINE0 for the !KDTRACE_HOOKS case.


# d63fca7a 06-Jul-2013 Mark Johnston <markj@FreeBSD.org>

Add SDT_PROBE_DEFINE0 for consistency with SDT_PROBE0.

MFC after: 1 week


# 3dd2790a 30-May-2013 Mark Johnston <markj@FreeBSD.org>

Add macros which allow one to define SDT probes with six or seven arguments;
they are needed when porting some of the Solaris providers (ip, iscsi, and
tcp in particular).

dtrace_probe() only takes five arguments from the probe site, so we need to
add the appropriate cast to allow for more than five arguments. The extra
arguments are later copied out of dtrace_probe()'s stack frame by
dtrace_getarg() (or the provider-specific getarg method) as needed.

MFC after: 1 week


# 838eb863 19-May-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Protect SDT_PROBE() with do { } while (0) loop.


# b3e9e682 14-May-2012 Ryan Stone <rstone@FreeBSD.org>

Implement the DTrace sched provider. This implementation aims to be
compatible with the sched provider implemented by Solaris and its open-
source derivatives. Full documentation of the sched provider can be found
on Oracle's DTrace wiki pages.

Note that for compatibility with scripts originally written for Solaris,
serveral probes are defined that will never fire. These probes are defined
to fire when Solaris-specific features perform certain actions. As these
features are not present in FreeBSD, the probes can never fire.

Also, I have added a two probes that are not defined in Solaris, lend-pri
and load-change. These probes have been added to make it possible to
collect schedgraph data with DTrace.

Finally, a few probes are defined in Solaris to take a cpuinfo_t *
argument. As it was not immediately clear to me how to translate that to
FreeBSD, currently those probes are passed NULL in place of a cpuinfo_t *.

Sponsored by: Sandvine Incorporated
MFC after: 2 weeks


# 97424107 27-Mar-2012 Ryan Stone <rstone@FreeBSD.org>

Instead of only iterating over the set of known SDT probes when sdt.ko is
loaded and unloaded, also have sdt.ko register callbacks with kern_sdt.c
that will be called when a newly loaded KLD module adds more probes or
a module with probes is unloaded.

This fixes two issues: first, if a module with SDT probes was loaded after
sdt.ko was loaded, those new probes would not be available in DTrace.
Second, if a module with SDT probes was unloaded while sdt.ko was loaded,
the kernel would panic the next time DTrace had cause to try and do
anything with the no-longer-existent probes.

This makes it possible to create SDT probes in KLD modules, although there
are still two caveats: first, any SDT probes in a KLD module must be part
of a DTrace provider that is defined in that module. At present DTrace
only destroys probes when the provider is destroyed, so you can still
panic the system if a KLD module creates new probes in a provider from a
different module(including the kernel) and then unload the the first module.

Second, the system will panic if you unload a module containing SDT probes
while there is an active D script that has enabled those probes.

MFC after: 1 month


# 1063f929 07-Nov-2011 Ed Schouten <ed@FreeBSD.org>

SDT's struct sdt_argtype can be marked static everywhere.

It is only passed to SYSINIT/SYSUNINIT.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 79856499 22-Aug-2010 Rui Paulo <rpaulo@FreeBSD.org>

Add an extra comment to the SDT probes definition. This allows us to get
use '-' in probe names, matching the probe names in Solaris.[1]

Add userland SDT probes definitions to sys/sdt.h.

Sponsored by: The FreeBSD Foundation
Discussed with: rwaston [1]


# 4cc7ec35 05-Dec-2009 Bjoern A. Zeeb <bz@FreeBSD.org>

MFC r199883:
Add SDT_PROBE[1-5] in the same way we have SDT_PROBE_DEFINE[1-5] to
avoid having to add all the unused trailing arguments as zeros.


# e7ad2d34 28-Nov-2009 Bjoern A. Zeeb <bz@FreeBSD.org>

Add SDT_PROBE[1-5] in the same way we have SDT_PROBE_DEFINE[1-5] to
avoid having to add all the unused trailing arguments as zeros.

MFC after: 6 days


# 5e713d3d 03-Mar-2009 Robert Watson <rwatson@FreeBSD.org>

Adding missing ";"'s required by some SDT_PROBE_DEFINEx() macros.

MFC after: 1 week


# 73e416e3 03-Mar-2009 Robert Watson <rwatson@FreeBSD.org>

Reduce the verbosity of SDT trace points for DTrace by defining several
wrapper macros that allow trace points and arguments to be declared
using a single macro rather than several. This means a lot less
repetition and vertical space for each trace point.

Use these macros when defining privilege and MAC Framework trace points.

Reviewed by: jb
MFC after: 1 week


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 80f4e2cb 16-May-2008 John Birrell <jb@FreeBSD.org>

Add the statically defined tracing header.

Note that this implementation differs from the one in OpenSolaris, so
it is BSD licensed and can be included anywhere.

The kernel definitions defined here are dependent on the kernel option
KDTRACE_HOOKS so that macros added to the sources are pre-processed
out completely when the DTrace kernel hooks aren't compiled in.