* [PATCH] Fix progenyof to compare TGIDs
@ 2026-03-28 16:41 eugene.loh
2026-04-14 18:19 ` Nick Alcock
0 siblings, 1 reply; 2+ messages in thread
From: eugene.loh @ 2026-03-28 16:41 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@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@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix progenyof to compare TGIDs
2026-03-28 16:41 [PATCH] Fix progenyof to compare TGIDs eugene.loh
@ 2026-04-14 18:19 ` Nick Alcock
0 siblings, 0 replies; 2+ messages in thread
From: Nick Alcock @ 2026-04-14 18:19 UTC (permalink / raw)
To: dtrace, dtrace-devel
On 28 Mar 2026, eugene loh uttered the following:
> From: Eugene Loh <eugene.loh@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@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
> 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;
> +}
It might in future be worth creating a thread in this test too... and
having a variant which has a process which creates a thread and exec()s
from that thread.
--
NULL && (void)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-14 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-28 16:41 [PATCH] Fix progenyof to compare TGIDs eugene.loh
2026-04-14 18:19 ` Nick Alcock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox