From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvRPD-0003b1-53 for qemu-devel@nongnu.org; Mon, 01 Dec 2014 08:52:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvRP6-0002Lj-Sl for qemu-devel@nongnu.org; Mon, 01 Dec 2014 08:52:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvRP6-0002LS-Js for qemu-devel@nongnu.org; Mon, 01 Dec 2014 08:52:40 -0500 Date: Mon, 1 Dec 2014 13:52:36 +0000 From: Stefan Hajnoczi Message-ID: <20141201135236.GA6744@stefanha-thinkpad.redhat.com> References: <1417091366-4469-1-git-send-email-stefanha@redhat.com> <1417091366-4469-2-git-send-email-stefanha@redhat.com> <54775481.9020605@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline In-Reply-To: <54775481.9020605@redhat.com> Subject: Re: [Qemu-devel] [RFC 1/6] bitmap: add atomic set functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Peter Maydell , Juan Quintela , qemu-devel@nongnu.org, rth@redhat.com --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 27, 2014 at 05:42:41PM +0100, Paolo Bonzini wrote: >=20 >=20 > On 27/11/2014 13:29, Stefan Hajnoczi wrote: > > +void bitmap_set_atomic(unsigned long *map, long start, long nr) > > +{ > > + unsigned long *p =3D map + BIT_WORD(start); > > + const long size =3D start + nr; > > + int bits_to_set =3D BITS_PER_LONG - (start % BITS_PER_LONG); > > + unsigned long mask_to_set =3D BITMAP_FIRST_WORD_MASK(start); > > + > > + while (nr - bits_to_set >=3D 0) { > > + atomic_or(p, mask_to_set); >=20 > atomic_or is unnecessary while mask_to_set is ~0UL. I think not even a > smp_wmb() is necessary. Okay, I can split this into the ~0UL case and the atomic case. --ZGiS0Q5IWpPtfppv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUfHKkAAoJEJykq7OBq3PIy/YH/2XqDsdVg7iZID+CxH54rhuL QulnNzgnXcS3spBm8UcShgxfQfn+G2Xr7F4Vmz70h/GVWdE9bq+yzGXaq3EC72LY rZS6s5dXhvkn0n5KQcKrZiI319gKza4wf27KpOxtDDb+epYRRsH8SPXvADLfsNtA koqueNxeSLyW8Ax+y8++zSxUpy54UDQnm4PYt7/UzHkzjmcLQC2BHHzYx/fK1BuJ d4UCqguDeFHr0MsHXxA+o9EMy7LfHoyAQsvYcIO/Ms7bbVk9XeVqwP0tsaNPRhN2 FtSvnKQr6cztNLTwwqj1wP715GxrokgclYfEvyQhFra1Ovmu9MhxfpEvHo7C7aE= =XHhv -----END PGP SIGNATURE----- --ZGiS0Q5IWpPtfppv--