linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Q] Implementation of spin_lock on i386: why "rep;nop" ?
@ 2001-09-17 16:16 Jean-Marc Saffroy
  2001-09-17 16:22 ` Dave Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jean-Marc Saffroy @ 2001-09-17 16:16 UTC (permalink / raw)
  To: linux-kernel, linux-smp

Hi all,

One of my coworkers directed my attention to the implementation of
spinlocks on IA-32. In spin_lock_string, we can read:

	"cmpb $0,%0\n\t" \
	"rep;nop\n\t" \
	"jle 2b\n\t" \

The "rep;nop" line looks dubious, since the IA-32 programmer's manual from
Intel (year 2001) mentions that the behaviour of REP is undefined when it
is not used with string opcodes. BTW, according to the same manual, REP is
supposed to modify ecx, but it looks like is is not the case here... which
is fortunate, since ecx is never saved. :-)

What is the intent behind this "rep;nop" ? Does it really rely on an
undocumented behaviour ?


Regards,

-- 
Jean-Marc Saffroy - Research Engineer - Silicomp Research Institute
mailto:saffroy@ri.silicomp.fr


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

end of thread, other threads:[~2001-09-19  4:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-17 16:16 [Q] Implementation of spin_lock on i386: why "rep;nop" ? Jean-Marc Saffroy
2001-09-17 16:22 ` Dave Jones
2001-09-17 17:19   ` Jean-Marc Saffroy
2001-09-17 16:42 ` Richard B. Johnson
2001-09-17 17:06   ` Jonathan Lundell
2001-09-17 17:27 ` Alan Cox
2001-09-17 19:47   ` H. Peter Anvin
2001-09-19  3:42   ` Jamie Lokier
2001-09-19  4:06     ` Brian Gerst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).