From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEdLV-0000Pq-0C for qemu-devel@nongnu.org; Tue, 05 Aug 2014 07:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEdLQ-0002qK-J2 for qemu-devel@nongnu.org; Tue, 05 Aug 2014 07:56:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEdLQ-0002q6-Bo for qemu-devel@nongnu.org; Tue, 05 Aug 2014 07:55:56 -0400 Message-ID: <53E0C645.5050106@redhat.com> Date: Tue, 05 Aug 2014 05:55:49 -0600 From: Eric Blake MIME-Version: 1.0 References: <1407209598-2572-1-git-send-email-ming.lei@canonical.com> <1407209598-2572-2-git-send-email-ming.lei@canonical.com> In-Reply-To: <1407209598-2572-2-git-send-email-ming.lei@canonical.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KK4dfxOFpP07cj1q6K5GolPR4QC3NjtuC" Subject: Re: [Qemu-devel] [PATCH v1 01/17] qemu/obj_pool.h: introduce object allocation pool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei , qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Stefan Hajnoczi Cc: Kevin Wolf , Fam Zheng , "Michael S. Tsirkin" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --KK4dfxOFpP07cj1q6K5GolPR4QC3NjtuC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/04/2014 09:33 PM, Ming Lei wrote: > This patch introduces object allocation pool for speeding up > object allocation in fast path. >=20 > Signed-off-by: Ming Lei > --- > include/qemu/obj_pool.h | 64 +++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 64 insertions(+) > create mode 100644 include/qemu/obj_pool.h >=20 > diff --git a/include/qemu/obj_pool.h b/include/qemu/obj_pool.h > new file mode 100644 > index 0000000..94b5f49 > --- /dev/null > +++ b/include/qemu/obj_pool.h > @@ -0,0 +1,64 @@ > +#ifndef QEMU_OBJ_POOL_HEAD > +#define QEMU_OBJ_POOL_HEAD Missing copyright boilerplate. According to LICENSE, that makes this file GPLv2+, but I'd much rather you make it explicit. > + > +typedef struct { > + unsigned int size; > + unsigned int cnt; size_t feels better for sizes. int may be okay in this case, but definitely consider if size_t is appropriate. > + > + void **free_obj; > + int free_idx; > + > + char *objs; > +} ObjPool; > + > +static inline void obj_pool_init(ObjPool *op, void *objs_buf, void **f= ree_objs, > + unsigned int obj_size, unsigned cnt) > +{ > + int i; > + > + op->objs =3D (char *)objs_buf; Why the cast? This is C, not C++. > + op->free_obj =3D free_objs; > + op->size =3D obj_size; > + op->cnt =3D cnt; > + > + for (i =3D 0; i < op->cnt; i++) { > + op->free_obj[i] =3D (void *)&op->objs[i * op->size]; Again, why the cast? > +static inline bool obj_pool_has_obj(ObjPool *op, void *obj) > +{ > + return op && (unsigned long)obj >=3D (unsigned long)&op->objs[0] &= & > + (unsigned long)obj <=3D > + (unsigned long)&op->objs[(op->cnt - 1) * op->size]; uintptr_t, not unsigned long. You are asking for problems on 64-bit mingw, where unsigned long is 32 bits but uintptr_t is 64 bits. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --KK4dfxOFpP07cj1q6K5GolPR4QC3NjtuC 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJT4MZFAAoJEKeha0olJ0Nqh18IAKjXi/mo1AsjQqAjv0IW2T1b 2Dd/ea6psFl1jWO4iE5XW13uCStzbvlgQWKMqriv+NRBIC1td8WpwYTgxIvEkMr/ 72Gy2w+auITOrLaqngNU1YRSMqX1wN29NnHsL3tkhgSXk6ItqAbake4ltwI/IGxb PRNsGhjbCb9N5LJhfFlMqSw5YDYwOOYLlpmTcoIy4x9/bHqWcTtEvkupqyvAUc7s ovp3gQFgzNkCN/yLVkoB43UaD7kdrdyBZW/PoaXCZBK4Pa/EgyGPpDM0uVG8Hhqw ryo4jO+G7ee95M2FnJkr83oJI/ky2jKQkdWK2aqlVQAZfkv+64bihvBjKy6w8y8= =0585 -----END PGP SIGNATURE----- --KK4dfxOFpP07cj1q6K5GolPR4QC3NjtuC--