Re: [PATCH 03/12] powerpc: qspinlock: Enforce qnode writes prior to publishing to queue
From: "Nicholas Piggin" <npiggin@gmail.com>
Date: 2023-05-09 02:05:52
From: "Nicholas Piggin" <npiggin@gmail.com>
Date: 2023-05-09 02:05:52
On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote:
Use a compiler barrier to enforce that all fields of a new struct qnode be written to (especially the lock value) before publishing the qnode to the waitqueue.
publish_tail_cpu is the release barrier for this and includes the memory clobber there. Can we annotate that instead? Thanks, Nick
Signed-off-by: Rohan McLure <redacted> --- arch/powerpc/lib/qspinlock.c | 4 ++++ 1 file changed, 4 insertions(+)diff --git a/arch/powerpc/lib/qspinlock.c b/arch/powerpc/lib/qspinlock.c index 579290d55abf..d548001a86be 100644 --- a/arch/powerpc/lib/qspinlock.c +++ b/arch/powerpc/lib/qspinlock.c@@ -567,6 +567,10 @@ static __always_inline void queued_spin_lock_mcs_queue(struct qspinlock *lock, b node->cpu = smp_processor_id(); node->yield_cpu = -1; node->locked = 1; + /* + * Assign all attributes of a node before it can be published. + */ + barrier(); tail = encode_tail_cpu(node->cpu);-- 2.37.2