From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
mingo@kernel.org, jiangshanlai@gmail.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 05/28] torture: Make torture_stutter() use hrtimer
Date: Thu, 5 Nov 2020 15:46:56 -0800 [thread overview]
Message-ID: <20201105234719.23307-5-paulmck@kernel.org> (raw)
In-Reply-To: <20201105234658.GA23142@paulmck-ThinkPad-P72>
From: "Paul E. McKenney" <paulmck@kernel.org>
The torture_stutter() function uses schedule_timeout_interruptible()
to time the stutter duration, but this can miss race conditions due to
its being time-synchronized with everything else that is based on the
timer wheels. This commit therefore converts torture_stutter() to use
the high-resolution timers via schedule_hrtimeout(), and also to fuzz
the stutter interval. While in the area, this commit also limits the
spin-loop portion of the stutter_wait() function's wait loop to two
jiffies, down from about one second.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/torture.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/torture.c b/kernel/torture.c
index 5488ad2..d8bdd9a 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -641,20 +641,27 @@ EXPORT_SYMBOL_GPL(stutter_wait);
*/
static int torture_stutter(void *arg)
{
+ ktime_t delay;
+ DEFINE_TORTURE_RANDOM(rand);
int wtime;
VERBOSE_TOROUT_STRING("torture_stutter task started");
do {
if (!torture_must_stop() && stutter > 1) {
wtime = stutter;
- if (stutter > HZ + 1) {
+ if (stutter > 2) {
WRITE_ONCE(stutter_pause_test, 1);
- wtime = stutter - HZ - 1;
- schedule_timeout_interruptible(wtime);
- wtime = HZ + 1;
+ wtime = stutter - 3;
+ delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
+ delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC;
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
+ wtime = 2;
}
WRITE_ONCE(stutter_pause_test, 2);
- schedule_timeout_interruptible(wtime);
+ delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
}
WRITE_ONCE(stutter_pause_test, 0);
if (!torture_must_stop())
--
2.9.5
next prev parent reply other threads:[~2020-11-05 23:48 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 23:46 [PATCH tip/core/rcu 0/28] Torture-test updates for v5.11 Paul E. McKenney
2020-11-05 23:46 ` [PATCH tip/core/rcu 01/28] refscale: Bounds-check module parameters paulmck
2020-11-05 23:46 ` [PATCH tip/core/rcu 02/28] torture: Don't kill gdb sessions paulmck
2020-11-05 23:46 ` [PATCH tip/core/rcu 03/28] locktorture: Track time of last ->writeunlock() paulmck
2020-11-06 6:56 ` Davidlohr Bueso
2020-11-06 19:13 ` Paul E. McKenney
2020-11-05 23:46 ` [PATCH tip/core/rcu 04/28] torture: Periodically pause in stutter_wait() paulmck
2020-11-05 23:46 ` paulmck [this message]
2020-11-05 23:46 ` [PATCH tip/core/rcu 06/28] scftorture: Add an alternative IPI vector paulmck
2020-11-05 23:46 ` [PATCH tip/core/rcu 07/28] rcuscale: Add RCU Tasks Trace paulmck
2020-11-05 23:46 ` [PATCH tip/core/rcu 08/28] rcuscale: Avoid divide by zero paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 09/28] torture: Exclude "NOHZ tick-stop error" from fatal errors paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 10/28] rcuscale: Prevent hangs for invalid arguments paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 11/28] refscale: " paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 12/28] rcutorture: Adjust scenarios SRCU-t and SRCU-u to make kconfig happy paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 13/28] locktorture: Ignore nreaders_stress if no readlock support paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 14/28] locktorture: Prevent hangs for invalid arguments paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 15/28] torture: Prevent jitter processes from delaying failed run paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 16/28] rcutorture: Prevent hangs for invalid arguments paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 17/28] torture: Force weak-hashed pointers on console log paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 18/28] rcutorture: Make stutter_wait() caller restore priority paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 19/28] torture: Accept time units on kvm.sh --duration argument paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 20/28] rcutorture: Small code cleanups paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 21/28] torture: Allow alternative forms of kvm.sh command-line arguments paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 22/28] scftorture: Add full-test stutter capability paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 23/28] locktorture: Invoke percpu_free_rwsem() to do percpu-rwsem cleanup paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 24/28] rcutorture: Don't do need_resched() testing if ->sync is NULL paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 25/28] rcutorture/nolibc: Fix a typo in header file paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 26/28] torture: Make kvm-check-branches.sh use --allcpus paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 27/28] tools/nolibc: Fix a spelling error in a comment paulmck
2020-11-05 23:47 ` [PATCH tip/core/rcu 28/28] tools/rcutorture: Fix BUG parsing of console.log paulmck
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=20201105234719.23307-5-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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