svn commit: r240427 - head/sys/dev/virtio

John Baldwin jhb at freebsd.org
Thu Sep 13 14:27:55 UTC 2012


On Wednesday, September 12, 2012 8:36:47 pm Peter Grehan wrote:
> Author: grehan
> Date: Thu Sep 13 00:36:46 2012
> New Revision: 240427
> URL: http://svn.freebsd.org/changeset/base/240427
> 
> Log:
>   Relax requirement of certain mb()s
>   
>   Submitted by:	Bryan Venteicher bryanv at daemoninthecloset org
> 
> Modified:
>   head/sys/dev/virtio/virtqueue.c
> 
> Modified: head/sys/dev/virtio/virtqueue.c
> 
==============================================================================
> --- head/sys/dev/virtio/virtqueue.c	Wed Sep 12 22:54:11 2012	(r240426)
> +++ head/sys/dev/virtio/virtqueue.c	Thu Sep 13 00:36:46 2012	(r240427)
> @@ -525,7 +525,7 @@ virtqueue_dequeue(struct virtqueue *vq, 
>  	used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);
>  	uep = &vq->vq_ring.used->ring[used_idx];
>  
> -	mb();
> +	rmb();
>  	desc_idx = (uint16_t) uep->id;
>  	if (len != NULL)
>  		*len = uep->len;
> @@ -623,7 +623,7 @@ vq_ring_update_avail(struct virtqueue *v
>  	avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);
>  	vq->vq_ring.avail->ring[avail_idx] = desc_idx;
>  
> -	mb();
> +	wmb();
>  	vq->vq_ring.avail->idx++;
>  
>  	/* Keep pending count until virtqueue_notify(). */

Would it be possible to use atomic_load/store() instead of direct
memory barriers?  For example:

	desc_idx = (uint16_t)atomic_load_acq_int(&uep->id);

and

	atomic_store_rel_int(&vq->vq_ring.avail->ring[avail_idx], desc_idx);

-- 
John Baldwin


More information about the svn-src-head mailing list