[DTrace-devel] [PATCH] sdt: support min and max kernel versions for probe dependencies
Kris Van Hees
kris.van.hees at oracle.com
Wed Nov 22 20:58:52 UTC 2023
THe underlying probes that are used to trigger SDT probes may be kernel
version dependent. Adding optional minimum and maximum specifications
(using DT_VERSION_NUMBER(x, y, z)) allows us to specify what kernels a
certain dependency can be expected to work on.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_provider_sdt.c | 10 ++++++++++
libdtrace/dt_provider_sdt.h | 8 +++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/libdtrace/dt_provider_sdt.c b/libdtrace/dt_provider_sdt.c
index ebd8b107..823e9b2a 100644
--- a/libdtrace/dt_provider_sdt.c
+++ b/libdtrace/dt_provider_sdt.c
@@ -87,6 +87,16 @@ dt_sdt_enable(dtrace_hdl_t *dtp, dt_probe_t *prp)
if (strcmp(prp->desc->prb, dep->name) != 0)
continue;
+ /*
+ * If the dependency specifies a minimum and/or maximum kernel
+ * version, skip this dependency if the runtime kernel version
+ * does not fall in the specified range.
+ */
+ if (dep->kver_min && dtp->dt_kernver < dep->kver_min)
+ continue;
+ if (dep->kver_max && dtp->dt_kernver > dep->kver_max)
+ continue;
+
if (dtrace_str2desc(dtp, dep->spec, dep->str, &pd) == -1)
return;
diff --git a/libdtrace/dt_provider_sdt.h b/libdtrace/dt_provider_sdt.h
index 86f3b84b..8595e2c8 100644
--- a/libdtrace/dt_provider_sdt.h
+++ b/libdtrace/dt_provider_sdt.h
@@ -19,14 +19,16 @@ extern "C" {
* Probe dependencies
*
* SDT probes are implemented using probes made available by other providers.
- * THe probe dependency table associates each SDT probe with one or more probe
- * specifications (possibly containing wildcards). Each matching probe will
- * have SDT lockstat probe added as a dependent probe.
+ * The probe dependency table associates each SDT probe with one or more probe
+ * specifications (possibly containing wildcards). On optional minimum kernel
+ * version can also be specified (assigned using DT_VERSION_NUMBER(x, y, z)).
*/
typedef struct probe_dep {
const char *name; /* probe name */
dtrace_probespec_t spec; /* spec type */
const char *str; /* spec string */
+ dt_version_t kver_min; /* minimum kernver */
+ dt_version_t kver_max; /* maximum kernver */
} probe_dep_t;
/*
--
2.39.3
More information about the DTrace-devel
mailing list