{
        int i;
 
-       i = rp->rtort_pipe_count;
+       i = READ_ONCE(rp->rtort_pipe_count);
        if (i > RCU_TORTURE_PIPE_LEN)
                i = RCU_TORTURE_PIPE_LEN;
        atomic_inc(&rcu_torture_wcount[i]);
-       if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
+       WRITE_ONCE(rp->rtort_pipe_count, i + 1);
+       if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
                rp->rtort_mbtest = 0;
                return true;
        }
                        if (i > RCU_TORTURE_PIPE_LEN)
                                i = RCU_TORTURE_PIPE_LEN;
                        atomic_inc(&rcu_torture_wcount[i]);
-                       old_rp->rtort_pipe_count++;
+                       WRITE_ONCE(old_rp->rtort_pipe_count,
+                                  old_rp->rtort_pipe_count + 1);
                        switch (synctype[torture_random(&rand) % nsynctypes]) {
                        case RTWS_DEF_FREE:
                                rcu_torture_writer_state = RTWS_DEF_FREE;
                atomic_inc(&n_rcu_torture_mberror);
        rtrsp = rcutorture_loop_extend(&readstate, trsp, rtrsp);
        preempt_disable();
-       pipe_count = p->rtort_pipe_count;
+       pipe_count = READ_ONCE(p->rtort_pipe_count);
        if (pipe_count > RCU_TORTURE_PIPE_LEN) {
                /* Should not happen, but... */
                pipe_count = RCU_TORTURE_PIPE_LEN;