From owner-svn-src-head@FreeBSD.ORG Thu Sep 13 18:40:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E63281065679; Thu, 13 Sep 2012 18:40:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id A91768FC0C; Thu, 13 Sep 2012 18:40:35 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 76E37B946; Thu, 13 Sep 2012 14:40:34 -0400 (EDT) From: John Baldwin To: Bryan Venteicher Date: Thu, 13 Sep 2012 14:40:32 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <651175615.1815.1347554442005.JavaMail.root@daemoninthecloset.org> In-Reply-To: <651175615.1815.1347554442005.JavaMail.root@daemoninthecloset.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201209131440.32903.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 13 Sep 2012 14:40:34 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Peter Grehan Subject: Re: svn commit: r240427 - head/sys/dev/virtio X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2012 18:40:36 -0000 On Thursday, September 13, 2012 12:40:42 pm Bryan Venteicher wrote: > Hi, > > ----- Original Message ----- > > From: "John Baldwin" > > To: "Peter Grehan" > > Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src- committers@freebsd.org > > Sent: Thursday, September 13, 2012 7:59:38 AM > > Subject: Re: svn commit: r240427 - head/sys/dev/virtio > > > > 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: > > > > I've been sitting on a (lightly tested) patch [1] for awhile that > does just that, but am not very happy with it. A lot of the fields > are 16-bit, which not all architectures have atomic(9) support for. > And I think the atomic(9) behavior on UP kernels does not provide > the same guarantees as on an SMP kernel (could have an UP kernel > on an SMP host). > > I also found myself wanting an atomic_load_rel_*() type function. > > > desc_idx = (uint16_t)atomic_load_acq_int(&uep->id); > > > > and > > > > atomic_store_rel_int(&vq->vq_ring.avail->ring[avail_idx], desc_idx); > > avail->ring is an array of uint16's so I'm a bit leery of using a > (presumably) 32bit op on it. > > [1] http://www.daemoninthecloset.org/~bryanv/patches/freebsd/vq_atomic.patch > > > > > -- > > John Baldwin > > _______________________________________________ > > svn-src-head@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/svn-src-head > > To unsubscribe, send any mail to > > "svn-src-head-unsubscribe@freebsd.org" > > > -- John Baldwin