[DTrace-devel] [PATCH] Fix progenyof to compare TGIDs
eugene.loh at oracle.com
eugene.loh at oracle.com
Sat Mar 28 16:41:59 UTC 2026
From: Eugene Loh <eugene.loh at oracle.com>
Switch the BPF progenyof helper to read TASK_TGID so it matches the
process IDs returned by ppid and expand the progenyof test to cover both
pid and ppid. The original tst.progenyof.d only exercised probes in the
main DTrace thread where tid == tgid, so it never exposed the mismatch.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
bpf/progenyof.S | 6 +++---
test/unittest/funcs/tst.progenyof2.sh | 31 +++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
create mode 100755 test/unittest/funcs/tst.progenyof2.sh
diff --git a/bpf/progenyof.S b/bpf/progenyof.S
index 5b4ce60fa..8ee76e63c 100644
--- a/bpf/progenyof.S
+++ b/bpf/progenyof.S
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates.
+ * Copyright (c) 2022, 2026, Oracle and/or its affiliates.
*/
#include <bpf_asm_helpers.h>
@@ -34,11 +34,11 @@ dt_progenyof:
/* if (count <= 0) goto Lret0 */
jsle CNT, 0, .Lret0
- /* val = *((uint32_t *)(ptr + TASK_PID)), using [%fp+-8] as temp */
+ /* val = *((uint32_t *)(ptr + TASK_TGID)), using [%fp+-8] as temp */
mov %r1, %fp
add %r1, -8
mov %r2, 4
- lddw %r3, TASK_PID
+ lddw %r3, TASK_TGID
add %r3, PTR
call BPF_FUNC_probe_read
jne %r0, 0, .Lret0
diff --git a/test/unittest/funcs/tst.progenyof2.sh b/test/unittest/funcs/tst.progenyof2.sh
new file mode 100755
index 000000000..1f284cdd8
--- /dev/null
+++ b/test/unittest/funcs/tst.progenyof2.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, 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.
+
+dtrace=$1
+
+DIRNAME="$tmpdir/progenyof2.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# make the trigger
+
+cat << EOF > a.c
+int main(void) {
+ return 0;
+}
+EOF
+$CC $test_cppflags $test_ldflags a.c
+if [ $? -ne 0 ]; then
+ echo ERROR: compiling trigger
+ exit 1
+fi
+
+# check that progenyof(ppid) and progenyof(pid) are nonzero
+
+$dtrace -c ./a.out -qn 'pid$target:a.out:main:* { exit((progenyof(ppid) && progenyof(pid)) ? 0 : 1) }'
+
+exit $?
--
2.47.3
More information about the DTrace-devel
mailing list