[DTrace-devel] [PATCH v2 6/8] fbt: performance improvements
Eugene Loh
eugene.loh at oracle.com
Tue Mar 18 01:58:29 UTC 2025
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Also...
One patch or another needs to update the dt_module.[c|h] copyright years.
On 1/14/25 23:21, Kris Van Hees wrote:
> Up until now, FBT probes were registered for every symbol that was
> listed as traceable. Most tracing session do not use most or even
s/session/sessions/
> any of these, and the process of registering them all was quite
> slow.
>
> diff --git a/libdtrace/dt_module.c b/libdtrace/dt_module.c
> @@ -1044,6 +1045,83 @@ dt_kern_module_find_ctf(dtrace_hdl_t *dtp, dt_module_t *dmp)
> }
> }
>
> +#define PROBE_LIST TRACEFS "available_filter_functions"
> +
> +/*
> + * Determine which kernel functions are traceable and mark them.
> + */
> +void
> +dt_modsym_mark_traceable(dtrace_hdl_t *dtp)
> +{
> + FILE *f;
> + char *buf = NULL;
> + size_t len = 0;
> +
> + if (dt_symtab_traceable(dtp->dt_exec->dm_kernsyms))
> + return;
> +
> + f = fopen(PROBE_LIST, "r");
> + if (f == NULL)
> + return;
> +
> + while (getline(&buf, &len, f) >= 0) {
> + char *p;
> + dt_symbol_t *sym = NULL;
> +
> + /*
> + * Here buf is either "funcname\n" or "funcname [modname]\n".
> + * The last line may not have a linefeed.
> + */
> + p = strchr(buf, '\n');
> + if (p) {
> + *p = '\0';
> + if (p > buf && *(--p) == ']')
> + *p = '\0';
> + }
> +
> + /*
> + * Now buf is either "funcname" or "funcname [modname". If
> + * there is no module name provided, we will use the default.
> + */
Maybe that second sentence is now orphaned?
> + p = strchr(buf, ' ');
> + if (p) {
> + *p++ = '\0';
> + if (*p == '[')
> + p++;
> + }
> +
> diff --git a/libdtrace/dt_prov_fbt.c b/libdtrace/dt_prov_fbt.c
> @@ -81,79 +71,166 @@ static int populate(dtrace_hdl_t *dtp)
> if (prv == NULL)
> return -1; /* errno already set */
>
> - f = fopen(PROBE_LIST, "r");
> - if (f == NULL)
> + return 0;
> +}
> +
> +/* Create a probe (if it does not exist yet). */
> +static int provide_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)
> +{
> + dt_provider_t *prv = dt_provider_lookup(dtp, pdp->prv);
> +
> + if (prv == NULL)
> + return 0;
> + if (dt_probe_lookup(dtp, pdp) != NULL)
> return 0;
> + if (dt_tp_probe_insert(dtp, prv, pdp->prv, pdp->mod, pdp->fun, pdp->prb))
> + return 1;
>
> - while (getline(&buf, &n, f) >= 0) {
> - /*
> - * Here buf is either "funcname\n" or "funcname [modname]\n".
> - * The last line may not have a linefeed.
> - */
> - p = strchr(buf, '\n');
> - if (p) {
> - *p = '\0';
> - if (p > buf && *(--p) == ']')
> - *p = '\0';
> + return 0;
> +}
> +
> +/*
> + * Try to provide probes for the given probe description. The caller ensures
> + * that the provider name in probe desxcription (if any) is a match for this
desxcription
description
> + * provider. When this is called, we already know that this provider matches
> + * the provider component of the probe specification.
> + */
More information about the DTrace-devel
mailing list