From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] coroutine: always use pooling
Date: Wed, 26 Sep 2012 17:18:29 +0200 [thread overview]
Message-ID: <50631CC5.5090504@redhat.com> (raw)
In-Reply-To: <CAFEAcA8=uonjFpLQx0ykx5AdBQw0ytbY2EwAy3p_XFX6PayzJQ@mail.gmail.com>
Il 26/09/2012 16:34, Peter Maydell ha scritto:
>> It makes sense to use it for other implementations than ucontext, too.
>> > Coroutine *qemu_coroutine_create(CoroutineEntry *entry)
>> > {
>> > - Coroutine *co = qemu_coroutine_new();
>> > + Coroutine *co;
>> > +
>> > + co = QSLIST_FIRST(&pool);
>> > + if (co) {
>> > + QSLIST_REMOVE_HEAD(&pool, pool_next);
>> > + pool_size--;
>> > + } else {
>> > + co = qemu_coroutine_new();
>> > + }
>> > co->entry = entry;
>> > return co;
>> > }
> Since this is obviously going to blow up badly if it's called
> from multiple threads, is there some kind of assert we can add
> so that we fail obviously if somebody makes that coding error?
> [the difficulty is probably when your backend is the gthread
> one, at least I assume creating a coroutine inside a coroutine
> is allowed.]
Yes, it is; however, creating a coroutine outside the big QEMU lock is
not allowed. Since one coroutine only runs at a time the code is safe,
just like the other global variables that are used in
qemu-coroutine-lock.c for example.
Paolo
prev parent reply other threads:[~2012-09-26 15:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 12:44 [Qemu-devel] [PATCH] coroutine: always use pooling Paolo Bonzini
2012-09-26 14:34 ` Peter Maydell
2012-09-26 15:18 ` Paolo Bonzini [this message]
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=50631CC5.5090504@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).