diff options
| author | Alexander Duyck <alexander.h.duyck@redhat.com> | 2015-04-13 07:33:49 -0400 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-04-13 07:34:16 -0400 |
| commit | 9e1a27ea42691429e31f158cce6fc61bc79bb2e9 (patch) | |
| tree | 46b42dc8ad0ee34fafcf6d7228e51066a550f184 /include | |
| parent | a8557d32fe90a91d70dbbf57a034ad0c660ce237 (diff) | |
virtio_ring: Update weak barriers to use dma_wmb/rmb
This change makes it so that instead of using smp_wmb/rmb which varies
depending on the kernel configuration we can can use dma_wmb/rmb which for
most architectures should be equal to or slightly more strict than
smp_wmb/rmb.
The advantage to this is that these barriers are available to uniprocessor
builds as well so the performance should improve under such a
configuration.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/virtio_ring.h | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index 67e06fe18c03..8e50888a6d59 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h | |||
| @@ -21,19 +21,20 @@ | |||
| 21 | * actually quite cheap. | 21 | * actually quite cheap. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #ifdef CONFIG_SMP | ||
| 25 | static inline void virtio_mb(bool weak_barriers) | 24 | static inline void virtio_mb(bool weak_barriers) |
| 26 | { | 25 | { |
| 26 | #ifdef CONFIG_SMP | ||
| 27 | if (weak_barriers) | 27 | if (weak_barriers) |
| 28 | smp_mb(); | 28 | smp_mb(); |
| 29 | else | 29 | else |
| 30 | #endif | ||
| 30 | mb(); | 31 | mb(); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | static inline void virtio_rmb(bool weak_barriers) | 34 | static inline void virtio_rmb(bool weak_barriers) |
| 34 | { | 35 | { |
| 35 | if (weak_barriers) | 36 | if (weak_barriers) |
| 36 | smp_rmb(); | 37 | dma_rmb(); |
| 37 | else | 38 | else |
| 38 | rmb(); | 39 | rmb(); |
| 39 | } | 40 | } |
| @@ -41,26 +42,10 @@ static inline void virtio_rmb(bool weak_barriers) | |||
| 41 | static inline void virtio_wmb(bool weak_barriers) | 42 | static inline void virtio_wmb(bool weak_barriers) |
| 42 | { | 43 | { |
| 43 | if (weak_barriers) | 44 | if (weak_barriers) |
| 44 | smp_wmb(); | 45 | dma_wmb(); |
| 45 | else | 46 | else |
| 46 | wmb(); | 47 | wmb(); |
| 47 | } | 48 | } |
| 48 | #else | ||
| 49 | static inline void virtio_mb(bool weak_barriers) | ||
| 50 | { | ||
| 51 | mb(); | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void virtio_rmb(bool weak_barriers) | ||
| 55 | { | ||
| 56 | rmb(); | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline void virtio_wmb(bool weak_barriers) | ||
| 60 | { | ||
| 61 | wmb(); | ||
| 62 | } | ||
| 63 | #endif | ||
| 64 | 49 | ||
| 65 | struct virtio_device; | 50 | struct virtio_device; |
| 66 | struct virtqueue; | 51 | struct virtqueue; |
