[PATCH 07/17] rcutorture: Recognize completed writer waits in console logs

From: Kunwu Chan

Date: Tue Dec 01 2026 - 11:20:37 EST


A slow expedited wait can span multiple statistics intervals
without advancing ver. Treat changes in wgps as writer progress
when ver stays constant.

Keep support for ver-only logs and test malformed wgps fields and
counter wrap.

Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
.../bin/parse-console-progress-test.sh | 40 +++++++++++++++++++
.../selftests/rcutorture/bin/parse-console.sh | 29 ++++++++++++--
2 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
index b9603ce04fce..a01d9e6ad94b 100755
--- a/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
+++ b/tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh
@@ -68,6 +68,29 @@ check legacy-regression fail 'BAD SEQ' < <(stats 107 ''; stats 106 '')
check legacy-nonnumeric fail 'BAD SEQ' < <(stats 106 ''; stats broken '')
check legacy-initial-zero fail 'BAD SEQ|GP HANG' < <(stats 0 ''; stats 1 '')

+# Constant version with wait progress.
+check burst-progress pass < <(stats 106 'wgps: 840' 73.381162; stats 106 'wgps: 845' 78.506285)
+check first-burst-progress pass < <(stats 0 'wgps: 1'; stats 0 'wgps: 2')
+check serial-crlf pass < <(
+ stats 106 'wgps: 840' | sed 's/$/\r/'
+ stats 106 'wgps: 845' | sed 's/$/\r/'
+)
+check burst-stall fail 'GP HANG' < <(stats 106 'wgps: 840'; stats 106 'wgps: 840')
+check burst-stall-then-recovery fail 'BAD SEQ' < <(
+ stats 106 'wgps: 840'
+ stats 106 'wgps: 840'
+ stats 106 'wgps: 845'
+)
+check burst-initial-stall fail 'BAD SEQ|GP HANG' < <(stats 0 'wgps: 0'; stats 1 'wgps: 1')
+check burst-regression fail 'BAD SEQ' < <(stats 107 'wgps: 840'; stats 106 'wgps: 845')
+check burst-nonnumeric-version fail 'BAD SEQ' < <(stats 106 'wgps: 840'; stats broken 'wgps: 845')
+check other-flavor-progress pass < <(stats 106 'wgps: 0'; stats 107 'wgps: 0')
+check unsigned-wrap pass < <(stats 106 'wgps: 18446744073709551615'; stats 106 'wgps: 0')
+check unsigned-adjacent pass < <(
+ stats 106 'wgps: 18446744073709551614'
+ stats 106 'wgps: 18446744073709551615'
+)
+check counter-decrease pass < <(stats 106 'wgps: 845'; stats 106 'wgps: 5')
check double-adjacent-progress pass < <(stats 9007199254740992 ''; stats 9007199254740993 '')
check double-adjacent-regression fail 'BAD SEQ' < <(
stats 9007199254740993 ''
@@ -78,6 +101,23 @@ check large-version-regression fail 'BAD SEQ' < <(
stats 18446744073709551615 'wgps: 1'
stats 18446744073709551614 'wgps: 2'
)
+check padded-stall fail 'GP HANG' < <(stats 106 'wgps: 007'; stats 106 'wgps: 7')
+
+check missing-first-field fail 'BAD WGPS' < <(stats 106 ''; stats 107 'wgps: 845')
+check missing-later-field fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 '')
+check missing-first-value fail 'BAD WGPS' < <(stats 106 'wgps:'; stats 107 'wgps: 845')
+check missing-later-value fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps:')
+check malformed-first-value fail 'BAD WGPS' < <(stats 106 'wgps: broken'; stats 107 'wgps: 845')
+check malformed-later-value fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps: broken')
+check negative-value fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps: -1')
+check decimal-value fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps: 845.5')
+check compact-field fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps:845')
+check duplicate-field fail 'BAD WGPS' < <(stats 106 'wgps: 840'; stats 107 'wgps: 845 wgps: 846')
+check writer-stall-diagnostic fail 'Writer stall state' < <(
+ stats 106 'wgps: 840'
+ stats 106 'wgps: 845'
+ printf '??? Writer stall state RTWS_EXP_SYNC(4)\n'
+)

echo "1..$nchecks"
test "$nfailed" -eq 0
diff --git a/tools/testing/selftests/rcutorture/bin/parse-console.sh b/tools/testing/selftests/rcutorture/bin/parse-console.sh
index d63fa43864ad..9b08a56a4977 100755
--- a/tools/testing/selftests/rcutorture/bin/parse-console.sh
+++ b/tools/testing/selftests/rcutorture/bin/parse-console.sh
@@ -82,26 +82,49 @@ then

BEGIN {
ver = 0;
+ wgps = 0;
badseq = 0;
}

{
sub(/\r$/, "");
+ nwgps = 0;
+ wgps_bad = 0;
+ for (i = 2; i <= NF; i++) {
+ if ($i ~ /^wgps:/) {
+ nwgps++;
+ newwgps = $(i + 1);
+ if ($i != "wgps:" || newwgps !~ /^[0-9]+$/)
+ wgps_bad = 1;
+ }
+ }
+ if (NR == 1)
+ has_wgps = nwgps != 0;
+ if (!badwgps && (wgps_bad || nwgps > 1 || has_wgps != (nwgps != 0)))
+ badwgps = NR;
+ # A change in wgps also counts, even on wrap.
vcmp = countcmp($1, ver);
- if (!badseq && ($1 !~ /^[0-9]+$/ || vcmp <= 0)) {
+ if (!badseq && ($1 !~ /^[0-9]+$/ || vcmp < 0 ||
+ (vcmp == 0 && (!has_wgps || countcmp(newwgps, wgps) == 0)))) {
badseqno1 = ver;
badseqno2 = $1;
badseqnr = NR;
+ badseq_wgps = newwgps;
+ badseq_has_wgps = has_wgps;
badseq_invalid = $1 !~ /^[0-9]+$/;
badseq = 1;
}
ver = $1;
+ wgps = newwgps;
}

END {
- if (badseq) {
+ if (badwgps) {
+ print "BAD WGPS torture stat " badwgps;
+ } else if (badseq) {
if (!badseq_invalid && countcmp(badseqno1, badseqno2) == 0 &&
- countcmp(badseqno2, ver) == 0)
+ countcmp(badseqno2, ver) == 0 &&
+ (!badseq_has_wgps || countcmp(badseq_wgps, wgps) == 0))
print "GP HANG at " ver " torture stat " badseqnr;
else
print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr;
--
2.43.0