Skip to content

Commit

Permalink
sdt: support min and max kernel versions for probe dependencies
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Jan 3, 2024
1 parent c30641e commit c99bce8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions libdtrace/dt_provider_sdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions libdtrace/dt_provider_sdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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). An optional min and/or max
* kernel version can 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;

/*
Expand Down

0 comments on commit c99bce8

Please sign in to comment.