From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH 0/5] use mask operations instead of test_bit() Date: Fri, 2 Oct 2015 11:03:29 +0200 Message-ID: <1443776609.14525.41.camel@citrix.com> References: <1443760830-29095-1-git-send-email-jgross@suse.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2645263942613198651==" Return-path: In-Reply-To: <1443760830-29095-1-git-send-email-jgross@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Juergen Gross Cc: george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, keir@xen.org, jbeulich@suse.com, xen-devel List-Id: xen-devel@lists.xenproject.org --===============2645263942613198651== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-BrnqViPXdiGGhAnTxVDx" --=-BrnqViPXdiGGhAnTxVDx Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2015-10-02 at 06:40 +0200, Juergen Gross wrote: > Instead of using test_bit() which is an atomic operation and limits > the compiler's choices to do optimization, use logical ANDs with > bitmasks where possible. >=20 That's a good idea, I think. > The possible candidates have been detected by searching definitions > of bitmasks in the form: >=20 > #define MASK 1 << _MASK >=20 Right. > On x86 the resulting code is slightly smaller (about 2 bytes for each > case, checked via disassembly in few examples). >=20 > I'm quite sure I didn't replace a test_bit() call required to be > atomic, but I'd be grateful for a thorough review especially in the > scheduler. >=20 I'll have a deep look. One question, can we introduce a __test_bit() macro/inline function, like Jan did with __set_bit? I've quickly-&-dirtily tested this: #define __test_bit(nr, addr) ({ \ unsigned _flags =3D 1 << nr; \ addr & _flags; \ }) and the result (I've checked a couple of cases) seems the same to me. Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-BrnqViPXdiGGhAnTxVDx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlYOSGEACgkQk4XaBE3IOsQzMwCgonu1MmMBmzr+MFKkErETMwaf HpsAoIqQELyGm1aYyGAgkfb05339OP2a =mYmI -----END PGP SIGNATURE----- --=-BrnqViPXdiGGhAnTxVDx-- --===============2645263942613198651== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2645263942613198651==--