qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com,
	mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org,
	eblake@redhat.com, rth@twiddle.net, armbru@redhat.com,
	Peter Lieven <pl@kamp.de>
Subject: [Qemu-devel] [PATCH V8 3/6] coroutine-ucontext: use helper for allocating stack memory
Date: Mon, 26 Sep 2016 13:44:29 +0200	[thread overview]
Message-ID: <1474890272-22952-4-git-send-email-pl@kamp.de> (raw)
In-Reply-To: <1474890272-22952-1-git-send-email-pl@kamp.de>

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 util/coroutine-ucontext.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
index 31254ab..6621f3f 100644
--- a/util/coroutine-ucontext.c
+++ b/util/coroutine-ucontext.c
@@ -34,6 +34,7 @@
 typedef struct {
     Coroutine base;
     void *stack;
+    size_t stack_size;
     sigjmp_buf env;
 
 #ifdef CONFIG_VALGRIND_H
@@ -82,7 +83,6 @@ static void coroutine_trampoline(int i0, int i1)
 
 Coroutine *qemu_coroutine_new(void)
 {
-    const size_t stack_size = COROUTINE_STACK_SIZE;
     CoroutineUContext *co;
     ucontext_t old_uc, uc;
     sigjmp_buf old_env;
@@ -101,17 +101,18 @@ Coroutine *qemu_coroutine_new(void)
     }
 
     co = g_malloc0(sizeof(*co));
-    co->stack = g_malloc(stack_size);
+    co->stack_size = COROUTINE_STACK_SIZE;
+    co->stack = qemu_alloc_stack(&co->stack_size);
     co->base.entry_arg = &old_env; /* stash away our jmp_buf */
 
     uc.uc_link = &old_uc;
     uc.uc_stack.ss_sp = co->stack;
-    uc.uc_stack.ss_size = stack_size;
+    uc.uc_stack.ss_size = co->stack_size;
     uc.uc_stack.ss_flags = 0;
 
 #ifdef CONFIG_VALGRIND_H
     co->valgrind_stack_id =
-        VALGRIND_STACK_REGISTER(co->stack, co->stack + stack_size);
+        VALGRIND_STACK_REGISTER(co->stack, co->stack + co->stack_size);
 #endif
 
     arg.p = co;
@@ -149,7 +150,7 @@ void qemu_coroutine_delete(Coroutine *co_)
     valgrind_stack_deregister(co);
 #endif
 
-    g_free(co->stack);
+    qemu_free_stack(co->stack, co->stack_size);
     g_free(co);
 }
 
-- 
1.9.1

  parent reply	other threads:[~2016-09-26 11:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 11:44 [Qemu-devel] [PATCH V8 0/6] coroutine: mmap stack memory and stack size Peter Lieven
2016-09-26 11:44 ` [Qemu-devel] [PATCH V8 1/6] oslib-posix: add helpers for stack alloc and free Peter Lieven
2016-09-26 13:44   ` Kevin Wolf
2016-09-26 14:43     ` Peter Lieven
2016-09-26 14:51       ` Kevin Wolf
2016-09-26 11:44 ` [Qemu-devel] [PATCH V8 2/6] coroutine: add a macro for the coroutine stack size Peter Lieven
2016-09-26 11:44 ` Peter Lieven [this message]
2016-09-26 11:44 ` [Qemu-devel] [PATCH V8 4/6] coroutine-sigaltstack: use helper for allocating stack memory Peter Lieven
2016-09-26 13:51   ` Kevin Wolf
2016-09-26 11:44 ` [Qemu-devel] [PATCH V8 5/6] oslib-posix: add a configure switch to debug stack usage Peter Lieven
2016-09-26 11:44 ` [Qemu-devel] [PATCH V8 6/6] coroutine: reduce stack size to 60kB Peter Lieven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474890272-22952-4-git-send-email-pl@kamp.de \
    --to=pl@kamp.de \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).