This is strictly a code-movement commit, pulling that part of
the rcu_torture_updown() function's loop body that processes
one rcu_torture_one_read_state_updown structure into a new
rcu_torture_updown_one() function.  The checks for the end of the
torture test and the current structure being in use remain in the
rcu_torture_updown() function.

Signed-off-by: Paul E. McKenney <paul...@kernel.org>
---
 kernel/rcu/rcutorture.c | 46 ++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index e7f0521c56d08..7eccc74e60a7f 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2505,6 +2505,30 @@ static void rcu_torture_updown_cleanup(void)
        updownreaders = NULL;
 }
 
+// Do one reader for rcu_torture_updown().
+static void rcu_torture_updown_one(struct rcu_torture_one_read_state_updown 
*rtorsup)
+{
+       int idx;
+       int rawidx;
+       ktime_t t;
+
+       init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors, 
&rtorsup->rtorsu_trs);
+       rawidx = cur_ops->down_read();
+       idx = (rawidx << RCUTORTURE_RDR_SHIFT_1) & RCUTORTURE_RDR_MASK_1;
+       rtorsup->rtorsu_rtors.readstate = idx | RCUTORTURE_RDR_UPDOWN;
+       rtorsup->rtorsu_rtors.rtrsp++;
+       if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors, 
&rtorsup->rtorsu_trs, -1)) {
+               cur_ops->up_read(rawidx);
+               schedule_timeout_idle(HZ);
+               return;
+       }
+       smp_store_release(&rtorsup->rtorsu_inuse, true);
+       t = torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // One per million.
+       if (t < 10 * 1000)
+               t = 200 * 1000 * 1000;
+       hrtimer_start(&rtorsup->rtorsu_hrt, t, HRTIMER_MODE_REL | 
HRTIMER_MODE_SOFT);
+}
+
 /*
  * RCU torture up/down reader kthread, starting RCU readers in kthread
  * context and ending them in hrtimer handlers.  Otherwise similar to
@@ -2513,10 +2537,7 @@ static void rcu_torture_updown_cleanup(void)
 static int
 rcu_torture_updown(void *arg)
 {
-       int idx;
-       int rawidx;
        struct rcu_torture_one_read_state_updown *rtorsup;
-       ktime_t t;
 
        VERBOSE_TOROUT_STRING("rcu_torture_updown task started");
        do {
@@ -2525,24 +2546,7 @@ rcu_torture_updown(void *arg)
                                break;
                        if (smp_load_acquire(&rtorsup->rtorsu_inuse))
                                continue;
-                       init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors,
-                                                       &rtorsup->rtorsu_trs);
-                       rawidx = cur_ops->down_read();
-                       idx = (rawidx << RCUTORTURE_RDR_SHIFT_1) & 
RCUTORTURE_RDR_MASK_1;
-                       rtorsup->rtorsu_rtors.readstate = idx | 
RCUTORTURE_RDR_UPDOWN;
-                       rtorsup->rtorsu_rtors.rtrsp++;
-                       if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors,
-                                                       &rtorsup->rtorsu_trs, 
-1)) {
-                               cur_ops->up_read(rawidx);
-                               schedule_timeout_idle(HZ);
-                               continue;
-                       }
-                       smp_store_release(&rtorsup->rtorsu_inuse, true);
-                       t = torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // 
One per million.
-                       if (t < 10 * 1000)
-                               t = 200 * 1000 * 1000;
-                       hrtimer_start(&rtorsup->rtorsu_hrt, t,
-                                     HRTIMER_MODE_REL | HRTIMER_MODE_SOFT);
+                       rcu_torture_updown_one(rtorsup);
                }
                torture_hrtimeout_ms(1, 1000, &rcu_torture_updown_rand);
                stutter_wait("rcu_torture_updown");
-- 
2.40.1


Reply via email to