Skip to content

Commit 6f31363

Browse files
rohanmclurempe
authored andcommitted
powerpc: qspinlock: Enforce qnode writes prior to publishing to queue
Annotate the release barrier and memory clobber (in effect, producing a compiler barrier) in the publish_tail_cpu call. These barriers have the effect of ensuring that qnode attributes are all written to prior to publish the node to the waitqueue. Even while the initial write to the 'locked' attribute is guaranteed to terminate prior to the node being visible, KCSAN still complains that the write is reorderable by the compiler. Issue a kcsan_release() to inform KCSAN of the release barrier contained in publish_tail_cpu(). Signed-off-by: Rohan McLure <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 03d44ee commit 6f31363

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/powerpc/lib/qspinlock.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static __always_inline u32 publish_tail_cpu(struct qspinlock *lock, u32 tail)
161161
{
162162
u32 prev, tmp;
163163

164+
kcsan_release();
165+
164166
asm volatile(
165167
"\t" PPC_RELEASE_BARRIER " \n"
166168
"1: lwarx %0,0,%2 # publish_tail_cpu \n"
@@ -570,6 +572,11 @@ static __always_inline void queued_spin_lock_mcs_queue(struct qspinlock *lock, b
570572

571573
tail = encode_tail_cpu(node->cpu);
572574

575+
/*
576+
* Assign all attributes of a node before it can be published.
577+
* Issues an lwsync, serving as a release barrier, as well as a
578+
* compiler barrier.
579+
*/
573580
old = publish_tail_cpu(lock, tail);
574581

575582
/*

0 commit comments

Comments
 (0)