[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240222133320.43780-1-anna-maria@linutronix.de>
Date: Thu, 22 Feb 2024 14:33:20 +0100
From: Anna-Maria Behnsen <anna-maria@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>,
John Stultz <jstultz@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Eric Dumazet <edumazet@...gle.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Arjan van de Ven <arjan@...radead.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Rik van Riel <riel@...riel.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sebastian Siewior <bigeasy@...utronix.de>,
Giovanni Gherdovich <ggherdovich@...e.cz>,
Lukasz Luba <lukasz.luba@....com>,
"Gautham R . Shenoy" <gautham.shenoy@....com>,
Srinivas Pandruvada <srinivas.pandruvada@...el.com>,
K Prateek Nayak <kprateek.nayak@....com>,
Christian Loehle <christian.loehle@....com>,
Anna-Maria Behnsen <anna-maria@...utronix.de>
Subject: [PATCH] timers/timer_migration: Fix memory barrier comment
Comment about the required memory barrier in tmigr_inactive_up() is not
written properly. Rewrite it and add also new comments to the other memory
barrier related places. Also make clear, why a memory barrier in
tmigr_active_up() is not required.
Signed-off-by: Anna-Maria Behnsen <anna-maria@...utronix.de>
---
This is a fix for the patch 'timers: Implement the hierarchical pull model'
v11b.
---
kernel/time/timer_migration.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 0825ccdcfae4..23cb6ea3d44e 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -623,6 +623,11 @@ static bool tmigr_active_up(struct tmigr_group *group,
u8 childmask;
childmask = data->childmask;
+ /*
+ * No memory barrier is required here in contrast to
+ * tmigr_inactive_up(), as the group state change does not depend on the
+ * child state.
+ */
curstate.state = atomic_read(&group->migr_state);
do {
@@ -1215,9 +1220,16 @@ static bool tmigr_inactive_up(struct tmigr_group *group,
u8 childmask;
childmask = data->childmask;
- curstate.state = atomic_read_acquire(&group->migr_state);
childstate.state = 0;
+ /*
+ * The memory barrier is paired with the cmpxchg() in tmigr_active_up()
+ * to make sure the updates of child and group states are ordered. The
+ * ordering is mandatory, as the group state change depends on the child
+ * state.
+ */
+ curstate.state = atomic_read_acquire(&group->migr_state);
+
for (;;) {
if (child)
childstate.state = atomic_read(&child->migr_state);
@@ -1257,10 +1269,12 @@ static bool tmigr_inactive_up(struct tmigr_group *group,
if (atomic_try_cmpxchg(&group->migr_state, &curstate.state,
newstate.state))
break;
+
/*
- * Add memory barrier to make sure child and group states order
- * of read is preserved. This barrier is only required when
- * atomic_try_cmpxchg() failed.
+ * The memory barrier is paired with the cmpxchg() in
+ * tmigr_active_up() to make sure the updates of child and group
+ * states are ordered. It is required only when the above
+ * try_cmpxchg() fails.
*/
smp_mb__after_atomic();
}
--
2.39.2
Powered by blists - more mailing lists