[DTrace-devel] [PATCH 17/61] test: Fix race condition in many-fire tests
eugene.loh at oracle.com
eugene.loh at oracle.com
Fri Jul 8 14:45:01 UTC 2022
From: Eugene Loh <eugene.loh at oracle.com>
Some tests that expect probes to fire many times had been using tick-*
for this purpose. Unfortunately, tick-* quality can be poor, depending
on how the kernel is configured. Therefore, commit 80a539ae8653
("test: Account for unreliable tick firing") addressed this problem
by replacing tick-* probes with syscall::ioctl:entry probes and with
bogus-ioctl as a trigger.
The problem with this solution is that the actions also involved some
global variables. The ioctl:entry probes could fire on multiple CPUs
concurrently, overwriting each other. Test runs were erratic.
Add "pid==$target" to the probe predicates. This includes both the
the tests in the aforementioned patch but also two rand() tests.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
test/unittest/aggs/tst.llquantincr.d | 3 ++-
test/unittest/aggs/tst.llquantize.d | 3 ++-
test/unittest/aggs/tst.llquantneg.d | 6 +++---
test/unittest/aggs/tst.llquantstep.d | 3 ++-
test/unittest/funcs/tst.rand_inter.sh | 3 ++-
test/unittest/funcs/tst.rand_intra.sh | 3 ++-
test/unittest/speculation/tst.SingleCPU.d | 12 ++++++------
7 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/test/unittest/aggs/tst.llquantincr.d b/test/unittest/aggs/tst.llquantincr.d
index 27755050..5b02d1d3 100644
--- a/test/unittest/aggs/tst.llquantincr.d
+++ b/test/unittest/aggs/tst.llquantincr.d
@@ -15,12 +15,13 @@
#pragma D option quiet
syscall::ioctl:entry
+/pid == $target/
{
@ = llquantize(i++, 10, 0, 6, 20, 2);
}
syscall::ioctl:entry
-/i == 1500/
+/pid == $target && i == 1500/
{
exit(0);
}
diff --git a/test/unittest/aggs/tst.llquantize.d b/test/unittest/aggs/tst.llquantize.d
index 3161ac97..352f937d 100644
--- a/test/unittest/aggs/tst.llquantize.d
+++ b/test/unittest/aggs/tst.llquantize.d
@@ -15,12 +15,13 @@
#pragma D option quiet
syscall::ioctl:entry
+/pid == $target/
{
@ = llquantize(i++, 10, 0, 6, 20);
}
syscall::ioctl:entry
-/i == 1500/
+/pid == $target && i == 1500/
{
exit(0);
}
diff --git a/test/unittest/aggs/tst.llquantneg.d b/test/unittest/aggs/tst.llquantneg.d
index 61d6686c..5070ad63 100644
--- a/test/unittest/aggs/tst.llquantneg.d
+++ b/test/unittest/aggs/tst.llquantneg.d
@@ -15,19 +15,19 @@
#pragma D option quiet
syscall::ioctl:entry
-/i % 2 == 0/
+/pid == $target && i % 2 == 0/
{
@ = llquantize(i++, 10, 0, 6, 20);
}
syscall::ioctl:entry
-/i % 2 != 0/
+/pid == $target && i % 2 != 0/
{
@ = llquantize(i++, 10, 0, 6, 20, -1);
}
syscall::ioctl:entry
-/i == 1500/
+/pid == $target && i == 1500/
{
exit(0);
}
diff --git a/test/unittest/aggs/tst.llquantstep.d b/test/unittest/aggs/tst.llquantstep.d
index 1420ebe4..0b8594d3 100644
--- a/test/unittest/aggs/tst.llquantstep.d
+++ b/test/unittest/aggs/tst.llquantstep.d
@@ -16,12 +16,13 @@
#pragma D option quiet
syscall::ioctl:entry
+/pid == $target/
{
@ = llquantize(i++, 3, 3, 5, 27);
}
syscall::ioctl:entry
-/i == 1500/
+/pid == $target && i == 1500/
{
exit(0);
}
diff --git a/test/unittest/funcs/tst.rand_inter.sh b/test/unittest/funcs/tst.rand_inter.sh
index 973d4a8e..4a66e488 100755
--- a/test/unittest/funcs/tst.rand_inter.sh
+++ b/test/unittest/funcs/tst.rand_inter.sh
@@ -21,6 +21,7 @@ BEGIN
x = rand();
}
syscall::ioctl:entry
+/pid == $target/
{
y = rand();
@@ -50,7 +51,7 @@ syscall::ioctl:entry
n++;
}
syscall::ioctl:entry
-/n >= '$niter'/
+/pid == $target && n >= '$niter'/
{
printf("number of iterations: %d\n", n);
exit(0);
diff --git a/test/unittest/funcs/tst.rand_intra.sh b/test/unittest/funcs/tst.rand_intra.sh
index 70a318f9..0d263fd5 100755
--- a/test/unittest/funcs/tst.rand_intra.sh
+++ b/test/unittest/funcs/tst.rand_intra.sh
@@ -16,6 +16,7 @@ niter=25000
$dtrace $dt_flags -q -o $tmpfile -c test/triggers/bogus-ioctl -n '
BEGIN { nuperr = n = 0 }
syscall::ioctl:entry
+/pid == $target/
{
x = rand();
@@ -32,7 +33,7 @@ syscall::ioctl:entry
n++;
}
syscall::ioctl:entry
-/n >= '$niter'/
+/pid == $target && n >= '$niter'/
{
printf("# of upper-bit errors: %d out of %d\n", nuperr, n);
exit(0);
diff --git a/test/unittest/speculation/tst.SingleCPU.d b/test/unittest/speculation/tst.SingleCPU.d
index 0a96b47d..81a5afa1 100644
--- a/test/unittest/speculation/tst.SingleCPU.d
+++ b/test/unittest/speculation/tst.SingleCPU.d
@@ -28,39 +28,39 @@ BEGIN
*/
syscall::ioctl:entry
-/ (n & 3) == 0 /
+/ pid == $target && (n & 3) == 0 /
{
i = speculation();
}
syscall::ioctl:entry
-/ (n & 3) == 1 /
+/ pid == $target && (n & 3) == 1 /
{
speculate(i);
printf("%4d %4d", n, i);
}
syscall::ioctl:entry
-/ (n & 3) == 2 /
+/ pid == $target && (n & 3) == 2 /
{
speculate(i);
printf("%4d hello world\n", n);
}
syscall::ioctl:entry
-/ (n & 3) == 3 && (n & 63) == 3 /
+/ pid == $target && (n & 3) == 3 && (n & 63) == 3 /
{
commit(i);
}
syscall::ioctl:entry
-/ (n & 3) == 3 && (n & 63) != 3 /
+/ pid == $target && (n & 3) == 3 && (n & 63) != 3 /
{
discard(i);
}
syscall::ioctl:entry
-/ n++ >= 1000 /
+/ pid == $target && n++ >= 1000 /
{
exit(0);
}
--
2.18.4
More information about the DTrace-devel
mailing list