search for: virtio_mb

Displaying 20 results from an estimated 206 matches for "virtio_mb".

Did you mean: virtio_db
2011 Dec 21
0
[PATCH] virtio: harsher barriers for virtio-mmio.
...rivers/virtio/virtio_ring.c @@ -28,17 +28,20 @@ #ifdef CONFIG_SMP /* Where possible, use SMP barriers which are more lightweight than mandatory * barriers, because mandatory barriers control MMIO effects on accesses - * through relaxed memory I/O windows (which virtio does not use). */ -#define virtio_mb() smp_mb() -#define virtio_rmb() smp_rmb() -#define virtio_wmb() smp_wmb() + * through relaxed memory I/O windows (which virtio-pci does not use). */ +#define virtio_mb(vq) \ + do { if ((vq)->weak_barriers) smp_mb(); else mb(); } while(0) +#define virtio_rmb(vq) \ + do { if ((vq)->weak_barrie...
2011 Dec 21
0
[PATCH] virtio: harsher barriers for virtio-mmio.
...rivers/virtio/virtio_ring.c @@ -28,17 +28,20 @@ #ifdef CONFIG_SMP /* Where possible, use SMP barriers which are more lightweight than mandatory * barriers, because mandatory barriers control MMIO effects on accesses - * through relaxed memory I/O windows (which virtio does not use). */ -#define virtio_mb() smp_mb() -#define virtio_rmb() smp_rmb() -#define virtio_wmb() smp_wmb() + * through relaxed memory I/O windows (which virtio-pci does not use). */ +#define virtio_mb(vq) \ + do { if ((vq)->weak_barriers) smp_mb(); else mb(); } while(0) +#define virtio_rmb(vq) \ + do { if ((vq)->weak_barrie...
2011 Nov 29
4
[RFC] virtio: use mandatory barriers for remote processor vdevs
...d be used by virtio devices that run on remote processors. The CONFIG_SMP variant of virtio_{mb, rmb, wmb} is then changed to use SMP barriers only if VIRTIO_RING_F_REMOTEPROC was absent. Signed-off-by: Ohad Ben-Cohen <ohad at wizery.com> --- Alternatively, we can also introduce some kind of virtio_mb_ops and set it according to the nature of the vdev with handlers that just do the right thing, instead of introducting that branch. Though I also wonder how big really is the perforamnce gain of d57ed95 ? drivers/virtio/virtio_ring.c | 78 +++++++++++++++++++++++++++++------------- include/lin...
2011 Nov 29
4
[RFC] virtio: use mandatory barriers for remote processor vdevs
...d be used by virtio devices that run on remote processors. The CONFIG_SMP variant of virtio_{mb, rmb, wmb} is then changed to use SMP barriers only if VIRTIO_RING_F_REMOTEPROC was absent. Signed-off-by: Ohad Ben-Cohen <ohad at wizery.com> --- Alternatively, we can also introduce some kind of virtio_mb_ops and set it according to the nature of the vdev with handlers that just do the right thing, instead of introducting that branch. Though I also wonder how big really is the perforamnce gain of d57ed95 ? drivers/virtio/virtio_ring.c | 78 +++++++++++++++++++++++++++++------------- include/lin...
2015 Dec 17
2
[PATCH] virtio_ring: use smp_store_mb
...t; > + __virtio16 *p, __virtio16 v) > > +{ > > +#ifdef CONFIG_SMP > > + if (weak_barriers) > > + smp_store_mb(*p, v); > > + else > > +#endif > > + { > > + WRITE_ONCE(*p, v); > > + mb(); > > + } > > +} > > Note that virtio_mb() is weirdly inconsistent with virtio_[rw]mb() in > that they use dma_* ops for weak_barriers, while virtio_mb() uses > smp_mb(). It's a hack really. I think I'll clean it up a bit to make it more consistent. To simplify things, you may consider things before the optimization brough...
2015 Dec 17
2
[PATCH] virtio_ring: use smp_store_mb
...t; > + __virtio16 *p, __virtio16 v) > > +{ > > +#ifdef CONFIG_SMP > > + if (weak_barriers) > > + smp_store_mb(*p, v); > > + else > > +#endif > > + { > > + WRITE_ONCE(*p, v); > > + mb(); > > + } > > +} > > Note that virtio_mb() is weirdly inconsistent with virtio_[rw]mb() in > that they use dma_* ops for weak_barriers, while virtio_mb() uses > smp_mb(). It's a hack really. I think I'll clean it up a bit to make it more consistent. To simplify things, you may consider things before the optimization brough...
2010 Jan 27
1
[PATCHv2] virtio: use smp_XX barriers on SMP
...ry barriers are used to control SMP effects. */ +#ifdef CONFIG_SMP +/* Where possible, use SMP barriers which are more lightweight than mandatory + * barriers, because mandatory barriers control MMIO effects on accesses + * through relaxed memory I/O windows (which virtio does not use). */ +#define virtio_mb() smp_mb() +#define virtio_rmb() smp_rmb() +#define virtio_wmb() smp_wmb() +#else +/* 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 fall back to mandatory barriers instead. */...
2010 Jan 27
1
[PATCHv2] virtio: use smp_XX barriers on SMP
...ry barriers are used to control SMP effects. */ +#ifdef CONFIG_SMP +/* Where possible, use SMP barriers which are more lightweight than mandatory + * barriers, because mandatory barriers control MMIO effects on accesses + * through relaxed memory I/O windows (which virtio does not use). */ +#define virtio_mb() smp_mb() +#define virtio_rmb() smp_rmb() +#define virtio_wmb() smp_wmb() +#else +/* 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 fall back to mandatory barriers instead. */...
2015 Dec 17
4
[PATCH] virtio_ring: use smp_store_mb
...for the next entry, tell host * by writing event index and flush out the write before * the read in the next get_buf call. */ - if (!(vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) { - vring_used_event(&vq->vring) = cpu_to_virtio16(_vq->vdev, vq->last_used_idx); - virtio_mb(vq->weak_barriers); - } + if (!(vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) + virtio_store_mb(vq->weak_barriers, + &vring_used_event(&vq->vring), + cpu_to_virtio16(_vq->vdev, vq->last_used_idx)); #ifdef DEBUG vq->last_add_time_valid = false; @@...
2015 Dec 17
4
[PATCH] virtio_ring: use smp_store_mb
...for the next entry, tell host * by writing event index and flush out the write before * the read in the next get_buf call. */ - if (!(vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) { - vring_used_event(&vq->vring) = cpu_to_virtio16(_vq->vdev, vq->last_used_idx); - virtio_mb(vq->weak_barriers); - } + if (!(vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) + virtio_store_mb(vq->weak_barriers, + &vring_used_event(&vq->vring), + cpu_to_virtio16(_vq->vdev, vq->last_used_idx)); #ifdef DEBUG vq->last_add_time_valid = false; @@...
2018 Sep 07
1
[PATCH net-next v2 4/5] virtio_ring: add event idx support in packed ring
...ruct vring_virtqueue *vq = to_vvq(_vq); > - u16 flags; > + u16 new, old, off_wrap, flags, wrap_counter, event_idx; > bool needs_kick; > u32 snapshot; > > @@ -1059,9 +1059,19 @@ static bool virtqueue_kick_prepare_packed(struct virtqueue *_vq) > * suppressions. */ > virtio_mb(vq->weak_barriers); > > + old = vq->next_avail_idx - vq->num_added; > + new = vq->next_avail_idx; > + vq->num_added = 0; > + > snapshot = READ_ONCE(*(u32 *)vq->vring_packed.device); > + off_wrap = virtio16_to_cpu(_vq->vdev, (__virtio16)(snapshot & 0...
2012 Jan 20
3
[PATCH 1/2] virtio: fix typos of memory barriers
Signed-off-by: Jason Wang <jasowang at redhat.com> --- drivers/virtio/virtio_ring.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 79e1b29..78428a8 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -35,7 +35,7 @@ #define virtio_rmb(vq) \ do { if
2012 Jan 20
3
[PATCH 1/2] virtio: fix typos of memory barriers
Signed-off-by: Jason Wang <jasowang at redhat.com> --- drivers/virtio/virtio_ring.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 79e1b29..78428a8 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -35,7 +35,7 @@ #define virtio_rmb(vq) \ do { if
2018 Jun 07
1
[RFC v6 4/5] virtio_ring: add event idx support in packed ring
...t;event ? VRING_EVENT_F_DESC : > + VRING_EVENT_F_ENABLE; > vq->vring_packed.driver->flags = cpu_to_virtio16(_vq->vdev, > vq->event_flags_shadow); > - /* We need to enable interrupts first before re-checking > - * for more used buffers. */ > - virtio_mb(vq->weak_barriers); > } > > + /* We need to update event suppression structure first > + * before re-checking for more used buffers. */ > + virtio_mb(vq->weak_barriers); > + > if (more_used_packed(vq)) { > END_USE(vq); > return false; I think what...
2016 Jan 01
0
[PATCH v2 30/32] virtio_ring: update weak barriers to use __smp_xxx
...xed memory I/O windows, so smp_mb() et al are + * accesses through relaxed memory I/O windows, so virt_mb() et al are * sufficient. * * For using virtio to talk to real devices (eg. other heterogeneous @@ -21,11 +21,10 @@ * actually quite cheap. */ -#ifdef CONFIG_SMP static inline void virtio_mb(bool weak_barriers) { if (weak_barriers) - smp_mb(); + virt_mb(); else mb(); } @@ -33,7 +32,7 @@ static inline void virtio_mb(bool weak_barriers) static inline void virtio_rmb(bool weak_barriers) { if (weak_barriers) - smp_rmb(); + virt_rmb(); else rmb(); } @@ -41,26 +40,10 @...
2013 Jul 08
4
[PATCH 2/2] virtio_net: fix race in RX VQ processing
...onize virtqueue_enable_cq wrt virtqueue_add_buf. In particular, used event can move backwards, causing us to lose interrupts. In a debug build, this can trigger panic within START_USE. Jason Wang reports that he can trigger the races artificially, by adding udelay() in virtqueue_enable_cb() after virtio_mb(). However, we must call napi_complete to clear NAPI_STATE_SCHED before polling the virtqueue for used buffers, otherwise napi_schedule_prep in a callback will fail, causing us to lose RX events. To fix, call virtqueue_enable_cb_prepare with NAPI_STATE_SCHED set (under napi lock), later call virt...
2013 Jul 08
4
[PATCH 2/2] virtio_net: fix race in RX VQ processing
...onize virtqueue_enable_cq wrt virtqueue_add_buf. In particular, used event can move backwards, causing us to lose interrupts. In a debug build, this can trigger panic within START_USE. Jason Wang reports that he can trigger the races artificially, by adding udelay() in virtqueue_enable_cb() after virtio_mb(). However, we must call napi_complete to clear NAPI_STATE_SCHED before polling the virtqueue for used buffers, otherwise napi_schedule_prep in a callback will fail, causing us to lose RX events. To fix, call virtqueue_enable_cb_prepare with NAPI_STATE_SCHED set (under napi lock), later call virt...
2015 Apr 08
3
[PATCH] virtio_ring: Update weak barriers to use dma_wmb/rmb
...ertions(+), 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 @@ * actually quite cheap. */ -#ifdef CONFIG_SMP static inline void virtio_mb(bool weak_barriers) { +#ifdef CONFIG_SMP if (weak_barriers) smp_mb(); else +#endif mb(); } static inline void virtio_rmb(bool weak_barriers) { if (weak_barriers) - smp_rmb(); + dma_rmb(); else rmb(); } @@ -41,26 +42,10 @@ static inline void virtio_rmb(bool weak_barriers)...
2015 Apr 08
3
[PATCH] virtio_ring: Update weak barriers to use dma_wmb/rmb
...ertions(+), 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 @@ * actually quite cheap. */ -#ifdef CONFIG_SMP static inline void virtio_mb(bool weak_barriers) { +#ifdef CONFIG_SMP if (weak_barriers) smp_mb(); else +#endif mb(); } static inline void virtio_rmb(bool weak_barriers) { if (weak_barriers) - smp_rmb(); + dma_rmb(); else rmb(); } @@ -41,26 +42,10 @@ static inline void virtio_rmb(bool weak_barriers)...
2018 Jul 09
0
[PATCH net-next v1 4/5] virtio_ring: add event idx support in packed ring
...re_packed(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); - u16 flags; + u16 new, old, off_wrap, flags, wrap_counter, event_idx; bool needs_kick; u32 snapshot; @@ -1059,9 +1059,19 @@ static bool virtqueue_kick_prepare_packed(struct virtqueue *_vq) * suppressions. */ virtio_mb(vq->weak_barriers); + old = vq->next_avail_idx - vq->num_added; + new = vq->next_avail_idx; + vq->num_added = 0; + snapshot = *(u32 *)vq->vring_packed.device; + off_wrap = virtio16_to_cpu(_vq->vdev, (__virtio16)(snapshot & 0xffff)); flags = virtio16_to_cpu(_vq->vde...