test: Allow more variations in expected fbt kernel stacks
PATCH 1/2 test: Allow more variations in expected fbt kernel stacks
From: Eugene Loh <[email protected]>
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
--- test/unittest/stack/tst.stack_fbt.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
test/unittest/stack/tst.stack_fbt.sh +12 -3
@@ -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
Signature · 1 line
2.43.5
PATCH 2/2 test: Account for pid:::entry ustack() being correct
From: Eugene Loh <[email protected]>
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
--- 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
test/unittest/ustack/tst.ustack25_pid.r +1 -0
@@ -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}
test/unittest/ustack/tst.ustack25_pid.r.p new file +37 -0
@@ -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
Signature · 1 line
2.43.5
Re: [PATCH 2/2] test: Account for pid:::entry ustack() being correct
Quoted 7 lines · On Sat, Feb 08, 2025 at 06:21:06PM -0500, [email protected] wrote:
From: Eugene Loh <[email protected]>
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.
Quoted 5 lines
Post process results from this test to accommodate both cases -- missing caller and not missing caller.
Orabug: 37459289
Signed-off-by Eugene Loh <[email protected]>
Quoted 63 lines
--- 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.ptest/unittest/ustack/tst.ustack25_pid.r +1
-0@@ -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}test/unittest/ustack/tst.ustack25_pid.r.p new file +37
-0@@ -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}" }' +fiSignature · 1 line
2.43.5
Quoted 8 lines · On Sat, Feb 08, 2025 at 06:21:05PM -0500, [email protected] wrote:
From: Eugene Loh <[email protected]>
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.
Quoted 5 lines
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 <[email protected]>
Quoted 33 lines
--- test/unittest/stack/tst.stack_fbt.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)test/unittest/stack/tst.stack_fbt.sh +12
-3@@ -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.outSignature · 1 line
2.43.5