Generic Linux architectural discussions
 help / color / mirror / Atom feed
* 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox