From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 14/19] Ignore clauses in USDT trampoline if we know they are impossible
Date: Thu, 29 Aug 2024 01:25:53 -0400 [thread overview]
Message-ID: <20240829052558.3525-14-eugene.loh@oracle.com> (raw)
In-Reply-To: <20240829052558.3525-1-eugene.loh@oracle.com>
From: Eugene Loh <eugene.loh@oracle.com>
An underlying probe might have to call all sorts of clauses if new
USDT processes start up. Currently, the underlying probe trampoline
simply loops over all clauses, deciding whether to call a clause
based on a run-time bit mask.
While this approach works, it can mean, e.g., that clauses are being
loaded unnecessarily into BPF programs, bloating code. It also means
that the trampoline is looping over unnecessarily many clauses.
Meanwhile, it is possible to know in certain cases that a clause
could never be called for a particular underlying probe. The
heuristics can be tricky, but that challenge can be faced incrementally.
Introduce an ignore_clause() function that, for an underlying probe,
determines whether some clause (denoted by index) can safely be
ignored.
The same ignore_clause() function should be called both during code
generation of the trampoline as well as during the construction of
the bit mask. Further, for a given clause n and underlying probe upp,
the function should always give the same output. The set of ignored
clauses should remain fixed over the lifetime of an underlying probe.
For now, conservatively, ignore_clause() ignores nothing. Later
patches will introduce heuristics for ignoring clauses.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
libdtrace/dt_prov_uprobe.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
index 98d7b79b..883a3e9d 100644
--- a/libdtrace/dt_prov_uprobe.c
+++ b/libdtrace/dt_prov_uprobe.c
@@ -232,6 +232,17 @@ grow_strtab(dtrace_hdl_t *dtp)
return 0;
}
+/*
+ * Judge whether clause "n" could ever be called as a USDT probe
+ * for this underlying probe.
+ */
+static int
+ignore_clause(dtrace_hdl_t *dtp, int n, const dt_probe_t *uprp)
+{
+ /* To be safe, ignore nothing. */
+ return 0;
+}
+
/*
* Update the uprobe provider.
*/
@@ -348,6 +359,9 @@ static void update_uprobe(dtrace_hdl_t *dtp, void *datap)
int n;
for (n = 0; n < dtp->dt_clause_nextid; n++) {
+ if (ignore_clause(dtp, n, uprp))
+ continue;
+
if (dt_gmatch(prp->desc->prv, dtp->dt_stmts[n]->dtsd_ecbdesc->dted_probe.prv) &&
dt_gmatch(prp->desc->mod, dtp->dt_stmts[n]->dtsd_ecbdesc->dted_probe.mod) &&
dt_gmatch(prp->desc->fun, dtp->dt_stmts[n]->dtsd_ecbdesc->dted_probe.fun) &&
@@ -803,7 +817,12 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
*/
for (n = 0; n < dtp->dt_clause_nextid; n++) {
dt_ident_t *idp = dtp->dt_stmts[n]->dtsd_clause;
- uint_t lbl_next = dt_irlist_label(dlp);
+ uint_t lbl_next;
+
+ if (ignore_clause(dtp, n, uprp))
+ continue;
+
+ lbl_next = dt_irlist_label(dlp);
/* If the lowest %r6 bit is 0, skip over this clause. */
emit(dlp, BPF_MOV_REG(BPF_REG_1, BPF_REG_6));
--
2.43.5
next prev parent reply other threads:[~2024-08-29 5:26 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 ` eugene.loh [this message]
2024-08-29 5:25 ` [PATCH 15/19] Ignore clauses: some clauses are impossible regardless of uprp eugene.loh
2024-08-29 20:31 ` [DTrace-devel] " Sam James
2024-09-03 19:54 ` 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=20240829052558.3525-14-eugene.loh@oracle.com \
--to=eugene.loh@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