]> git.baikalelectronics.ru Git - kernel.git/commit
virtio: use smp_XX barriers on SMP
authorMichael S. Tsirkin <mst@redhat.com>
Wed, 27 Jan 2010 22:42:23 +0000 (00:42 +0200)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 24 Feb 2010 03:52:25 +0000 (14:22 +1030)
commitea130ab32e538d1eb6d4d5c6f38a222fbe3fb47c
tree0eb215813f3066bf634a395d02cf4aab3ba94fc6
parentbbe955604f00a16599a2db1b6488025b8b786fed
virtio: use smp_XX barriers on SMP

virtio is communicating with a virtual "device" that actually runs on
another host processor. Thus SMP barriers can be used to control
memory access ordering.

Where possible, we should use SMP barriers which are more lightweight than
mandatory barriers, because mandatory barriers also control MMIO effects on
accesses through relaxed memory I/O windows (which virtio does not use)
(compare specifically smp_rmb and rmb on x86_64).

We can't just use smp_mb and friends though, because
we must force memory ordering even if guest is UP since host could be
running on another CPU, but SMP barriers are defined to barrier() in
that configuration. So, for UP fall back to mandatory barriers instead.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/virtio/virtio_ring.c