[DTrace-devel] [PATCH v2 03/12] Overhaul the stackdepth value test

Eugene Loh eugene.loh at oracle.com
Wed Jun 16 15:33:18 PDT 2021


On 6/15/21 1:12 PM, Kris Van Hees wrote:

> Woops, Houston, we have a problem...
>
> And for two other patches that use the same FBT probe...)
>
> __vfs_write doesn't seem like a stable function to use.  E.g. my 5.13.0 kernel
> does not have it.

Thanks.  It seems to have fallen out of use:  unexported, made static, 
and then finally removed altogether in 5.8 (commit 53ad86266bda  "fs: 
remove __vfs_write").

For tst.stackdepth2.d, a few-char change in the test moves us up one 
frame and addresses the problem.

For tst.caller_ksys_write.d, I changed the test to tst.caller2.d, which 
no longer checks for a specific caller frame but simply for consistency 
with stack().  That's a weaker check, but if we can rely on stack() then 
the check is more immune to changes in the kernel.

For tst.stack*_fbt.d, I've added a *.x file to check whether the kernel 
version is 5.8 or later, in which case the test is skipped (with an 
explanatory message).  Maybe we can devise an alternative check, but as 
you point out that is tough.  Meanwhile, so that there is at least a 
sanity check on stack() for 5.8 and beyond, I've added a new tst.stack.d.

I've revised the associated patches accordingly.  They already had 
Reviewed-by.  I'll post them again for your information, so you can see 
the tests.  Of course, let me know if you have any comments.

>
> You will have to use a more stable probe to use, especially for the stack()
> trsts.  Which is really hard to do because you never know what the kernel
> people will mess with next.
>
> On Fri, Jun 11, 2021 at 04:01:48PM -0400, Kris Van Hees wrote:
>> Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
>>
>> On Tue, Jun 08, 2021 at 05:54:22PM -0400, eugene.loh at oracle.com wrote:
>>> From: Eugene Loh <eugene.loh at oracle.com>
>>>
>>> This test checks the value of stackdepth by using stack() as a
>>> consistency check.  Address the following shortcomings:
>>>
>>> 1) The test fires in BEGIN, which no longer has a kernel stack.
>>>
>>> 2) The test incorrectly counts stack frames.
>>>
>>> 3) The test passes because neither stack() nor stackdepth is implemented!
>>> (Currently, stack() always reports nothing and stackdepth always 0.)
>>>
>>> 4) An ERROR in the D script would cause the test to hang.
>>>
>>> The corrected test will XFAIL until stack() and stackdepth are implemented.
>>>
>>> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
>>> ---
>>>   test/unittest/stackdepth/tst.value.d   | 14 +++++++++++++-
>>>   test/unittest/stackdepth/tst.value.r.p |  8 +++++---
>>>   2 files changed, 18 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/test/unittest/stackdepth/tst.value.d b/test/unittest/stackdepth/tst.value.d
>>> index 857728bd..a729bd3f 100644
>>> --- a/test/unittest/stackdepth/tst.value.d
>>> +++ b/test/unittest/stackdepth/tst.value.d
>>> @@ -1,10 +1,12 @@
>>>   /*
>>>    * Oracle Linux DTrace.
>>> - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
>>> + * Copyright (c) 2006, 2021, 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.
>>>    */
>>> +/* @@xfail: dtv2 */
>>>   
>>> +#pragma D option destructive
>>>   #pragma D option quiet
>>>   
>>>   /*
>>> @@ -16,6 +18,11 @@
>>>    */
>>>   
>>>   BEGIN
>>> +{
>>> +	system("echo write something > /dev/null");
>>> +}
>>> +
>>> +fbt::__vfs_write:entry
>>>   {
>>>   	printf("DEPTH %d\n", stackdepth);
>>>   	printf("TRACE BEGIN\n");
>>> @@ -23,3 +30,8 @@ BEGIN
>>>   	printf("TRACE END\n");
>>>   	exit(0);
>>>   }
>>> +
>>> +ERROR
>>> +{
>>> +	exit(1);
>>> +}
>>> diff --git a/test/unittest/stackdepth/tst.value.r.p b/test/unittest/stackdepth/tst.value.r.p
>>> index d5143e38..9b071181 100755
>>> --- a/test/unittest/stackdepth/tst.value.r.p
>>> +++ b/test/unittest/stackdepth/tst.value.r.p
>>> @@ -1,6 +1,6 @@
>>>   #!/usr/bin/gawk -f
>>>   # Oracle Linux DTrace.
>>> -# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
>>> +# Copyright (c) 2016, 2021, 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.
>>>   
>>> @@ -12,12 +12,12 @@
>>>   	getline;
>>>   	count = 0;
>>>   	while ($0 !~ /^TRACE END/) {
>>> +		if (NF)
>>> +			count++;
>>>   		if (getline != 1) {
>>>   			print "EOF or error while processing stack\n";
>>>   			exit 0;
>>>   		}
>>> -		if (NF)
>>> -			count++;
>>>   	}
>>>   }
>>>   
>>> @@ -26,6 +26,8 @@ END {
>>>   		printf "Stack depth too large (%d > %d)\n", depth, count;
>>>   	else if (count > depth)
>>>   		printf "Stack depth too small (%d < %d)\n", depth, count;
>>> +	else if (count == 0)
>>> +		printf "Stack depth is 0\n";
>>>   	else
>>>   		printf "Stack depth OK\n";
>>>   }
>>> -- 
>>> 2.18.4
>>>
>>>
>>> _______________________________________________
>>> DTrace-devel mailing list
>>> DTrace-devel at oss.oracle.com
>>> https://oss.oracle.com/mailman/listinfo/dtrace-devel
>> _______________________________________________
>> DTrace-devel mailing list
>> DTrace-devel at oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list