Commit b2847368 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

vhost: add smp_wmb() before logging used->ring



This doesn't really fix anything as rte_vhost
logging functions are extremely poorly designed
and do smp_wmb() by themselves - but only if
logging is enabled...

Let's move the barrier in our vhost.c. This
doesn't change any behavior, but makes the code
more readable. It surely looked weird to update
the ring, log it, and then do smp_wmb().

Change-Id: I90827b14292b60bd5641a48d546e7249a0496a4b
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/398326


Reviewed-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent da78c670
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -359,10 +359,11 @@ spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_dev *vdev, struct spdk_vhost_v
	vring->last_used_idx++;
	used->ring[last_idx].id = id;
	used->ring[last_idx].len = len;
	spdk_vhost_log_used_vring_elem(vdev, virtqueue, last_idx);

	/* Ensure the used ring is updated before we increment used->idx. */
	/* Ensure the used ring is updated before we log it or increment used->idx. */
	spdk_smp_wmb();

	spdk_vhost_log_used_vring_elem(vdev, virtqueue, last_idx);
	* (volatile uint16_t *) &used->idx = vring->last_used_idx;
	spdk_vhost_log_used_vring_idx(vdev, virtqueue);