public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@engr.sgi.com>
To: Anton Blanchard <anton@samba.org>
Cc: Matthew Wilcox <matthew@wil.cx>,
	David Howells <dhowells@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH] ?mb() -> smp_?mb() conversion
Date: Tue, 22 Mar 2005 10:15:57 -0800	[thread overview]
Message-ID: <200503221015.57732.jbarnes@engr.sgi.com> (raw)
In-Reply-To: <20050322160324.GA4980@krispykreme>

On Tuesday, March 22, 2005 8:03 am, Anton Blanchard wrote:
> > > Would it be worth renaming the mb/rmb/wmb to io_mb/io_rmb/io_wmb?
> > > After all, I believe they should only be used to flush I/O memory
> > > accesses. This would, I think, make the distinction between memory
> > > barriers for I/O and memory barriers for SMP more obvious.
> >
> > Are you joking or genuinely confused?
>
> To be fair there are a lot of confused people out there. A few examples:
>
> 1. My original patch showed there are a number of places we use memory
> barriers on UP when not required. Getting rid of mb/rmb/wmb would help
> this, people are unlikely to sprinkle io_mb in the scheduler code :)
>
> 2. drivers/net/typhoon.c
>
>                 INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP);
>                 smp_wmb();
>                 writel(ring->lastWrite, tp->ioaddr +
> TYPHOON_REG_CMD_READY);

I think this is the same as (3) below, since the first line is writing memory.  
So I'd agree that we need an I/O vs. memory barrier of some sort for 
platforms like ppc64 where they can be reordered independently.

>
> it looks a lot like smp_wmb is being used to order IO.
>
> 3. On ppc64 we recently had to upgrade our barriers to make sure
> mb/wmb/rmb ordered IO. This is because drivers do this (example taken
> from e1000):
>
>         tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
>
>         /* Force memory writes to complete before letting h/w
>          * know there are new descriptors to fetch.  (Only
>          * applicable for weak-ordered memory model archs,
>          * such as IA-64). */
>         wmb();
>
>         tx_ring->next_to_use = i;
>         E1000_WRITE_REG(&adapter->hw, TDT, i);
>
> Renaming mb/wmb/rmb to io_mb/io_wmb/io_rmb would fit in well here.

Yep.

> 4. Its not clear other architectures are insuring wmb/rmb/mb are
> ordering IO. Checking ia64:
>
>  * Note: "mb()" and its variants cannot be used as a fence to order
>  * accesses to memory mapped I/O registers.  For that, mf.a needs to
>  * be used.  However, we don't want to always use mf.a because (a)
>  * it's (presumably) much slower than mf and (b) mf.a is supported for
>  * sequential memory pages only.

Right.  And then there's pure I/O ordering, which as James pointed out can be 
implemented with mmiowb.  So let's see, we have

memory vs. memory writes: smp_wmb()
I/O vs. I/O writes: mmiowb() (and/or io_wmb()?)
memory vs. I/O writes: io_wmb()

right?  And for reads:

memory vs. memory reads: smp_rmb
I/O vs. I/O reads: io_rmb()?
memory vs. I/O reads: io_rmb()

Is that an accurate summary?

Jesse

  parent reply	other threads:[~2005-03-22 18:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-21 22:59 [PATCH] ?mb() -> smp_?mb() conversion Anton Blanchard
2005-03-21 23:06 ` David S. Miller
2005-03-22 10:43   ` David Howells
2005-03-22 13:13     ` Matthew Wilcox
2005-03-22 14:27       ` David Howells
2005-03-22 16:03       ` Anton Blanchard
2005-03-22 16:34         ` Matthew Wilcox
2005-03-22 16:48           ` David Howells
2005-03-22 17:13             ` David S. Miller
2005-03-22 17:44               ` James Bottomley
2005-03-22 18:09                 ` Jesse Barnes
2005-03-22 18:00               ` David Howells
2005-03-22 21:59               ` Paul Mackerras
2005-03-22 18:15         ` Jesse Barnes [this message]
2005-03-22 18:24           ` Jesse Barnes
2005-03-23  6:23         ` Paul Mackerras

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=200503221015.57732.jbarnes@engr.sgi.com \
    --to=jbarnes@engr.sgi.com \
    --cc=anton@samba.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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