public inbox for linux-kernel@vger.kernel.org
 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@fb.com,
	rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH rcu 03/12] rcutorture: Simplify rcu_torture_read_exit_child() loop
Date: Mon, 20 Jun 2022 15:58:08 -0700	[thread overview]
Message-ID: <20220620225817.3843106-3-paulmck@kernel.org> (raw)
In-Reply-To: <20220620225814.GA3842995@paulmck-ThinkPad-P17-Gen-1>

The existing loop has an implicit manual loop that obscures the flow
and requires an extra control variable.  This commit makes this implicit
loop explicit, thus saving several lines of code.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 47 ++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 3032dd7c7ad35..9273264772b88 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2874,7 +2874,6 @@ static int rcu_torture_read_exit_child(void *trsp_in)
 // Parent kthread which creates and destroys read-exit child kthreads.
 static int rcu_torture_read_exit(void *unused)
 {
-	int count = 0;
 	bool errexit = false;
 	int i;
 	struct task_struct *tsp;
@@ -2886,34 +2885,28 @@ static int rcu_torture_read_exit(void *unused)
 
 	// Each pass through this loop does one read-exit episode.
 	do {
-		if (++count > read_exit_burst) {
-			VERBOSE_TOROUT_STRING("rcu_torture_read_exit: End of episode");
-			rcu_barrier(); // Wait for task_struct free, avoid OOM.
-			for (i = 0; i < read_exit_delay; i++) {
-				schedule_timeout_uninterruptible(HZ);
-				if (READ_ONCE(read_exit_child_stop))
-					break;
+		VERBOSE_TOROUT_STRING("rcu_torture_read_exit: Start of episode");
+		for (i = 0; i < read_exit_burst; i++) {
+			if (READ_ONCE(read_exit_child_stop))
+				break;
+			stutter_wait("rcu_torture_read_exit");
+			// Spawn child.
+			tsp = kthread_run(rcu_torture_read_exit_child,
+					  &trs, "%s", "rcu_torture_read_exit_child");
+			if (IS_ERR(tsp)) {
+				TOROUT_ERRSTRING("out of memory");
+				errexit = true;
+				break;
 			}
-			if (!READ_ONCE(read_exit_child_stop))
-				VERBOSE_TOROUT_STRING("rcu_torture_read_exit: Start of episode");
-			count = 0;
-		}
-		if (READ_ONCE(read_exit_child_stop))
-			break;
-		// Spawn child.
-		tsp = kthread_run(rcu_torture_read_exit_child,
-				     &trs, "%s",
-				     "rcu_torture_read_exit_child");
-		if (IS_ERR(tsp)) {
-			TOROUT_ERRSTRING("out of memory");
-			errexit = true;
-			tsp = NULL;
-			break;
+			cond_resched();
+			kthread_stop(tsp);
+			n_read_exits ++;
 		}
-		cond_resched();
-		kthread_stop(tsp);
-		n_read_exits ++;
-		stutter_wait("rcu_torture_read_exit");
+		VERBOSE_TOROUT_STRING("rcu_torture_read_exit: End of episode");
+		rcu_barrier(); // Wait for task_struct free, avoid OOM.
+		i = 0;
+		for (; !errexit && !READ_ONCE(read_exit_child_stop) && i < read_exit_delay; i++)
+			schedule_timeout_uninterruptible(HZ);
 	} while (!errexit && !READ_ONCE(read_exit_child_stop));
 
 	// Clean up and exit.
-- 
2.31.1.189.g2e36527f23


  parent reply	other threads:[~2022-06-20 23:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 22:58 [PATCH rcu 0/12] Torture-test updates for v5.20 Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 01/12] torture: Make kvm-remote.sh announce which system is being waited on Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 02/12] rcu/torture: Change order of warning and trace dump Paul E. McKenney
2022-06-20 22:58 ` Paul E. McKenney [this message]
2022-06-20 22:58 ` [PATCH rcu 04/12] rcutorture: Fix memory leak in rcu_test_debug_objects() Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 05/12] torture: Adjust to again produce debugging information Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 06/12] rcutorture: Make failure indication note reader-batch overflow Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 07/12] rcu/rcuscale: Fix smp_processor_id()-in-preemptible warnings Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 08/12] torture: Create kvm-check-branches.sh output in proper location Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 09/12] rcutorture: Fix ksoftirqd boosting timing and iteration Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 10/12] rcutorture: Handle failure of memory allocation functions Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 11/12] torture: Flush printk() buffers before powering off Paul E. McKenney
2022-06-20 23:23   ` John Ogness
2022-06-20 23:28     ` Paul E. McKenney
2022-06-21  8:09       ` John Ogness
2022-06-21 18:13         ` Paul E. McKenney
2022-06-21 20:52           ` John Ogness
2022-06-21 21:01             ` Paul E. McKenney
2022-06-20 22:58 ` [PATCH rcu 12/12] refscale: Convert test_lock spinlock to raw_spinlock 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=20220620225817.3843106-3-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=kernel-team@fb.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