Prior to this change the lockstat provider created using a custom
provider. This is done in illumos because lockstat uses some special
hot-patching techniques for probe sites, but that doesn't apply in
FreeBSD, so there's no reason to use a separate provider implementation.
Reimplementing the lockstat probes in terms of SDT(9) provides the
following benefits:
- less code
- argument type info: currently the lockstat probes carry no type info
- improved performance when we switch to hot-patching SDT probe sites (currently a WIP)
While here, I've fixed a few bugs and nits at the probe sites, mostly
based on the upstream documentation:
https://wikis.oracle.com/display/DTrace/lockstat+Provider
In particular, this change
- removes some unnecessary #ifdef KDTRACE_HOOKS usages: the lockstat macros expand to nothing if KDTRACE_HOOKS is not defined.
- removes some unnecessary "if (spin_cnt > sleep_cnt)" conditionals: this condition is always true since spin_cnt is incremented at least once per loop body, while sleep_cnt is incremented once every time the thread blocks on a turnstile or enter a sleepqueue.
- removes some unneeded parentheses around probe arguments.
- ensures that a "block" probe fires before the corresponding "acquire" probe, as explicitly stated in the docs.
- adds extra probe arguments to the rwlock block probe as documented above. Specifically, we define constants, LOCKSTAT_READER and LOCKSTAT_WRITER which correspond to the RW_{READER,WRITER} constants in the docs; the values are chosen based on the lockstat(1) code. These are used as probe arguments to indicate whether a read or write lock is being taken. Other probe arguments specify whether a writer held the lock when the current thread blocked, and the number of readers at the time the current thread blocked.