public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: davidm@hpl.hp.com
Cc: torvalds@transmeta.com, engebret@vnet.ibm.com,
	justincarlson@cmu.edu, alan@lxorguk.ukuu.org.uk,
	linux-kernel@vger.kernel.org, anton@samba.org, ak@suse.de,
	paulus@samba.org
Subject: Re: Memory Barrier Definitions
Date: Mon, 13 May 2002 13:26:05 +1000	[thread overview]
Message-ID: <20020513132605.06b44d85.rusty@rustcorp.com.au> (raw)
In-Reply-To: <15578.36627.478751.622066@napali.hpl.hp.com>

On Thu, 9 May 2002 08:00:35 -0700
David Mosberger <davidm@napali.hpl.hp.com> wrote:
> The latter: loads can have "acquire" semantics and stores can have
> "release" semantics.  For example, at the assembly level, ld8.acq
> would be an 8-byte load with acquire semantics, st8.rel an 8-byte
> store with release semantics.  At the C level, acquire/release
> semantics is used for all accesses to "volatile" variables.

OK.  So ignoring the fact that you somehow have to attach your barriers
to a load or store for the moment, we have before vs. after (ia64),
read vs. write (most archs), io vs mem (ppc, ppc64), data dependency
vs non-data dependency (alpha), and smp vs up.

{read|write|readwrite} \
	_{before|after|bidir} \
		_{io|mem|iomem} \
			_{dd|nondd} \
				_{smp|nonsmp}

Now, I think the non-data-depends case is so common that it doesn't
belong in the name at all, but as a separate macro:

#ifndef __alpha__
	#define data_depends(barrier) (barrier)
#else
	#define data_depends(barrier) (ddep_##barrier)
#endif

Also, assuming that no data dependency on normal memory where it doesn't
matter on UP is the default, we can elide those.  Also, any barrier mentioning
IO can be assumed to be in force even if UP, so those combinations are invalid.
Note that UP with CONFIG_PREEMPT counts as SMP here:

	/* Complete all reads from normal memory before any normal
	   memory reads ;which follow this instruction, on SMP or PREEMPT */
	read_before();

	/* Do not begin any reads from normal memory which follow,
	   before any normal reads which preceed this instruction are
	   complete, on SMP or PREEMPT */
	read_after();

	/* read_before(); read_after(); */
	read_bidir();

	/* Complete all reads from IO before any IO reads which follow
	   this instruction. */
	read_before_io();

	/* Complete all reads (IO or memory) before any reads which follow
	   this instruction. */
	read_before_iomem();

	/* Do not begin any IO reads which follow, before any IO reads
	   which preceed this instruction are complete. */
	read_after_io();

	/* Do not begin any reads (IO or memory) which follow, before any
	   reads which preceed this instruction are complete. */
	read_after_iomem();

	/* read_before_io(); read_after_io(); */
	read_bidir_io();

	/* read_before_iomem(); read_after_iomem(); */
	read_bidir_iomem();

	/* read_before(), even if we are non-PREEMPT, non-SMP. */
	read_before_nonsmp();

	/* read_after(), even if we are non-PREEMPT, non-SMP. */
	read_after_nonsmp();

	/* read_before_nonsmp(); read_after_nonsmp(); */
	read_bidir_nonsmp();

Complete for write_* and readwrite_*.

Suggested semantics spin_lock():
	readwrite_after();
	readwrite_after_io();
ie. no interlock between io and memory: if you're doing both (eg acenic)
you need to put in your own iomem barrier (this is for the PPC folk).

Questions:
1) Can we elide any others?  In particular, can we remove ths _bidir_
   ones?
2) Should we prepend a "barr_" prefix?
3) Any variations I missed?

Cheers,
Rusty.
-- 
   there are those who do and those who hang on and you don't see too
   many doers quoting their contemporaries.  -- Larry McVoy

  reply	other threads:[~2002-05-13  3:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-07 19:07 Memory Barrier Definitions Dave Engebretsen
2002-05-07 19:49 ` Alan Cox
2002-05-07 19:53   ` Dave Engebretsen
2002-05-07 20:27     ` Alan Cox
2002-05-07 21:23       ` Dave Engebretsen
2002-05-07 22:15       ` justincarlson
2002-05-08  2:49         ` Dave Engebretsen
2002-05-08 13:54           ` Justin Carlson
2002-05-08 15:27           ` Dave Engebretsen
2002-05-08 15:49             ` Andi Kleen
2002-05-08 17:07             ` David Mosberger
2002-05-09  7:36               ` Rusty Russell
2002-05-09  8:01                 ` Keith Owens
2002-05-09 15:00                 ` David Mosberger
2002-05-13  3:26                   ` Rusty Russell [this message]
2002-05-13 16:36                     ` David Mosberger
2002-05-13 16:50                       ` Linus Torvalds
2002-05-13 17:53                         ` David Mosberger
2002-05-13 23:28                         ` Rusty Russell
2002-05-07 22:57       ` Anton Blanchard
2002-05-13 18:16         ` Jesse Barnes
  -- strict thread matches above, loose matches on Subject: below --
2002-05-09 11:33 Manfred Spraul
2002-05-09 19:38 ` Dave Engebretsen

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=20020513132605.06b44d85.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=ak@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=anton@samba.org \
    --cc=davidm@hpl.hp.com \
    --cc=engebret@vnet.ibm.com \
    --cc=justincarlson@cmu.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=torvalds@transmeta.com \
    /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