From owner-svn-src-head@FreeBSD.ORG Fri Sep 14 07:55:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 035CD106566B; Fri, 14 Sep 2012 07:55:34 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 732828FC0C; Fri, 14 Sep 2012 07:55:32 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q8E7tZev086264; Fri, 14 Sep 2012 10:55:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q8E7tKiV000737; Fri, 14 Sep 2012 10:55:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q8E7tK8a000736; Fri, 14 Sep 2012 10:55:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 14 Sep 2012 10:55:20 +0300 From: Konstantin Belousov To: Bryan Venteicher Message-ID: <20120914075520.GA37286@deviant.kiev.zoral.com.ua> References: <201209131456.03422.jhb@freebsd.org> <2045684227.3044.1347601672495.JavaMail.root@daemoninthecloset.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="edESjMboOAwUFn6i" Content-Disposition: inline In-Reply-To: <2045684227.3044.1347601672495.JavaMail.root@daemoninthecloset.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Peter Grehan , John Baldwin 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: Fri, 14 Sep 2012 07:55:34 -0000 --edESjMboOAwUFn6i Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 14, 2012 at 12:47:52AM -0500, Bryan Venteicher wrote: > Hi >=20 > ----- Original Message ----- > > From: "John Baldwin" > > To: "Bryan Venteicher" > > Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@f= reebsd.org, "Peter Grehan" > > > > Sent: Thursday, September 13, 2012 1:56:03 PM > > Subject: Re: svn commit: r240427 - head/sys/dev/virtio > >=20 > > On Thursday, September 13, 2012 12:40:42 pm Bryan Venteicher wrote: > > > > Would it be possible to use atomic_load/store() instead of direct > > > > memory barriers? For example: > > > >=20 > > >=20 > > > 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). > >=20 > > That is the one thing I was worried about (the fields being defined > > to be 16-bit). I presume that is required by the virtio de facto > > standard? Shame we can't clue-by-four people putting 16-bit fields > > in these sort of things. :-P > >=20 >=20 > Yes, the 16-bit fields are mandated by the VirtIO spec. The guest/host > shared memory is rounded up to next full page, so there actually isn't > any memory savings for typical queue sizes. Doubt it is any worse than > actual hardware regardless. >=20 > > > I also found myself wanting an atomic_load_rel_*() type function. > >=20 > > 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. > >=20 >=20 > 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. >=20 > In the patch, I kludge this with: > atomic_add_rel_16(&flags, 0); > foo =3D 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. >=20 > Hoping the dependency would prevent the assignment to foo from > floating above the atomic_add_rel().=20 >=20 > I originally did the atomic(9) work just to see if there would be > any performance difference between the two - I wasn't able to > measure any, but I don't have the most modern hardware either. >=20 > Bryan >=20 > > -- > > John Baldwin > >=20 --edESjMboOAwUFn6i Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBS4ugACgkQC3+MBN1Mb4hk0wCgmOgvk2HSrmNPZDs/91H7xVe5 kCUAoKfYlsybYMewFcFIiyYFokrQgiWg =ziFt -----END PGP SIGNATURE----- --edESjMboOAwUFn6i--