[DTrace-devel] [PATCH] probe: ensure probe argument info is retrieved only once per probe

Eugene Loh eugene.loh at oracle.com
Thu Feb 16 19:46:35 UTC 2023


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 2/16/23 10:54, Kris Van Hees via DTrace-devel wrote:
> Throughout the compilation process there are multiple points where
> probe argument information is requested from the providers.  This
> data cannot change during a runtime of DTrace and there is therefore
> no reason to go through the process of retrieving it more than once.
>
> The prp->argc (probe argument count) is used to determine if argument
> data has been obtained.  It is initially -1, and will be 0 or greater
> once argument data has been requested.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_probe.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libdtrace/dt_probe.c b/libdtrace/dt_probe.c
> index 3594097e..58b26836 100644
> --- a/libdtrace/dt_probe.c
> +++ b/libdtrace/dt_probe.c
> @@ -695,6 +695,7 @@ dt_probe_insert(dtrace_hdl_t *dtp, dt_provider_t *prov, const char *prv,
>   	prp->desc = desc;
>   	prp->prov = prov;
>   	prp->prv_data = datap;
> +	prp->argc = -1;
>   
>   	dt_htab_insert(dtp->dt_byprv, prp);
>   	dt_htab_insert(dtp->dt_bymod, prp);
> @@ -865,13 +866,18 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
>   	int			i, nc, xc;
>   	dtrace_typeinfo_t	dtt;
>   
> +	/* Only retrieve probe argument information once per probe. */
> +	if (prp->argc != -1)
> +		return;
>   	if (!prp->prov->impl->probe_info)
>   		return;
>   	if (prp->prov->impl->probe_info(dtp, prp, &argc, &argv) < 0)
>   		return;
>   
> -	if (!argc || !argv)
> +	if (!argc || !argv) {
> +		prp->argc = 0;
>   		return;
> +	}
>   
>   	nc = 0;
>   	for (xc = 0; xc < argc; xc++)



More information about the DTrace-devel mailing list