From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnd Bergmann <arnd@arndb.de>, <linux-arch@vger.kernel.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
<virtualization@lists.linux-foundation.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Jonathan Corbet <corbet@lwn.net>, <linux-doc@vger.kernel.org>
Subject: Re: [PATCH 01/34] Documentation/memory-barriers.txt: document __smb_mb()
Date: Mon, 4 Jan 2016 11:08:19 +0000 [thread overview]
Message-ID: <alpine.DEB.2.02.1601041104290.19710@kaball.uk.xensource.com> (raw)
In-Reply-To: <1451473761-30019-2-git-send-email-mst@redhat.com>
On Wed, 30 Dec 2015, Michael S. Tsirkin wrote:
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> Documentation/memory-barriers.txt | 33 ++++++++++++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
> index aef9487..a20f7ef 100644
> --- a/Documentation/memory-barriers.txt
> +++ b/Documentation/memory-barriers.txt
> @@ -1655,17 +1655,18 @@ macro is a good place to start looking.
> SMP memory barriers are reduced to compiler barriers on uniprocessor compiled
> systems because it is assumed that a CPU will appear to be self-consistent,
> and will order overlapping accesses correctly with respect to itself.
> +However, see the subsection on "Virtual Machine Guests" below.
>
> [!] Note that SMP memory barriers _must_ be used to control the ordering of
> references to shared memory on SMP systems, though the use of locking instead
> is sufficient.
>
> Mandatory barriers should not be used to control SMP effects, since mandatory
> -barriers unnecessarily impose overhead on UP systems. They may, however, be
> -used to control MMIO effects on accesses through relaxed memory I/O windows.
> -These are required even on non-SMP systems as they affect the order in which
> -memory operations appear to a device by prohibiting both the compiler and the
> -CPU from reordering them.
> +barriers impose unnecessary overhead on both SMP and UP systems. They may,
> +however, be used to control MMIO effects on accesses through relaxed memory I/O
> +windows. These barriers are required even on non-SMP systems as they affect
> +the order in which memory operations appear to a device by prohibiting both the
> +compiler and the CPU from reordering them.
>
>
> There are some more advanced barrier functions:
> @@ -2948,6 +2949,28 @@ The Alpha defines the Linux kernel's memory barrier model.
>
> See the subsection on "Cache Coherency" above.
>
> +VIRTUAL MACHINE GUESTS
> +-------------------
> +
> +Guests running within virtual machines might be affected by
> +SMP effects even if the guest itself is compiled within
^ without
> +SMP support.
> +
> +This is an artifact of interfacing with an SMP host while
> +running an UP kernel.
> +
> +Using mandatory barriers for this use-case would be possible
> +but is often suboptimal.
> +
> +To handle this case optimally, low-level __smp_mb() etc macros are available.
> +These have the same effect as smp_mb() etc when SMP is enabled, but generate
> +identical code for SMP and non-SMP systems. For example, virtual machine guests
> +should use __smp_mb() rather than smp_mb() when synchronizing against a
> +(possibly SMP) host.
> +
> +These are equivalent to smp_mb() etc counterparts in all other respects,
> +in particular, they do not control MMIO effects: to control
> +MMIO effects, use mandatory barriers.
>
> ============
> EXAMPLE USES
> --
> MST
>
next prev parent reply other threads:[~2016-01-04 11:08 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-30 12:58 [PATCH 00/34] arch: barrier cleanup + __smp_xxx barriers for virt Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 01/34] Documentation/memory-barriers.txt: document __smb_mb() Michael S. Tsirkin
2016-01-04 11:08 ` Stefano Stabellini [this message]
2016-01-04 11:27 ` Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 02/34] asm-generic: guard smp_store_release/load_acquire Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 03/34] ia64: rename nop->iosapic_nop Michael S. Tsirkin
2015-12-30 16:39 ` Luck, Tony
2015-12-30 13:24 ` [PATCH 04/34] ia64: reuse asm-generic/barrier.h Michael S. Tsirkin
2015-12-30 16:41 ` Luck, Tony
2015-12-30 13:24 ` [PATCH 05/34] powerpc: " Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 06/34] s390: " Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 07/34] sparc: " Michael S. Tsirkin
2015-12-30 17:56 ` David Miller
2015-12-30 19:55 ` Michael S. Tsirkin
2015-12-30 20:47 ` David Miller
2015-12-30 13:24 ` [PATCH 08/34] asm-generic: smp_store_mb should use smp_mb Michael S. Tsirkin
2015-12-30 13:44 ` Arnd Bergmann
2015-12-30 20:30 ` Michael S. Tsirkin
2015-12-30 22:43 ` Arnd Bergmann
2015-12-30 13:24 ` [PATCH 09/34] arm: reuse asm-generic/barrier.h Michael S. Tsirkin
2015-12-30 13:24 ` [PATCH 10/34] arm64: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 11/34] metag: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 12/34] mips: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 13/34] x86/um: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 14/34] x86: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 15/34] asm-generic: add __smp_xxx wrappers Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 16/34] powerpc: define __smp_xxx Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 17/34] arm64: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 18/34] arm: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 19/34] blackfin: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 20/34] ia64: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 21/34] metag: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 22/34] mips: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 23/34] s390: " Michael S. Tsirkin
2015-12-30 13:25 ` [PATCH 24/34] sh: define __smp_xxx, fix smp_store_mb for !SMP Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 25/34] sparc: define __smp_xxx Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 26/34] tile: " Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 27/34] xtensa: " Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 28/34] x86: define __smp_xxX Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 29/34] Revert "virtio_ring: Update weak barriers to use dma_wmb/rmb" Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 31/34] xenbus: use __smp_xxx barriers Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 32/34] xen/io: " Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 33/34] virtio: use __smp_load_acquire/__smp_store_release Michael S. Tsirkin
2015-12-30 13:26 ` [PATCH 34/34] virtio_ring: use __smp_store_mb Michael S. Tsirkin
2015-12-30 20:46 ` [PATCH 00/34] arch: barrier cleanup + __smp_xxx barriers for virt David Miller
2015-12-30 21:36 ` Michael S. Tsirkin
2015-12-30 21:59 ` David Miller
[not found] ` <11919001.9WHgFoPpmK@wuerfel>
2015-12-30 21:45 ` Michael S. Tsirkin
2015-12-30 22:45 ` Arnd Bergmann
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=alpine.DEB.2.02.1601041104290.19710@kaball.uk.xensource.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=peterz@infradead.org \
--cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®