[DTrace-devel] [PATCH 10/20] libdtrace: retain descriptors for cached module BTF IDs

Kris Van Hees kris.van.hees at oracle.com
Sat Nov 7 15:59:10 UTC 2026


On Fri, Nov 06, 2026 at 12:59:41PM +0000, Nix wrote:
> On 30 Oct 2026, Kris Van Hees outgrape:
> 
> > ---
> >  libdtrace/dt_btf.c               | 79 ++++++++++++++++++++++++++++++--
> >  libdtrace/dt_impl.h              |  1 +
> >  libdtrace/dt_open.c              |  1 +
> >  test/triggers/module-discovery.c | 11 +++++
> >  4 files changed, 88 insertions(+), 4 deletions(-)
> >
> > diff --git a/libdtrace/dt_btf.c b/libdtrace/dt_btf.c
> > index 617b0128..727e5f54 100644
> > --- a/libdtrace/dt_btf.c
> > +++ b/libdtrace/dt_btf.c
> > @@ -1479,17 +1479,67 @@ dt_btf_lookup_name_kind(dtrace_hdl_t *dtp, dt_module_t *dmp, const char *name,
> >  	return id;
> >  }
> >  
> > +/*
> > + * Retain a descriptor as well as the ID: otherwise an unloaded object's ID
> > + * could be reused and a later enumeration could mistake it for a cached one.
> > + * Only IDs assigned to modules are retained, bounding descriptor use by the
> > + * number of modules discovered by this handle.
> > + */
> 
> I suppose just not reusing IDs in general, and having them only
> increment, would end up using too many? (I can't remember under what
> circumstances they're reused, but I didn't think it was *common*.)

The thing is that we have no control over the IDs...  They are provided
by the BTF subsystem, and we should not make any assumptions about them
in terms of wether they could be reused or not.

> How it interacts with the earlier change to never remove dt_modules when
> their corresponding kernel module is unloaded is unclear to me -- is
> this the bit that ensures that an unloaded module never gets reused (and
> instead we load a new one if the module is reloaded into the kernel), or
> what?

This really has to do with the way the BTF subsystem handles modules and
associates IDs with them.  OUr own view of modules is independent from
that.



More information about the DTrace-devel mailing list