All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Zealey <mark@zealos.org>
To: linux-kernel@vger.kernel.org
Subject: Question and patch about spinlocks (x86)
Date: Thu, 11 Oct 2001 21:36:55 +0100	[thread overview]
Message-ID: <20011011213655.D7138@itsolve.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

Just looking through at the spinlock assembly I noticed a few things which I
think are bugs:
 
 	"js 2f\n" \
 	".section .text.lock,\"ax\"\n" \
 	"2:\t" \
	"cmpb $0,%0\n\t" \
 	"rep;nop\n\t" \
	"jle 2b\n\t" \
 	"jmp 1b\n" \
 	".previous"

We do the cmp loop as a 'soft' check, as the lock operand locks the whole system
bus, stopping the system for a while (as much as 70 cycles, I believe). However,
I don't understand why it was put before the 'rep; nop' which just sets the
processor to wait for a bit. Surely it would be better to test *after* we have
waited, as then we have a better chance of it being correct.

Any comments? Attached is a patch to fix it.

-- 

Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
mark@zealos.org
mark@itsolve.co.uk

UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
!E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
!R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

(www.geekcode.com)

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 302 bytes --]

--- include/asm-i386/spinlock.h.old	Thu Oct 11 21:28:37 2001
+++ include/asm-i386/spinlock.h	Thu Oct 11 21:35:14 2001
@@ -58,8 +58,8 @@
 	"js 2f\n" \
 	".section .text.lock,\"ax\"\n" \
 	"2:\t" \
-	"cmpb $0,%0\n\t" \
 	"rep;nop\n\t" \
+	"cmpb $0,%0\n\t" \
 	"jle 2b\n\t" \
 	"jmp 1b\n" \
 	".previous"

             reply	other threads:[~2001-10-11 20:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-11 20:36 Mark Zealey [this message]
2001-10-11 23:01 ` Question and patch about spinlocks (x86) Davide Libenzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011011213655.D7138@itsolve.co.uk \
    --to=mark@zealos.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.