qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: Kevin Wolf <kwolf@redhat.com>,
	gabriel@kerneis.info, qemu-devel@nongnu.org,
	qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] coroutine: add ./configure --disable-coroutine-pool
Date: Fri, 27 Sep 2013 11:11:07 +0200	[thread overview]
Message-ID: <20130927091107.GA9972@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <52451595.1000506@weilnetz.de>

On Fri, Sep 27, 2013 at 07:20:21AM +0200, Stefan Weil wrote:
> Am 11.09.2013 16:42, schrieb Stefan Hajnoczi:
> > The 'gthread' coroutine backend was written before the freelist (aka
> > pool) existed in qemu-coroutine.c.
> >
> > This means that every thread is expected to exit when its coroutine
> > terminates.  It is not possible to reuse threads from a pool.
> >
> > This patch automatically disables the pool when 'gthread' is used.  This
> > allows the 'gthread' backend to work again (for example,
> > tests/test-coroutine completes successfully instead of hanging).
> >
> > I considered implementing thread reuse but I don't want quirks like CPU
> > affinity differences due to coroutine threads being recycled.  The
> > 'gthread' backend is a reference backend and it's therefore okay to skip
> > the pool optimization.
> >
> > Note this patch also makes it easy to toggle the pool for benchmarking
> > purposes:
> >
> >   ./configure --with-coroutine-backend=ucontext \
> >               --disable-coroutine-pool
> >
> > Reported-by: Gabriel Kerneis <gabriel@kerneis.info>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  configure        | 24 ++++++++++++++++++++++++
> >  qemu-coroutine.c | 34 +++++++++++++++++++---------------
> >  2 files changed, 43 insertions(+), 15 deletions(-)
> >
> 
> This patch is important for QEMU 1.5 as well, but needs some
> modifications there.
> A recent bug report for MinGW shows that the win32 coroutine needs it, too.

coroutine-win32.c is designed to support reuse:

static void CALLBACK coroutine_trampoline(void *co_)
{
    Coroutine *co = co_;

    while (true) {
        co->entry(co->entry_arg);
        qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE);
    }
}

We return from qemu_coroutine_switch() when the fiber is reused and
simply run another iteration of the while loop.

Why do you say win32 coroutines should disable the pool?

Stefan

  reply	other threads:[~2013-09-27  9:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 14:42 [Qemu-devel] [PATCH] coroutine: add ./configure --disable-coroutine-pool Stefan Hajnoczi
2013-09-11 14:56 ` Gabriel Kerneis
2013-09-11 15:24 ` Kevin Wolf
2013-09-11 15:32   ` Gabriel Kerneis
2013-09-11 15:38     ` Kevin Wolf
2013-09-12  8:42       ` Stefan Hajnoczi
2013-09-27  5:20 ` Stefan Weil
2013-09-27  9:11   ` Stefan Hajnoczi [this message]
2013-09-27 16:49     ` Stefan Weil
2013-09-30  9:06       ` Stefan Hajnoczi
2013-10-01  5:51         ` Stefan Weil
2013-10-01  7:29           ` Gabriel Kerneis
2013-10-01 16:44             ` Stefan Weil
2013-10-02  8:54               ` Stefan Hajnoczi
2013-10-02 21:15                 ` Stefan Weil
2013-10-04  7:30                   ` Stefan Hajnoczi
2013-10-01  7:21         ` Paolo Bonzini

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=20130927091107.GA9972@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=gabriel@kerneis.info \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).