* spin_lock() ordering on ia64
@ 2015-11-18 13:11 Will Deacon
2015-11-18 18:41 ` Luck, Tony
0 siblings, 1 reply; 2+ messages in thread
From: Will Deacon @ 2015-11-18 13:11 UTC (permalink / raw)
To: tony.luck; +Cc: peterz, linux-arch
Hi Tony,
I recently took a look at the ia64 spinlock implementation in hope of
some inspiration regarding spin_unlock_wait, but I'm actually having
trouble understanding how spin_lock() guarantees ordering between taking
the lock and reads of some shared data in the critical section.
In particular, the loop where the locker spins awaiting its turn in the
queue:
for (;;) {
asm volatile ("ld4.c.nc %0=[%1]" : "=r"(serve) : "r"(p) : "memory");
if (!(((serve >> TICKET_SHIFT) ^ ticket) & TICKET_MASK))
return;
cpu_relax();
}
AFAIU, ld4.c.nc doesn't provide any ordering semantics, so a load to an
unrelated address from within the following critical section could be
speculated before we've actually acquired the lock.
What am I missing? Does the ALAT provide guarantees against other loads
somehow or does ld4.c.nc provide ordering guarantees that I didn't spot
in the manuals?
Cheers,
Will
^ permalink raw reply [flat|nested] 2+ messages in thread* RE: spin_lock() ordering on ia64
2015-11-18 13:11 spin_lock() ordering on ia64 Will Deacon
@ 2015-11-18 18:41 ` Luck, Tony
0 siblings, 0 replies; 2+ messages in thread
From: Luck, Tony @ 2015-11-18 18:41 UTC (permalink / raw)
To: Will Deacon; +Cc: peterz@infradead.org, linux-arch@vger.kernel.org
> AFAIU, ld4.c.nc doesn't provide any ordering semantics, so a load to an
> unrelated address from within the following critical section could be
> speculated before we've actually acquired the lock.
>
> What am I missing? Does the ALAT provide guarantees against other loads
> somehow or does ld4.c.nc provide ordering guarantees that I didn't spot
> in the manuals?
I don't recall. I pinged the Itanium h/w architect that helped me write that code,
but it may be a while before I get an answer (they said it would require paging
in some old context to the brain, and they are swamped with other work now).
-Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-18 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 13:11 spin_lock() ordering on ia64 Will Deacon
2015-11-18 18:41 ` Luck, Tony
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.