All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks
@ 2025-02-08 23:21 eugene.loh
  2025-02-08 23:21 ` [PATCH 2/2] test: Account for pid:::entry ustack() being correct eugene.loh
  2025-02-28 15:47 ` [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks Kris Van Hees
  0 siblings, 2 replies; 4+ messages in thread
From: eugene.loh @ 2025-02-08 23:21 UTC (permalink / raw)
  To: dtrace, dtrace-devel

From: Eugene Loh <eugene.loh@oracle.com>

This test checks the call stack upon entry to vfs_write().
Unfortunately, these checks require some maintenance since the call
stack can vary -- slightly or greatly -- depending on processor or
kernel.  There is a competition between ease of test maintenance and
strictness of correctness checks.

Adapt post processing of output to allow new variations in stacks
seen in UEK 8 (currently Linux 6.12).

Orabug: 37459289
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 test/unittest/stack/tst.stack_fbt.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/unittest/stack/tst.stack_fbt.sh b/test/unittest/stack/tst.stack_fbt.sh
index c365e14d6..8a0b7999c 100755
--- a/test/unittest/stack/tst.stack_fbt.sh
+++ b/test/unittest/stack/tst.stack_fbt.sh
@@ -37,9 +37,18 @@ if [ $? -ne 0 ]; then
 	exit 1
 fi
 
-# Strip out blank lines and pointer values.
-
-awk 'NF != 0 { sub(/+0x[0-9a-f]*$/, "+{ptr}"); print }' dtrace.out > dtrace.post
+# Strip out
+# - blank lines
+# - "constprop"
+# - "isra"
+# - "_after_hwframe"    (x86 starting with UEK8)
+# - pointer values
+
+awk 'NF != 0 { sub("\\.constprop\\.[0-9]", "");
+               sub("\\.isra\\.[0-9]", "");
+               sub("_after_hwframe\\+", "+");
+               sub(/+0x[0-9a-f]*$/, "+{ptr}");
+               print }' dtrace.out > dtrace.post
 if [ $? -ne 0 ]; then
 	echo ERROR: awk failed
 	cat dtrace.out
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] test: Account for pid:::entry ustack() being correct
  2025-02-08 23:21 [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks eugene.loh
@ 2025-02-08 23:21 ` eugene.loh
  2025-02-28 16:00   ` Kris Van Hees
  2025-02-28 15:47 ` [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks Kris Van Hees
  1 sibling, 1 reply; 4+ messages in thread
From: eugene.loh @ 2025-02-08 23:21 UTC (permalink / raw)
  To: dtrace, dtrace-devel

From: Eugene Loh <eugene.loh@oracle.com>

The pid:::entry uprobe fires so early in the function preamble
that the frame pointer is not yet set and the caller is not (yet)
correctly identified.  In Linux 6.11, x86-specific heuristics
address this problem.

Post process results from this test to accommodate both cases --
missing caller and not missing caller.

Orabug: 37459289
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 test/unittest/ustack/tst.ustack25_pid.r   |  1 +
 test/unittest/ustack/tst.ustack25_pid.r.p | 37 +++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100755 test/unittest/ustack/tst.ustack25_pid.r.p

diff --git a/test/unittest/ustack/tst.ustack25_pid.r b/test/unittest/ustack/tst.ustack25_pid.r
index 89b35c028..e7732fb81 100644
--- a/test/unittest/ustack/tst.ustack25_pid.r
+++ b/test/unittest/ustack/tst.ustack25_pid.r
@@ -1,5 +1,6 @@
 
               ustack-tst-basic`myfunc_z
+              ustack-tst-basic`myfunc_y+{ptr}
               ustack-tst-basic`myfunc_x+{ptr}
               ustack-tst-basic`myfunc_w+{ptr}
               ustack-tst-basic`myfunc_v+{ptr}
diff --git a/test/unittest/ustack/tst.ustack25_pid.r.p b/test/unittest/ustack/tst.ustack25_pid.r.p
new file mode 100755
index 000000000..6486f7ec6
--- /dev/null
+++ b/test/unittest/ustack/tst.ustack25_pid.r.p
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# A pid entry probe places a uprobe on the first instruction of a function.
+# Unfortunately, this is so early in the function preamble that the function
+# frame pointer has not yet been established and the actual caller of the
+# traced function is missed.
+#
+# In Linux 6.11, x86-specific heuristics are introduced to fix this problem.
+# See commit cfa7f3d
+# ("perf,x86: avoid missing caller address in stack traces captured in uprobe")
+# for both a description of the problem and an explanation of the heuristics.
+#
+# Add post processing to these test results to allow for both cases:
+# caller frame is missing or not missing.
+
+missing_caller=1
+if [ $(uname -m) == "x86_64" ]; then
+        read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+        if [ $MAJOR -ge 6 ]; then
+                if [ $MAJOR -gt 6 -o $MINOR -ge 11 ]; then
+                        missing_caller=0
+                fi
+        fi
+fi
+
+if [ $missing_caller -eq 1 ]; then
+        # Add the missing caller function after the current function.
+        awk '{ print }
+             /myfunc_z/ { print "              ustack-tst-basic`myfunc_y+{ptr}" }'
+else
+        # The .r results file has an extra frame at the end in case
+        # the caller frame is missing and the 25-frame limit goes
+        # "too far."  If the caller is not missing, fake that extra frame.
+        awk '{ print }
+             /myfunc_b/ { print "              ustack-tst-basic`myfunc_a+{ptr}" }'
+fi
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks
  2025-02-08 23:21 [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks eugene.loh
  2025-02-08 23:21 ` [PATCH 2/2] test: Account for pid:::entry ustack() being correct eugene.loh
@ 2025-02-28 15:47 ` Kris Van Hees
  1 sibling, 0 replies; 4+ messages in thread
From: Kris Van Hees @ 2025-02-28 15:47 UTC (permalink / raw)
  To: eugene.loh; +Cc: dtrace, dtrace-devel

On Sat, Feb 08, 2025 at 06:21:05PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> This test checks the call stack upon entry to vfs_write().
> Unfortunately, these checks require some maintenance since the call
> stack can vary -- slightly or greatly -- depending on processor or
> kernel.  There is a competition between ease of test maintenance and
> strictness of correctness checks.
> 
> Adapt post processing of output to allow new variations in stacks
> seen in UEK 8 (currently Linux 6.12).
> 
> Orabug: 37459289
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>

> ---
>  test/unittest/stack/tst.stack_fbt.sh | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/test/unittest/stack/tst.stack_fbt.sh b/test/unittest/stack/tst.stack_fbt.sh
> index c365e14d6..8a0b7999c 100755
> --- a/test/unittest/stack/tst.stack_fbt.sh
> +++ b/test/unittest/stack/tst.stack_fbt.sh
> @@ -37,9 +37,18 @@ if [ $? -ne 0 ]; then
>  	exit 1
>  fi
>  
> -# Strip out blank lines and pointer values.
> -
> -awk 'NF != 0 { sub(/+0x[0-9a-f]*$/, "+{ptr}"); print }' dtrace.out > dtrace.post
> +# Strip out
> +# - blank lines
> +# - "constprop"
> +# - "isra"
> +# - "_after_hwframe"    (x86 starting with UEK8)
> +# - pointer values
> +
> +awk 'NF != 0 { sub("\\.constprop\\.[0-9]", "");
> +               sub("\\.isra\\.[0-9]", "");
> +               sub("_after_hwframe\\+", "+");
> +               sub(/+0x[0-9a-f]*$/, "+{ptr}");
> +               print }' dtrace.out > dtrace.post
>  if [ $? -ne 0 ]; then
>  	echo ERROR: awk failed
>  	cat dtrace.out
> -- 
> 2.43.5
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] test: Account for pid:::entry ustack() being correct
  2025-02-08 23:21 ` [PATCH 2/2] test: Account for pid:::entry ustack() being correct eugene.loh
@ 2025-02-28 16:00   ` Kris Van Hees
  0 siblings, 0 replies; 4+ messages in thread
From: Kris Van Hees @ 2025-02-28 16:00 UTC (permalink / raw)
  To: eugene.loh; +Cc: dtrace, dtrace-devel

On Sat, Feb 08, 2025 at 06:21:06PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> The pid:::entry uprobe fires so early in the function preamble
> that the frame pointer is not yet set and the caller is not (yet)
> correctly identified.  In Linux 6.11, x86-specific heuristics
> address this problem.
> 
> Post process results from this test to accommodate both cases --
> missing caller and not missing caller.
> 
> Orabug: 37459289
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>

> ---
>  test/unittest/ustack/tst.ustack25_pid.r   |  1 +
>  test/unittest/ustack/tst.ustack25_pid.r.p | 37 +++++++++++++++++++++++
>  2 files changed, 38 insertions(+)
>  create mode 100755 test/unittest/ustack/tst.ustack25_pid.r.p
> 
> diff --git a/test/unittest/ustack/tst.ustack25_pid.r b/test/unittest/ustack/tst.ustack25_pid.r
> index 89b35c028..e7732fb81 100644
> --- a/test/unittest/ustack/tst.ustack25_pid.r
> +++ b/test/unittest/ustack/tst.ustack25_pid.r
> @@ -1,5 +1,6 @@
>  
>                ustack-tst-basic`myfunc_z
> +              ustack-tst-basic`myfunc_y+{ptr}
>                ustack-tst-basic`myfunc_x+{ptr}
>                ustack-tst-basic`myfunc_w+{ptr}
>                ustack-tst-basic`myfunc_v+{ptr}
> diff --git a/test/unittest/ustack/tst.ustack25_pid.r.p b/test/unittest/ustack/tst.ustack25_pid.r.p
> new file mode 100755
> index 000000000..6486f7ec6
> --- /dev/null
> +++ b/test/unittest/ustack/tst.ustack25_pid.r.p
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +# A pid entry probe places a uprobe on the first instruction of a function.
> +# Unfortunately, this is so early in the function preamble that the function
> +# frame pointer has not yet been established and the actual caller of the
> +# traced function is missed.
> +#
> +# In Linux 6.11, x86-specific heuristics are introduced to fix this problem.
> +# See commit cfa7f3d
> +# ("perf,x86: avoid missing caller address in stack traces captured in uprobe")
> +# for both a description of the problem and an explanation of the heuristics.
> +#
> +# Add post processing to these test results to allow for both cases:
> +# caller frame is missing or not missing.
> +
> +missing_caller=1
> +if [ $(uname -m) == "x86_64" ]; then
> +        read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
> +
> +        if [ $MAJOR -ge 6 ]; then
> +                if [ $MAJOR -gt 6 -o $MINOR -ge 11 ]; then
> +                        missing_caller=0
> +                fi
> +        fi
> +fi
> +
> +if [ $missing_caller -eq 1 ]; then
> +        # Add the missing caller function after the current function.
> +        awk '{ print }
> +             /myfunc_z/ { print "              ustack-tst-basic`myfunc_y+{ptr}" }'
> +else
> +        # The .r results file has an extra frame at the end in case
> +        # the caller frame is missing and the 25-frame limit goes
> +        # "too far."  If the caller is not missing, fake that extra frame.
> +        awk '{ print }
> +             /myfunc_b/ { print "              ustack-tst-basic`myfunc_a+{ptr}" }'
> +fi
> -- 
> 2.43.5
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-28 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-08 23:21 [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks eugene.loh
2025-02-08 23:21 ` [PATCH 2/2] test: Account for pid:::entry ustack() being correct eugene.loh
2025-02-28 16:00   ` Kris Van Hees
2025-02-28 15:47 ` [PATCH 1/2] test: Allow more variations in expected fbt kernel stacks Kris Van Hees

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.