From: Linus Torvalds <torvalds@transmeta.com>
To: "Stephen C. Tweedie" <sct@dcs.ed.ac.uk>
Cc: linux-mm@kvack.org, linux-smp@vger.rutgers.edu
Subject: Re: Lazy page reclamation on SMP machines: memory barriers
Date: Mon, 23 Mar 1998 15:20:11 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.3.95.980323151332.431D-100000@penguin.transmeta.com> (raw)
In-Reply-To: <199803232249.WAA02431@dax.dcs.ed.ac.uk>
On Mon, 23 Mar 1998, Stephen C. Tweedie wrote:
>
> Are there barrier constructs available to do this? I believe the answer
> to be no, based on the recent thread concerning the use of inline asm
> cpuid instructions as a barrier on Intel machines. Alternatively, does
> Intel provide any ordering guarantees which may help?
Intel only gives you total ordering across certain instructions (cpuid
being one of them, and the only one that is easily usable under all
circumstances).
> Finally, I looked quickly at the kernel's spinlock primitives, and they
> also seem unprotected by memory barriers on Intel. Is this really safe?
Yes. Intel guarantees total ordering around any locked instruction, so the
spinlocks themselves act as the barriers. This is why "unlock" is a slow
lock ; btrl $0,(mem)
instead of the much faster
movl $0,(mem)
because the latter doesn't imply any ordering, and there are no faster
ways to do it (cpuid is fairly slow, so trying to do a "movl + cpuid"
doesn't help either).
The intel ordering is really nasty, because there is no good fast
synchronization. "cpuid" trashes half the register set, and all the other
synchronizing instructions have other even nastier side effects. And there
is nothing like the alpha (and others) "write memory barrier" instruction
that does only a one-way barrier.
(To be fair, the alpha for example has very nice primitives for SMP, but
sometimes the implementation of them is horribly slow. For example, the
"load-and-protect" thing always seems to go to the bus even when the CPU
has exclusive ownership, which makes atomic sequences much more expensive
than they should be. I think DEC fixed this in their later alpha's, but
the point being that even when you have the right concepts you can mess up
with having a bad implementation ;)
Linus
next prev parent reply other threads:[~1998-03-23 23:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-23 22:49 Stephen C. Tweedie
1998-03-23 23:20 ` Linus Torvalds [this message]
1998-03-24 22:54 ` Stephen C. Tweedie
1998-03-24 23:45 ` David S. Miller
1998-03-25 0:11 ` Linus Torvalds
1998-03-25 9:08 ` Rik van Riel
1998-03-23 23:37 ` Linus Torvalds
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=Pine.LNX.3.95.980323151332.431D-100000@penguin.transmeta.com \
--to=torvalds@transmeta.com \
--cc=linux-mm@kvack.org \
--cc=linux-smp@vger.rutgers.edu \
--cc=sct@dcs.ed.ac.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox