[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to d
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage |
Date: |
Tue, 27 Sep 2016 10:48:57 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
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.
>
> Signed-off-by: Peter Lieven <address@hidden>
> ---
> configure | 19 +++++++++++++++++++
> util/oslib-posix.c | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
> @@ -534,10 +541,38 @@ void *qemu_alloc_stack(size_t *sz)
> abort();
> }
>
> +#ifdef CONFIG_DEBUG_STACK_USAGE
> + for (ptr2 = ptr + pagesz; ptr2 < ptr + *sz; ptr2 += sizeof(uint32_t)) {
> + *(uint32_t *)ptr2 = 0xdeadbeaf;
It's usually spelled 0xdeadbeef, if you want to tweak it.
> + }
> +#endif
> +
> return ptr;
> }
>
> +#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 = stack + getpagesize(); ptr < stack + sz;
> + ptr += sizeof(uint32_t)) {
> + if (*(uint32_t *)ptr != 0xdeadbeaf) {
Of course, you'd have to do it here, too.
Either way,
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH V9 0/7] coroutine: mmap stack memory and stack size, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 3/7] coroutine: add a macro for the coroutine stack size, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 1/7] oslib-posix: add helpers for stack alloc and free, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage, Peter Lieven, 2016/09/27
- Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage,
Eric Blake <=
- [Qemu-devel] [PATCH V9 5/7] coroutine-sigaltstack: use helper for allocating stack memory, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 7/7] coroutine: reduce stack size to 60kB, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 2/7] coroutine-sigaltstack: rename coroutine struct appropriately, Peter Lieven, 2016/09/27
- [Qemu-devel] [PATCH V9 4/7] coroutine-ucontext: use helper for allocating stack memory, Peter Lieven, 2016/09/27