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:37:08 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.3.95.980323152209.431E-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?
Just a quick follow-up with more intel-specific information in case people
care. The serializing instructions (intel-speak for "read and write memory
barrier") are:
Privileged (and all of these are too slow to really consider):
- mov to control register
- mov to debug register
- wrmsr, invd, invlpg, winvd, lgdt, lldt, lidt, ltr
Non-privileged:
- CPUID, IRET, RSM (and only CPUID is really usable for serialization)
In addition, any locked instruction (or xchg, which is implicitly locked)
will "wait for all previous instructions to complete, and for the store
buffer to drain to memory". That, together with the rule that reads cannot
pass locked instructions, essentially makes all locked instructions
serialized (they _are_ serialized as far as memory ordering goes, but
intel seems to use the term "serialized" for both memory ordering and for
"internal CPU behaviour": in intel-speak a "real" serializing instruction
will apparently also wait for the CPU pipeline to drain).
The cheapest way (considering register usage etc) to get a serializing
instruction _seems_ to be to use something like
lock ; add $0,0(%esp)
which will act as a read and write barrier, but won't actually drain the
pipe completely (and won't trash any registers - and the stack is likely
to be dirty and cached, so it won't generate any extra memory traffic
except on a Pentium where the "lock" thing cannot work on the cache).
Linus
prev parent reply other threads:[~1998-03-23 23:37 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
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 [this message]
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.980323152209.431E-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