Linux DTrace development list
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v5 03/11] libdtrace: avoid BTF probes for ranged built-in modules
Date: Wed, 7 Oct 2026 10:20:49 +0000	[thread overview]
Message-ID: <asYdAbzPN9i-OSFN@kvh-deb-bpf> (raw)
In-Reply-To: <20260821161100.41710-4-alan.maguire@oracle.com>

Some questions below.

On Fri, Aug 21, 2026 at 05:10:51PM +0100, Alan Maguire wrote:
> When /proc/kallsyms is used with modules.builtin.ranges, libdtrace can
> attribute symbols linked into vmlinux to their individual built-in objects,
> such as bitrev or atomic64_test.  This creates module objects for those
> names.
> 
> These objects have no per-module BTF file under /sys/kernel/btf.  Avoid
> probing for one when modules.builtin.ranges has identified the module as
> built in, and use the shared vmlinux BTF directly instead.
> 
> Keep the existing lookup path for loadable modules and for an explicitly
> configured BTF directory.
> 
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
>  libdtrace/dt_btf.c    |  8 ++++++--
>  libdtrace/dt_impl.h   |  1 +
>  libdtrace/dt_module.c | 20 +++++++++++++++++++-
>  3 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/libdtrace/dt_btf.c b/libdtrace/dt_btf.c
> index e7980969..93ecf5cd 100644
> --- a/libdtrace/dt_btf.c
> +++ b/libdtrace/dt_btf.c
> @@ -915,8 +915,12 @@ dt_btf_module_ctf(dtrace_hdl_t *dtp, dt_module_t *dmp)
>  	if (!dtp->dt_shared_ctf && dtp->dt_shared_btf && btf == dtp->dt_shared_btf)
>  		dtp->dt_shared_ctf = ctf;
>  
> -	dt_dprintf("Generated %s CTF from BTF (%d types).\n", dmp->dm_name,
> -		   btf->type_cnt);
> +	if (btf == dtp->dt_shared_btf && strcmp(dmp->dm_name, "vmlinux") != 0)
> +		dt_dprintf("Created %s CTF import from shared vmlinux BTF.\n",
> +		    dmp->dm_name);
> +	else
> +		dt_dprintf("Generated %s CTF from BTF (%d types).\n", dmp->dm_name,
> +		    btf->type_cnt);
>  #endif
>  
>  	return ctf;
> diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
> index 7ccdc271..38c5ff0b 100644
> --- a/libdtrace/dt_impl.h
> +++ b/libdtrace/dt_impl.h
> @@ -201,6 +201,7 @@ typedef struct dt_kern_path {
>  #define DT_DM_KERNEL		0x2	/* module is associated with a kernel object */
>  #define DT_DM_CTF_ARCHIVED	0x4	/* module found in a CTF archive */
>  #define DT_DM_KERN_UNLOADED	0x8	/* module not loaded into the kernel */
> +#define DT_DM_KERN_BUILTIN	0x10	/* module is linked into vmlinux */
>  
>  /*
>   * Why do we need (only) 4 slots?  The maximum amount of string arguments to
> diff --git a/libdtrace/dt_module.c b/libdtrace/dt_module.c
> index 00978911..ea6d56c3 100644
> --- a/libdtrace/dt_module.c
> +++ b/libdtrace/dt_module.c
> @@ -871,6 +871,19 @@ dt_kern_module_find_btf(dtrace_hdl_t *dtp, dt_module_t *dmp)
>  	if (dtp->dt_shared_btf == NULL && strcmp(dmp->dm_name, "vmlinux") != 0)
>  		return;
>  
> +	/*
> +	 * modules.builtin.ranges identifies this object as linked into vmlinux.
> +	 * Such objects cannot have a per-module BTF object, so use the shared
> +	 * vmlinux BTF directly.  Retain the usual lookup for an explicitly
> +	 * configured BTF directory and every other module.
> +	 */
> +	if (dtp->dt_btf_path == NULL && (dmp->dm_flags & DT_DM_KERN_BUILTIN)) {
> +		dmp->dm_btf = dtp->dt_shared_btf;
> +		dt_dprintf("Using shared vmlinux BTF for built-in module %s.\n",
> +		    dmp->dm_name);
> +		return;
> +	}

This does not look right to me, because if a dt_btf_path is specified, I
would expect the handle to still provided a handle-wide shared CTF and
BTF, even if it may be different from the system-wide shared CTF and
BTF.  In other words, I think that sharing should be based on:

System standard CTF and BTF -> dt_shared_ctf and dt_share_btf globals
Non-standard CTF or BTF -> dtp->dt_shared_ctf and dtp->dt_shared_btf

So dropping the dtp->dt_btf_path == NULL in the conditional clause above
should be fine, right?

> +
>  	dt_dprintf("Loading BTF for module %s.\n", dmp->dm_name);
>  
>  	/*
> @@ -1405,6 +1418,7 @@ dt_modsym_update(dtrace_hdl_t *dtp, const char *line, dt_kasstate_t *state)
>  {
>  	dt_kallsym_t	sym;
>  	char		*modname;
> +	int		builtin = 0;
>  
>  	if ((line[0] == '\n') || (line[0] == 0))
>  		return 0;
> @@ -1440,8 +1454,10 @@ dt_modsym_update(dtrace_hdl_t *dtp, const char *line, dt_kasstate_t *state)
>  			char	*s;
>  
>  			s = dt_kasstate_modname(state, sym.addr, sym.name);
> -			if (s != NULL)
> +			if (s != NULL) {
>  				strncpy(sym.mod, s, PATH_MAX);
> +				builtin = 1;
> +			}
>  		}
>  	}
>  
> @@ -1511,6 +1527,8 @@ dt_modsym_update(dtrace_hdl_t *dtp, const char *line, dt_kasstate_t *state)
>  			if (err != 0)
>  				return err;
>  		}
> +		if (builtin)
> +			dmp->dm_flags |= DT_DM_KERN_BUILTIN;
>  
>  		err = dt_modsym_addsym(dtp, dmp, &sym, state);
>  		if (err != 0)
> -- 
> 2.43.5
> 

  reply	other threads:[~2026-10-07 10:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 16:10 [PATCH v5 00/11] Add python, PCP support via libdtrace interfaces Alan Maguire
2026-08-21 16:10 ` [PATCH v5 01/11] libdtrace: Support multiple DTrace handles per process Alan Maguire
2026-10-07  9:26   ` Kris Van Hees
2026-08-21 16:10 ` [PATCH v5 02/11] libdtrace: share vmlinux BTF/CTF globally to support faster startup Alan Maguire
2026-10-07 10:05   ` Kris Van Hees
2026-08-21 16:10 ` [PATCH v5 03/11] libdtrace: avoid BTF probes for ranged built-in modules Alan Maguire
2026-10-07 10:20   ` Kris Van Hees [this message]
2026-08-21 16:10 ` [PATCH v5 04/11] libdtrace: Add aggregation key/value computation APIs Alan Maguire
2026-10-07 10:51   ` Kris Van Hees
2026-08-21 16:10 ` [PATCH v5 05/11] python: Add cpython bindings for libdtrace Alan Maguire
2026-10-05 16:23   ` Kris Van Hees
2026-08-21 16:10 ` [PATCH v5 06/11] dtrace.spec: add python bindings packaging Alan Maguire
2026-08-21 16:10 ` [PATCH v5 07/11] runtest.sh: Prepare Python bindings for in-tree testing Alan Maguire
2026-08-21 16:10 ` [PATCH v5 08/11] test: add tests for python bindings Alan Maguire
2026-08-21 16:10 ` [PATCH v5 09/11] dtrace: Add a PCP PMDA to expose DTrace data as metrics Alan Maguire
2026-08-21 16:10 ` [PATCH v5 10/11] dtrace.spec: Add PCP PMDA packaging pcp-pmda-dtrace Alan Maguire
2026-08-21 16:10 ` [PATCH v5 11/11] test: Add a test for the PCP ManagedDTraceScript interface Alan Maguire
2026-10-05 16:28   ` Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asYdAbzPN9i-OSFN@kvh-deb-bpf \
    --to=kris.van.hees@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox