[DTrace-devel] [PATCH v2 06/14] test: caller and stackdepth tests for rawtp provider
eugene.loh at oracle.com
eugene.loh at oracle.com
Wed Jun 25 04:20:59 UTC 2025
From: Eugene Loh <eugene.loh at oracle.com>
Also, add skip_rawtp_old.x, to skip rawtp testing on older kernels
for the reasons described in the file.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
---
test/unittest/variables/bvar/skip_rawtp_old.x | 31 +++++++++++++++++++
.../variables/bvar/tst.caller-rawtp.d | 25 +++++++++++++++
.../variables/bvar/tst.caller-rawtp.r | 1 +
.../variables/bvar/tst.caller-rawtp.r.p | 1 +
.../variables/bvar/tst.caller-rawtp.x | 1 +
.../variables/bvar/tst.stackdepth-rawtp.d | 27 ++++++++++++++++
.../variables/bvar/tst.stackdepth-rawtp.r | 1 +
.../variables/bvar/tst.stackdepth-rawtp.r.p | 1 +
.../variables/bvar/tst.stackdepth-rawtp.x | 1 +
9 files changed, 89 insertions(+)
create mode 100755 test/unittest/variables/bvar/skip_rawtp_old.x
create mode 100644 test/unittest/variables/bvar/tst.caller-rawtp.d
create mode 100644 test/unittest/variables/bvar/tst.caller-rawtp.r
create mode 120000 test/unittest/variables/bvar/tst.caller-rawtp.r.p
create mode 120000 test/unittest/variables/bvar/tst.caller-rawtp.x
create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawtp.d
create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawtp.r
create mode 120000 test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p
create mode 120000 test/unittest/variables/bvar/tst.stackdepth-rawtp.x
diff --git a/test/unittest/variables/bvar/skip_rawtp_old.x b/test/unittest/variables/bvar/skip_rawtp_old.x
new file mode 100755
index 000000000..bf7970832
--- /dev/null
+++ b/test/unittest/variables/bvar/skip_rawtp_old.x
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# In older kernels (e.g., UEK6), the BPF helper function had a bug with
+# skipping stack frames. While that many stack frames were correctly
+# skipped on the leaf end of the stack, that many frames were also
+# incorrectly skipped at the root end of the output buffer.
+#
+# Only two DTrace providers ask for a nonzero skip count. One is the
+# fentry/fexit implementation of fbt, but it was not used on such older
+# kernels.
+#
+# The other is rawtp. Therefore, rawtp stack(), caller, and stackdepth
+# results on such older kernels can be incorrect.
+#
+# A few other providers also have some or most probes implemented in
+# terms of rawtp probes. They could have similar problems, depending
+# on which probes are used.
+#
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -gt 5 ]; then
+ exit 0
+fi
+if [ $MAJOR -eq 5 -a $MINOR -ge 10 ]; then
+ exit 0
+fi
+
+echo "rawtp caller, stack(), and stackdepth problematic in old kernels"
+exit 2
diff --git a/test/unittest/variables/bvar/tst.caller-rawtp.d b/test/unittest/variables/bvar/tst.caller-rawtp.d
new file mode 100644
index 000000000..9bc91b67a
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-rawtp.d
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawtp:sched::
+{
+ stack(2);
+ sym(caller);
+ exit(0);
+}
+
+ERROR
+{
+ printf("error encountered\n");
+ exit(1);
+}
diff --git a/test/unittest/variables/bvar/tst.caller-rawtp.r b/test/unittest/variables/bvar/tst.caller-rawtp.r
new file mode 100644
index 000000000..2e9ba477f
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-rawtp.r
@@ -0,0 +1 @@
+success
diff --git a/test/unittest/variables/bvar/tst.caller-rawtp.r.p b/test/unittest/variables/bvar/tst.caller-rawtp.r.p
new file mode 120000
index 000000000..954ca96aa
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-rawtp.r.p
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.caller-rawtp.x b/test/unittest/variables/bvar/tst.caller-rawtp.x
new file mode 120000
index 000000000..37b3ef9f8
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-rawtp.x
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.stackdepth-rawtp.d b/test/unittest/variables/bvar/tst.stackdepth-rawtp.d
new file mode 100644
index 000000000..b99ada9a3
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-rawtp.d
@@ -0,0 +1,27 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawtp:sched::
+{
+ printf("DEPTH %d\n", stackdepth);
+ printf("TRACE BEGIN\n");
+ stack(100);
+ printf("TRACE END\n");
+ exit(0);
+}
+
+ERROR
+{
+ printf("error encountered\n");
+ exit(1);
+}
diff --git a/test/unittest/variables/bvar/tst.stackdepth-rawtp.r b/test/unittest/variables/bvar/tst.stackdepth-rawtp.r
new file mode 100644
index 000000000..3bd29b8ed
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-rawtp.r
@@ -0,0 +1 @@
+Stack depth OK
diff --git a/test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p b/test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p
new file mode 120000
index 000000000..e50f12822
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.stackdepth-rawtp.x b/test/unittest/variables/bvar/tst.stackdepth-rawtp.x
new file mode 120000
index 000000000..37b3ef9f8
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-rawtp.x
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
--
2.43.5
More information about the DTrace-devel
mailing list