Date: Fri, 14 Sep 2012 09:26:52 -0500 (CDT) From: Bryan Venteicher <bryanv@daemoninthecloset.org> To: John Baldwin <jhb@freebsd.org> Cc: svn-src-head@freebsd.org, Konstantin Belousov <kostikbel@gmail.com>, svn-src-all@freebsd.org, src-committers@freebsd.org, Peter Grehan <grehan@freebsd.org> Subject: Re: svn commit: r240427 - head/sys/dev/virtio Message-ID: <2051018874.3102.1347632812362.JavaMail.root@daemoninthecloset.org> In-Reply-To: <201209140817.54376.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, ----- Original Message ----- > From: "John Baldwin" <jhb@freebsd.org> > To: "Konstantin Belousov" <kostikbel@gmail.com> > Cc: "Bryan Venteicher" <bryanv@daemoninthecloset.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, > src-committers@freebsd.org, "Peter Grehan" <grehan@freebsd.org> > Sent: Friday, September 14, 2012 7:17:54 AM > Subject: Re: svn commit: r240427 - head/sys/dev/virtio > > On Friday, September 14, 2012 3:55:20 am Konstantin Belousov wrote: > > On Fri, Sep 14, 2012 at 12:47:52AM -0500, Bryan Venteicher wrote: > > > > > I also found myself wanting an atomic_load_rel_*() type > > > > > function. > > > > > > > > That would be odd I think. _rel barriers only affect stores, > > > > so > > > > there would be no defined ordering between the load and the > > > > subsequent stores. (With our current definitions of _acq and > > > > _rel.) If you need a full fence for some reason, than a plain > > > > mb() may be the best thing in that case. > > > > > > > > > > I'm able to batch add descriptors (via vq_ring_update_avail()), > > > but when checking if I must notify the host, I need to make sure > > > the latest avail->idx is visible before checking the flag from > > > the host on whether notifications are disabled. Gratuitous > > > notifications are fine, but skipping one is not. > > > > > > In the patch, I kludge this with: > > > atomic_add_rel_16(&flags, 0); > > > foo = flags; > > Don't you need > > atomic_store_rel_16(&foo, flags); > > instead ? > > > > You might do a cas_rel over the containing 32bit word as well. > > Yes, the right barrier here would be to use the barrier on the > assignment > to foo. That ensures all other writes post before the write to > 'foo'. >From reading between the lines of atomic(9), I wasn't totally sure where the load of flags is guaranteed to occur with respect to the previous loads/stores. Bryan > > -- > John Baldwin >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2051018874.3102.1347632812362.JavaMail.root>