Linux RCU subsystem development
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time
Date: Thu, 18 Sep 2025 03:29:42 -0700	[thread overview]
Message-ID: <20250918102952.2593045-1-paulmck@kernel.org> (raw)
In-Reply-To: <c0edd79a-f988-432c-b08a-18793b2e15d9@paulmck-laptop>

An embarrassing syntax error in jitter.sh makes for fixed spin time.
This commit therefore makes it be variable, as intended, albeit with
very coarse-grained adjustment.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/jitter.sh        | 27 ++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh
index fd1ffaa5a1358e..3c1e5d3f88058c 100755
--- a/tools/testing/selftests/rcutorture/bin/jitter.sh
+++ b/tools/testing/selftests/rcutorture/bin/jitter.sh
@@ -39,6 +39,22 @@ do
 	fi
 done
 
+# Uses global variables startsecs, startns, endsecs, endns, and limit.
+# Exit code is success for time not yet elapsed and failure otherwise.
+function timecheck {
+	local done=`awk -v limit=$limit \
+			-v startsecs=$startsecs \
+			-v startns=$startns \
+			-v endsecs=$endsecs \
+			-v endns=$endns < /dev/null '
+		BEGIN {
+			delta = (endsecs - startsecs) * 1000 * 1000;
+			delta += int((endns - startns) / 1000);
+			print delta >= limit;
+		}'`
+	return $done
+}
+
 while :
 do
 	# Check for done.
@@ -85,15 +101,20 @@ do
 	n=$(($n+1))
 	sleep .$sleeptime
 
-	# Spin a random duration
+	# Spin a random duration, but with rather coarse granularity.
 	limit=`awk -v me=$me -v n=$n -v spinmax=$spinmax 'BEGIN {
 		srand(n + me + systime());
 		printf("%06d", int(rand() * spinmax));
 	}' < /dev/null`
 	n=$(($n+1))
-	for i in {1..$limit}
+	startsecs=`date +%s`
+	startns=`date +%N`
+	endsecs=$startns
+	endns=$endns
+	while timecheck
 	do
-		echo > /dev/null
+		endsecs=`date +%s`
+		endns=`date +%N`
 	done
 done
 
-- 
2.40.1


  reply	other threads:[~2025-09-18 10:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
2025-09-18 10:29 ` Paul E. McKenney [this message]
2025-09-18 10:29 ` [PATCH v2 02/11] torture: Add --do-normal parameter to torture.sh help text Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 03/11] torture: Announce kernel boot status at torture-test startup Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 04/11] rcutorture: Suppress "Writer stall state" reports during boot Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 05/11] rcutorture: Delay rcutorture readers and writers until boot completes Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 06/11] torture: Delay CPU-hotplug operations " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 07/11] rcutorture: Delay forward-progress testing " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 08/11] rcutorture: Use kcalloc() instead of kzalloc() Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 09/11] refscale: " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 10/11] refperf: Remove redundant kfree() after torture_stop_kthread() Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 11/11] refperf: Set reader_tasks to NULL after kfree() Paul E. McKenney

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=20250918102952.2593045-1-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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