From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ7mw-00043q-IW for qemu-devel@nongnu.org; Fri, 22 Mar 2013 15:38:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ7mv-0008Tt-2D for qemu-devel@nongnu.org; Fri, 22 Mar 2013 15:38:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ7mu-0008Tg-Qp for qemu-devel@nongnu.org; Fri, 22 Mar 2013 15:38:04 -0400 Message-ID: <514CB312.4090203@redhat.com> Date: Fri, 22 Mar 2013 13:37:54 -0600 From: Eric Blake MIME-Version: 1.0 References: <1363956370-23681-1-git-send-email-pl@kamp.de> <1363956370-23681-3-git-send-email-pl@kamp.de> In-Reply-To: <1363956370-23681-3-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2EHMVPKCVDWXDCCKEULST" Subject: Re: [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero content in a buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Paolo Bonzini , quintela@redhat.com, Orit Wasserman , qemu-devel@nongnu.org, Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2EHMVPKCVDWXDCCKEULST Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/22/2013 06:46 AM, Peter Lieven wrote: > this adds buffer_find_nonzero_offset() which is a SSE2/Altivec > optimized function that searches for non-zero content in a > buffer. >=20 > due to the optimizations used in the function there are restrictions > on buffer address and search length. the function > can_use_buffer_find_nonzero_content() can be used to check if > the function can be used safely. >=20 > Signed-off-by: Peter Lieven > --- > include/qemu-common.h | 13 +++++++++++++ > util/cutils.c | 45 +++++++++++++++++++++++++++++++++++++++++= ++++ > 2 files changed, 58 insertions(+) > +#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8 > +static inline bool > +can_use_buffer_find_nonzero_offset(const void *buf, size_t len) > +{ > + if (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR > + * sizeof(VECTYPE)) =3D=3D 0 > + && ((uintptr_t) buf) % sizeof(VECTYPE) =3D=3D 0) { I know that emacs tends to indent the second line to the column after the ( that it is associated with, as in: + if (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR + * sizeof(VECTYPE)) =3D=3D 0 + && ((uintptr_t) buf) % sizeof(VECTYPE) =3D=3D 0) { But since checkpatch.pl didn't complain, and since I'm not sure if there is a codified qemu indentation style, and since I _am_ sure that not everyone uses emacs [hi, vi guys], it's not worth respinning. A maintainer can touch it up if desired. > + > +size_t buffer_find_nonzero_offset(const void *buf, size_t len) > +{ > + VECTYPE *p =3D (VECTYPE *)buf; > + VECTYPE zero =3D ZERO_SPLAT; > + size_t i; > + > + assert(len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR > + * sizeof(VECTYPE)) =3D=3D 0); > + assert(((uintptr_t) buf) % sizeof(VECTYPE) =3D=3D 0); I would have written this: assert(can_use_buffer_find_nonzero_offset(buf, len)); But that's cosmetic, and compiles to the same code, so it's not worth a respin. You've addressed my concerns on v3. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2EHMVPKCVDWXDCCKEULST Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRTLMSAAoJEKeha0olJ0NqsG8H/iKbL0y+rpzO9jZX0rGwwzfY 1jflb1meM6SoWbXUOvcCmt/x0lGAARdi0Kg8NsaCGdIyYu9aHGHedM/liYAQmfcX FCh7R0bGf6JOP4tsVz8Tfug6h1M5fKpWZkBmtRRnUvOPDV7t9/7lWD8O/YeDFlKk H9EVs0l2ATTtI3UWRjx3jWLu2mhPwxkPkXZCIaImKTeJq1VdJx5ESY1QKUiXAISh oq6952yCdwyyKgMvc9jjuaZenTkOCoRsWodgxdYIHvARKqtmay0khxGK9GVYA4Mo t6anOJyJNs6yoNt3nEU3FZU/prgPDFuADM6aakFNW63ngV4z/8+W7akFy/jwL3g= =dsgF -----END PGP SIGNATURE----- ------enig2EHMVPKCVDWXDCCKEULST--