From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v2] test: Account for large stack-limit kernel parameter
Date: Mon, 13 Oct 2025 15:15:18 -0400 [thread overview]
Message-ID: <aO1PxpMjm7ng0KUe@oracle.com> (raw)
In-Reply-To: <20251009213342.31010-1-eugene.loh@oracle.com>
On Thu, Oct 09, 2025 at 05:33:42PM -0400, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> In commit d0fdeec50 ("test: Fix some ustackdepth tests"), the test was
> tweaked to check that the full stack would be recovered if the kernel
> stack-limit parameter were increased from a default 127 to greater than
> about 190 frames. But this does not work if the system already has
> reset the kernel parameter to a high value.
>
> Change the test to deliberately try a "too small" and a "big enough"
> value -- again, ultimately restoring the original value.
>
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> .../variables/bvar/tst.ustackdepth_big.sh | 106 +++++++++++-------
> 1 file changed, 68 insertions(+), 38 deletions(-)
>
> diff --git a/test/unittest/variables/bvar/tst.ustackdepth_big.sh b/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> index 4ce53d929..aeef9982c 100755
> --- a/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> +++ b/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> @@ -23,52 +23,82 @@ cd $DIRNAME
>
> orig_maxstack=`sysctl -n kernel.perf_event_max_stack`
> echo kernel.perf_event_max_stack was $orig_maxstack
> -trap "sysctl kernel.perf_event_max_stack=$orig_maxstack" QUIT EXIT
> -sysctl kernel.perf_event_max_stack=200
> +trap "sleep 2; sysctl kernel.perf_event_max_stack=$orig_maxstack" QUIT EXIT
>
> -$dtrace $dt_flags -c $TRIGGER -qn '
> -profile-1
> -/pid == $target/
> -{
> - printf("DEPTH %d\n", ustackdepth);
> - printf("TRACE BEGIN\n");
> - ustack(200);
> - printf("TRACE END\n");
> - exit(0);
> -}
> -ERROR
> -{
> - exit(1);
> -}
> -' > D.out
> -if [ $? -ne 0 ]; then
> - echo DTrace failure
> - exit 1
> -fi
> +# set bounds on the full stack depth (which is ambiguous)
> +lo=188
> +hi=192
>
> -sleep 2
> -sysctl kernel.perf_event_max_stack=$orig_maxstack
> +function do_dtrace() {
> + # set the kernel parameter
> + sysctl kernel.perf_event_max_stack=$stack_limit
>
> -$POSTPROC D.out > awk.out
> -if [ $? -ne 0 ]; then
> - echo post processing failure
> - exit 1
> -fi
> + # run dtrace
> + $dtrace $dt_flags -c $TRIGGER -qn '
> + profile-1
> + /pid == $target/
> + {
> + printf("DEPTH %d\n", ustackdepth);
> + printf("TRACE BEGIN\n");
> + ustack(200);
> + printf("TRACE END\n");
> + exit(0);
> + }
> + ERROR
> + {
> + exit(1);
> + }
> + ' > D.out.$stack_limit
> + if [ $? -ne 0 ]; then
> + echo ERROR: DTrace failure with $stack_limit
> + exit 1
> + fi
>
> -if echo "Stack depth OK" | diff -q - awk.out; then
> - mydepth=`gawk '/DEPTH/ { print $2 }' D.out`
> - if [ $mydepth -gt $orig_maxstack ]; then
> - echo success depth $mydepth exceeded original limit $orig_maxstack
> - exit 0
> - else
> - echo ERROR: $mydepth does not exceed original limit $orig_maxstack
> + # check stackdepth consistency
> + $POSTPROC D.out.$stack_limit > awk.out.$stack_limit
> + if [ $? -ne 0 ]; then
> + echo ERROR: post processing failure
> + exit 1
> + fi
> + if ! grep -q "Stack depth OK" awk.out.$stack_limit; then
> + echo ERROR: stack depth does not match stack
> cat D.out
> exit 1
> fi
> -else
> - echo "ERROR: stack depth does not match stack"
> - cat D.out
> +
> + # get actual stack depth
> + mydepth=`gawk '/DEPTH/ { print $2 }' D.out.$stack_limit`
> + echo with limit $stack_limit got stack depth $mydepth
> +
> + # provide breathing room between dtrace and resetting kernel parameter
> + sleep 2
> +}
> +
> +# try a stack limit that is too small
> +stack_limit=$(($lo / 2))
> +do_dtrace
> +echo " " stack limit $stack_limit is too small for the entire stack
> +if [ $mydepth -ne $stack_limit ]; then
> + echo ERROR: $mydepth does not match $stack_limit
> exit 1
> fi
> +echo " " success: actual depth matches limit
> +
> +# try a stack limit that is large enough
> +stack_limit=$(($hi + 20))
> +do_dtrace
> +echo " " stack limit $stack_limit is large enough
> +if [ $mydepth -lt $lo ]; then
> + echo ERROR: $mydepth is lower than low bound $lo
> + exit 1
> +fi
> +if [ $mydepth -gt $hi ]; then
> + echo ERROR: $mydepth is greater than high bound $hi
> + exit 1
> +fi
> +echo " " success: actual depth captures full stack
> +
> +# restore the kernel parameter
> +sysctl kernel.perf_event_max_stack=$orig_maxstack
>
> exit 0
> --
> 2.47.3
>
prev parent reply other threads:[~2025-10-13 19:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 21:33 [PATCH v2] test: Account for large stack-limit kernel parameter eugene.loh
2025-10-13 19:15 ` Kris Van Hees [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aO1PxpMjm7ng0KUe@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=eugene.loh@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox