From: Sam James <sam@gentoo.org>
To: "eugene.loh--- via DTrace-devel" <dtrace-devel@oss.oracle.com>
Cc: dtrace@lists.linux.dev, eugene.loh@oracle.com
Subject: Re: [DTrace-devel] [PATCH 15/19] Ignore clauses: some clauses are impossible regardless of uprp
Date: Thu, 29 Aug 2024 21:31:57 +0100 [thread overview]
Message-ID: <87ikvjf4ua.fsf@gentoo.org> (raw)
In-Reply-To: <20240829052558.3525-15-eugene.loh@oracle.com> (eugene loh's message of "Thu, 29 Aug 2024 01:25:54 -0400")
"eugene.loh--- via DTrace-devel" <dtrace-devel@oss.oracle.com> writes:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> In ignore_clauses, for an underlying probe uprp, we try to
> decide if we can safely ignore clause n.
>
> Meanwhile, for some clauses, the probe description tells us the
> clause will not be called for any USDT probe, regardless of the
> underlying probe. For example, "syscall::write:" can safely be
> ignored, for all uprp.
>
> Add a dtsd_usdt variable to each statement to track status:
Not that it really matters here, but I wonder why not an enum?
>
> USDT_FLAG_UNINITIALIZED not yet initialized
>
> USDT_FLAG_POSSIBLE clause could possibly be called
> for some USDT probe
>
> USDT_FLAG_IGNORE clause can safely be ignored for
> all USDT probes
>
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> ---
> libdtrace/dt_prov_uprobe.c | 56 ++++++++++++++++++++++++++++++++++++--
> libdtrace/dtrace.h | 1 +
> 2 files changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
> index 883a3e9d..454c53dc 100644
> --- a/libdtrace/dt_prov_uprobe.c
> +++ b/libdtrace/dt_prov_uprobe.c
> @@ -27,6 +27,7 @@
> */
> #include <sys/types.h>
> #include <assert.h>
> +#include <ctype.h>
> #include <errno.h>
> #include <string.h>
>
> @@ -232,6 +233,10 @@ grow_strtab(dtrace_hdl_t *dtp)
> return 0;
> }
>
> +#define USDT_FLAG_UNINITIALIZED 0
> +#define USDT_FLAG_POSSIBLE 1
> +#define USDT_FLAG_IGNORE 2
> +
> /*
> * Judge whether clause "n" could ever be called as a USDT probe
> * for this underlying probe.
> @@ -239,7 +244,53 @@ grow_strtab(dtrace_hdl_t *dtp)
> static int
> ignore_clause(dtrace_hdl_t *dtp, int n, const dt_probe_t *uprp)
> {
> - /* To be safe, ignore nothing. */
> + dtrace_probedesc_t *pdp = &dtp->dt_stmts[n]->dtsd_ecbdesc->dted_probe;
> + int *usdt_stat = &dtp->dt_stmts[n]->dtsd_usdt;
> +
> + /*
> + * Some clauses could never be called for a USDT probe,
> + * regardless of the underlying probe uprp. Cache this
> + * status in dt_stmts[n]->dtsd_usdt (pointed to by usdt_stat).
> + */
> + if (*usdt_stat == USDT_FLAG_UNINITIALIZED) {
> + char lastchar = pdp->prv[strlen(pdp->prv) - 1];
> +
> + /*
> + * If the last char in the provider description is
> + * neither '*' nor a digit, it cannot be a USDT probe.
> + */
> + if (lastchar != '*' && !isdigit(lastchar)) {
> + *usdt_stat = USDT_FLAG_IGNORE;
> + return 1;
> + }
> +
> + /*
> + * If the provider description is "pid[0-9]*", it
> + * is a pid probe, not USDT.
> + */
> + if (strncmp(pdp->prv, "pid", 3) == 0) {
> + int i, l = strlen(pdp->prv);
> +
> + for (i = 3; i < l; i++)
> + if (!isdigit((pdp->prv[i])))
> + break;
> +
> + if (i == l) {
> + *usdt_stat = USDT_FLAG_IGNORE;
> + return 1;
> + }
> + }
> +
> + /* Otherwise, it is possibly a USDT probe. */
> + *usdt_stat = USDT_FLAG_POSSIBLE;
> + }
> + if (*usdt_stat == USDT_FLAG_IGNORE)
> + return 1;
> +
> + /*
> + * If USDT_FLAG_POSSIBLE, try to use uprp.
> + */
> +
> return 0;
> }
>
> @@ -267,7 +318,8 @@ static void update_uprobe(dtrace_hdl_t *dtp, void *datap)
> */
> memset(&pcb, 0, sizeof(dt_pcb_t));
> for (i = 0; i < dtp->dt_clause_nextid; i++)
> - dt_pid_create_probes(&dtp->dt_stmts[i]->dtsd_ecbdesc->dted_probe, dtp, &pcb, 1);
> + if (dtp->dt_stmts[i]->dtsd_usdt != USDT_FLAG_IGNORE)
> + dt_pid_create_probes(&dtp->dt_stmts[i]->dtsd_ecbdesc->dted_probe, dtp, &pcb, 1);
>
> while (prid < dtp->dt_probe_id) {
> dt_bpf_probe_t pinfo;
> diff --git a/libdtrace/dtrace.h b/libdtrace/dtrace.h
> index a23052e4..2de7067f 100644
> --- a/libdtrace/dtrace.h
> +++ b/libdtrace/dtrace.h
> @@ -151,6 +151,7 @@ typedef struct dtrace_stmtdesc {
> dtrace_attribute_t dtsd_stmtattr; /* statement attributes */
> int dtsd_clauseflags; /* clause flags */
> int dtsd_index; /* index in dtp->dt_stmts */
> + int dtsd_usdt; /* flags describing USDT use, see dt_prov_uprobe.c */
> } dtrace_stmtdesc_t;
>
> /* dtsd clause flags */
next prev parent reply other threads:[~2024-08-29 20:32 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 5:25 [PATCH 01/19] Change probes from having lists of clauses to lists of stmts eugene.loh
2024-08-29 5:25 ` [PATCH 02/19] Add a hook for a provider-specific "update" function eugene.loh
2024-08-29 5:25 ` [PATCH 03/19] Widen the EPID to include the PRID eugene.loh
2024-08-29 20:28 ` [DTrace-devel] " Sam James
2024-08-29 20:38 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 04/19] Eliminate dt_pdesc eugene.loh
2024-09-03 17:47 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 05/19] Add flag to dt_pid_create_probes() eugene.loh
2024-09-18 20:33 ` Kris Van Hees
2024-09-24 20:24 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 06/19] Allow for USDT wildcards eugene.loh
2024-09-17 17:34 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 07/19] Create the BPF usdt_prids map eugene.loh
2024-08-29 5:25 ` [PATCH 08/19] Support multiple overlying probes in the uprobe trampoline eugene.loh
2024-10-24 2:42 ` Kris Van Hees
2024-10-24 13:52 ` [DTrace-devel] " Kris Van Hees
2024-10-24 23:30 ` Eugene Loh
2024-10-25 0:14 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 09/19] Use usdt_prids map to call clauses conditionally for USDT probes eugene.loh
2024-08-29 5:25 ` [PATCH 10/19] Remove the is-enabled provider eugene.loh
2024-10-24 15:18 ` Kris Van Hees
2024-10-26 1:13 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 11/19] Support USDT wildcard provider descriptions eugene.loh
2024-08-29 5:25 ` [PATCH 12/19] Increase size of BPF probes map eugene.loh
2024-08-29 20:30 ` [DTrace-devel] " Sam James
2024-10-08 22:15 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 13/19] Get rid of relocatable EPID, dt_nextepid, and dt_ddesc[] eugene.loh
2024-09-03 17:49 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 14/19] Ignore clauses in USDT trampoline if we know they are impossible eugene.loh
2024-08-29 5:25 ` [PATCH 15/19] Ignore clauses: some clauses are impossible regardless of uprp eugene.loh
2024-08-29 20:31 ` Sam James [this message]
2024-09-03 19:54 ` [DTrace-devel] " Eugene Loh
2024-09-03 20:10 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 16/19] Ignore clauses: use underlying probe's function information eugene.loh
2024-10-24 16:52 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 17/19] test: Add a pid-USDT test eugene.loh
2024-08-29 20:32 ` [DTrace-devel] " Sam James
2024-10-04 4:49 ` Eugene Loh
2024-10-04 5:51 ` Sam James
2024-08-29 5:25 ` [PATCH 18/19] test: Add a lazy USDT test eugene.loh
2024-09-28 2:11 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 19/19] test: Add another USDT open/close test eugene.loh
2024-10-24 17:01 ` Kris Van Hees
2024-09-18 14:18 ` [PATCH 01/19] Change probes from having lists of clauses to lists of stmts 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=87ikvjf4ua.fsf@gentoo.org \
--to=sam@gentoo.org \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=eugene.loh@oracle.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.