mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Spinlock assembly clarification
@ 2011-07-18  5:30 Frank Coldwell
  2011-07-18  6:41 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Coldwell @ 2011-07-18  5:30 UTC (permalink / raw)
  To: linux-kernel

dear friends,

I was looking at spinlock implementation in x86 architecture folder
and this is code i found there:
-----------------------------------------------------------------------------------------------------
static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
{
	short inc = 0x0100;

	asm volatile (
		LOCK_PREFIX "xaddw %w0, %1\n"
		"1:\t"
		"cmpb %h0, %b0\n\t"
		"je 2f\n\t"
		"rep ; nop\n\t"
		"movb %1, %b0\n\t"
		/* don't need lfence here, because loads are in-order */
		"jmp 1b\n"
		"2:"
		: "+Q" (inc), "+m" (lock->slock)
		:
		: "memory", "cc");
}
-----------------------------------------------------------------------------------------------------

So to understand this I look at intel manual for these instructions,
and I could not find anything
for instruction xaddw ??

So can anyone can help me understand what this assembly code is doing
and also where are these
assembly instructions converted to real assembly instructions (in gcc maybe) ??

Thanks in advance,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Spinlock assembly clarification
  2011-07-18  5:30 Spinlock assembly clarification Frank Coldwell
@ 2011-07-18  6:41 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2011-07-18  6:41 UTC (permalink / raw)
  To: Frank Coldwell; +Cc: linux-kernel

Le lundi 18 juillet 2011 à 09:30 +0400, Frank Coldwell a écrit :

> So to understand this I look at intel manual for these instructions,
> and I could not find anything
> for instruction xaddw ??
> 

Look for XADD

The W suffix means we operate on a 16bit word.

http://faydoc.tripod.com/cpu/xadd.htm



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-18  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18  5:30 Spinlock assembly clarification Frank Coldwell
2011-07-18  6:41 ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®