[DTrace-devel] [PATCH] Change trigger for rand() test

eugene.loh at oracle.com eugene.loh at oracle.com
Tue Nov 23 02:32:38 UTC 2021


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

The tick-* probe is unreliable on some kernels, depending on how
their timers subsystem is configured (CONFIG*_HZ*).  Add a trigger
that generates many ioctl() calls and use a syscall::ioctl:entry
probe instead.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 test/unittest/funcs/tst.rand_inter.sh | 14 ++++++++------
 test/unittest/funcs/tst.rand_intra.sh | 14 ++++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/test/unittest/funcs/tst.rand_inter.sh b/test/unittest/funcs/tst.rand_inter.sh
index ac3f318a..973d4a8e 100755
--- a/test/unittest/funcs/tst.rand_inter.sh
+++ b/test/unittest/funcs/tst.rand_inter.sh
@@ -8,17 +8,19 @@
 dtrace=$1
 tmpfile=$tmpdir/tst.rand_inter.$$
 
+niter=25000
+
 # Sanity test of rand().  Do inter-word correlation checks.  That
 # is, use lquantize to look at the distribution of 4-bit blocks,
 # 2 bits from two consecutive words at arbitrary locations.
 
-$dtrace $dt_flags -q -o $tmpfile -n '
+$dtrace $dt_flags -q -o $tmpfile -c test/triggers/bogus-ioctl -n '
 BEGIN
 {
 	n = 0;
 	x = rand();
 }
-tick-200us
+syscall::ioctl:entry
 {
 	y = rand();
 
@@ -47,7 +49,8 @@ tick-200us
 	x = y;
 	n++;
 }
-tick-5sec
+syscall::ioctl:entry
+/n >= '$niter'/
 {
 	printf("number of iterations: %d\n", n);
 	exit(0);
@@ -70,9 +73,8 @@ awk '
     # process line: "number of iterations: ..."
     /number of iterations:/ {
         n = int($4);
-        if (n < 400) {
-            # tick-* can underfire, but require some minimum data
-            print "ERROR: insufficient data";
+        if (n != '$niter') {
+            print "ERROR: unexpected amount of data";
             exit 1;
         }
         avg = n / nbins;     # how many to expect per bin
diff --git a/test/unittest/funcs/tst.rand_intra.sh b/test/unittest/funcs/tst.rand_intra.sh
index 3fcf8c42..70a318f9 100755
--- a/test/unittest/funcs/tst.rand_intra.sh
+++ b/test/unittest/funcs/tst.rand_intra.sh
@@ -8,12 +8,14 @@
 dtrace=$1
 tmpfile=$tmpdir/tst.rand_intra.$$
 
+niter=25000
+
 # Sanity test of rand().  Do intra-word correlation checks.  That
 # is, use lquantize to look at the distribution of 4-bit blocks.
 
-$dtrace $dt_flags -q -o $tmpfile -n '
+$dtrace $dt_flags -q -o $tmpfile -c test/triggers/bogus-ioctl -n '
 BEGIN { nuperr = n = 0 }
-tick-200us
+syscall::ioctl:entry
 {
 	x = rand();
 
@@ -29,7 +31,8 @@ tick-200us
 	nuperr += (x & 0xffffffff00000000) ? 1 : 0;
 	n++;
 }
-tick-5sec
+syscall::ioctl:entry
+/n >= '$niter'/
 {
 	printf("# of upper-bit errors: %d out of %d\n", nuperr, n);
 	exit(0);
@@ -56,9 +59,8 @@ awk '
             exit 1;
         }
         n = int($8);
-        if (n < 400) {
-            # tick-* can underfire, but require some minimum data
-            print "ERROR: insufficient data";
+        if (n != '$niter') {
+            print "ERROR: unexpected amount of data";
             exit 1;
         }
         avg = n / nbins;     # how many to expect per bin
-- 
2.18.4




More information about the DTrace-devel mailing list