[DTrace-devel] [PATCH] test: Have manyprobes clean up uprobes
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue May 30 18:53:51 UTC 2023
From: Eugene Loh <eugene.loh at oracle.com>
Once dtprobed cleans uprobes up automatically, this hack will no longer
be needed. Meanwhile, we have to clean up lest a few runs of this test
lead to denial of service.
Note that the test did try to clean up uprobes but it referred to
uprobe_events with an incorrect pathname (leading to ineffectual cleanup
and, on some systems, test failures) and it cleaned up all uprobes, even
ones not created by this test.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
test/unittest/usdt/tst.manyprobes.sh | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/test/unittest/usdt/tst.manyprobes.sh b/test/unittest/usdt/tst.manyprobes.sh
index 14bf9128..9acf251f 100755
--- a/test/unittest/usdt/tst.manyprobes.sh
+++ b/test/unittest/usdt/tst.manyprobes.sh
@@ -60,7 +60,12 @@ fi
script()
{
- $dtrace -c ./test -qs /dev/stdin <<EOF
+ $dtrace -o D.output -c ./test -qs /dev/stdin <<EOF
+ BEGIN
+ {
+ /* Dump pid for the clean-up hack we use. */
+ printf("pid is %d\n", \$target);
+ }
manyprobes\$target:::test1, manyprobes\$target:::test750, manyprobes\$target:::test1999
{
printf("%s:%s:%s\n", probemod, probefunc, probename);
@@ -71,7 +76,17 @@ EOF
script
status=$?
-# Temporary, until autocleanup is implemented
-echo - > /sys/kernel/tracing/uprobe_events 2>/dev/null
+# D.output has the pid we need for the clean-up hack. Display the output minus
+# that pid information for checking with the .r results file. Once uprobe cleanup
+# has been automated, the pid info and D.output will not be needed.
+grep -v "pid is " D.output
+
+# Here is the clean-up hack for uprobe_events until dtprobed does clean up.
+# Find the events for the specified pid and eliminate them.
+pid=`awk '/pid is / {print $3}' D.output`
+uprobes=/sys/kernel/debug/tracing/uprobe_events
+for x in `awk '/^p:dt_pid\/.* \/proc\/'$pid'\/map_files\// { sub("^p:", "-:"); print $1 }' $uprobes`; do
+ echo $x >> $uprobes
+done
exit $status
--
2.18.4
More information about the DTrace-devel
mailing list