]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcutorture: Re-use value stored to ->rtort_pipe_count instead of re-reading
authorlinke li <lilinke99@qq.com>
Thu, 7 Mar 2024 03:51:10 +0000 (19:51 -0800)
committerUladzislau Rezki (Sony) <urezki@gmail.com>
Tue, 16 Apr 2024 09:16:35 +0000 (11:16 +0200)
Currently, the rcu_torture_pipe_update_one() writes the value (i + 1)
to rp->rtort_pipe_count, then immediately re-reads it in order to compare
it to RCU_TORTURE_PIPE_LEN.  This re-read is pointless because no other
update to rp->rtort_pipe_count can occur at this point.  This commit
therefore instead re-uses the (i + 1) value stored in the comparison
instead of re-reading rp->rtort_pipe_count.

Signed-off-by: linke li <lilinke99@qq.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
kernel/rcu/rcutorture.c

index 0cb5452ecd945d11780ebee2ae437190ee12c601..dd7d5ba457409febfdb0751fe59e4b9ca4b3c8d7 100644 (file)
@@ -467,7 +467,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
        atomic_inc(&rcu_torture_wcount[i]);
        WRITE_ONCE(rp->rtort_pipe_count, i + 1);
        ASSERT_EXCLUSIVE_WRITER(rp->rtort_pipe_count);
-       if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
+       if (i + 1 >= RCU_TORTURE_PIPE_LEN) {
                rp->rtort_mbtest = 0;
                return true;
        }