]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcu-tasks: Remove open-coded one-byte cmpxchg() emulation
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 9 Oct 2024 18:00:45 +0000 (11:00 -0700)
committerFrederic Weisbecker <frederic@kernel.org>
Tue, 12 Nov 2024 20:45:14 +0000 (21:45 +0100)
This commit removes the open-coded one-byte cmpxchg() emulation from
rcu_trc_cmpxchg_need_qs(), replacing it with just cmpxchg() given the
latter's new-found ability to handle single-byte arguments across all
architectures.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
kernel/rcu/tasks.h

index dd9730fd44fbe89d2fac31f3005c7979e3d8e60a..c789d994e7ebc9eaef18a4fc201b43b9887b91ec 100644 (file)
@@ -1541,22 +1541,7 @@ static void rcu_st_need_qs(struct task_struct *t, u8 v)
  */
 u8 rcu_trc_cmpxchg_need_qs(struct task_struct *t, u8 old, u8 new)
 {
-       union rcu_special ret;
-       union rcu_special trs_old = READ_ONCE(t->trc_reader_special);
-       union rcu_special trs_new = trs_old;
-
-       if (trs_old.b.need_qs != old)
-               return trs_old.b.need_qs;
-       trs_new.b.need_qs = new;
-
-       // Although cmpxchg() appears to KCSAN to update all four bytes,
-       // only the .b.need_qs byte actually changes.
-       instrument_atomic_read_write(&t->trc_reader_special.b.need_qs,
-                                    sizeof(t->trc_reader_special.b.need_qs));
-       // Avoid false-positive KCSAN failures.
-       ret.s = data_race(cmpxchg(&t->trc_reader_special.s, trs_old.s, trs_new.s));
-
-       return ret.b.need_qs;
+       return cmpxchg(&t->trc_reader_special.b.need_qs, old, new);
 }
 EXPORT_SYMBOL_GPL(rcu_trc_cmpxchg_need_qs);