Received: from eggs.gnu.org ([2001:4830:134:3::10]:43331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boucw-0003k5-W7 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 11:49:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boucu-0003Rc-Qi for qemu-devel@nongnu.org; Tue, 27 Sep 2016 11:49:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boucu-0003RR-H4 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 11:49:00 -0400 References: <1474970326-10271-1-git-send-email-pl@kamp.de> <1474970326-10271-7-git-send-email-pl@kamp.de> From: Eric Blake Message-ID: <2720cd49-7b70-9938-775d-5f27828ce8c8@redhat.com> Date: Tue, 27 Sep 2016 10:48:57 -0500 MIME-Version: 1.0 In-Reply-To: <1474970326-10271-7-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PIuWrxcm7O7iIAFLDPKiifKrFjhiLsiVh" Subject: Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org, rth@twiddle.net, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PIuWrxcm7O7iIAFLDPKiifKrFjhiLsiVh From: Eric Blake To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org, rth@twiddle.net, armbru@redhat.com Message-ID: <2720cd49-7b70-9938-775d-5f27828ce8c8@redhat.com> Subject: Re: [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage References: <1474970326-10271-1-git-send-email-pl@kamp.de> <1474970326-10271-7-git-send-email-pl@kamp.de> In-Reply-To: <1474970326-10271-7-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/27/2016 04:58 AM, Peter Lieven wrote: > this adds a knob to track the maximum stack usage of stacks > created by qemu_alloc_stack. >=20 > Signed-off-by: Peter Lieven > --- > configure | 19 +++++++++++++++++++ > util/oslib-posix.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 54 insertions(+) > @@ -534,10 +541,38 @@ void *qemu_alloc_stack(size_t *sz) > abort(); > } > =20 > +#ifdef CONFIG_DEBUG_STACK_USAGE > + for (ptr2 =3D ptr + pagesz; ptr2 < ptr + *sz; ptr2 +=3D sizeof(uin= t32_t)) { > + *(uint32_t *)ptr2 =3D 0xdeadbeaf; It's usually spelled 0xdeadbeef, if you want to tweak it. > + } > +#endif > + > return ptr; > } > =20 > +#ifdef CONFIG_DEBUG_STACK_USAGE > +static __thread unsigned int max_stack_usage; > +#endif > + > void qemu_free_stack(void *stack, size_t sz) > { > +#ifdef CONFIG_DEBUG_STACK_USAGE > + unsigned int usage; > + void *ptr; > + > + for (ptr =3D stack + getpagesize(); ptr < stack + sz; > + ptr +=3D sizeof(uint32_t)) { > + if (*(uint32_t *)ptr !=3D 0xdeadbeaf) { Of course, you'd have to do it here, too. Either way, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PIuWrxcm7O7iIAFLDPKiifKrFjhiLsiVh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX6pTpAAoJEKeha0olJ0NqKCkH/0ztitK6nnXCbU79nAQ1Qara F/YIjr7qbK+wetWQz3PjPc8wHgDanQfW8e6mVoqhDX/t1OhQM1eUH9Nyr+0GVhin MzcaWJQ/mqlAwp1KMBkADAOQgjigMIw4euK3z/JvZ7kZJ4fGS1chhjXo9hCsMYME gwkS7vWbV5s8d1V90vT5aQNoT0vFFd0dSn9IGYiXIb3N+sOs4jOOId0l6pCBPxBb nnLBmOoG/K7KGG70u9NEBuViw32b8R7Q/Z0bbiPY0vRwKczzS5BsaNw2FIpg1ND4 x3YRIIKIWp3mvFZUuqxyk2x1o8/InD6TAFQs8Ys7GIBdaKHw6jJOplXrnLzTmhU= =jvS8 -----END PGP SIGNATURE----- --PIuWrxcm7O7iIAFLDPKiifKrFjhiLsiVh--