qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, famz@redhat.com,
	qemu-block@nongnu.org, mreitz@redhat.com, stefanha@redhat.com,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 2/5] coroutine: abort if we try to enter coroutine scheduled for another ctx
Date: Mon, 20 Nov 2017 08:42:40 -0500	[thread overview]
Message-ID: <20171120134240.GH5399@localhost.localdomain> (raw)
In-Reply-To: <20171120112826.GC4516@stefanha-x1.localdomain>

On Mon, Nov 20, 2017 at 11:28:26AM +0000, Stefan Hajnoczi wrote:
> On Sun, Nov 19, 2017 at 09:46:43PM -0500, Jeff Cody wrote:
> > diff --git a/include/qemu/coroutine_int.h b/include/qemu/coroutine_int.h
> > index cb98892..931cdc9 100644
> > --- a/include/qemu/coroutine_int.h
> > +++ b/include/qemu/coroutine_int.h
> > @@ -53,6 +53,9 @@ struct Coroutine {
> >  
> >      /* Only used when the coroutine has yielded.  */
> >      AioContext *ctx;
> > +
> > +    int scheduled;
> 
> s/int/bool/
> 

OK.

> > diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
> > index d6095c1..2edab63 100644
> > --- a/util/qemu-coroutine.c
> > +++ b/util/qemu-coroutine.c
> > @@ -109,6 +109,15 @@ void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co)
> >  
> >      trace_qemu_aio_coroutine_enter(ctx, self, co, co->entry_arg);
> >  
> > +    /* if the Coroutine has already been scheduled, entering it again will
> > +     * cause us to enter it twice, potentially even after the coroutine has
> > +     * been deleted */
> > +    if (co->scheduled == 1) {
> > +        fprintf(stderr, "Cannot enter a co-routine that has already "
> > +                        "been scheduled to run in a different AioContext\n");
> 
> This error message is too specific, the AioContext doesn't have to be
> different from the current one:
> 
> block/blkdebug.c:        aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self());
> 
> If something calls qemu_aio_coroutine_enter() on the coroutine it might
> be from the same AioContext - but still an error condition worth failing
> loudly on.
> 

Good point.


> I suggest simplifying the error message:
> 
>   fprintf(stderr, "Cannot enter a co-routine that has already "
>                   "been scheduled\n");

OK. I'll also change the wording here to what you have above, as well:

  void aio_co_schedule(AioContext *ctx, Coroutine *co)
  {
       trace_aio_co_schedule(ctx, co);
  +    if (co->scheduled == 1) {
  +        fprintf(stderr,
  +                "Cannot schedule a co-routine that is already scheduled\n");
  +        abort();
  +    }
  +    co->scheduled = 1;
       QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines,
                                 co, co_scheduled_next);


Jeff

  reply	other threads:[~2017-11-20 13:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20  2:46 [Qemu-devel] [PATCH 0/5] Fix segfault in blockjob race condition Jeff Cody
2017-11-20  2:46 ` [Qemu-devel] [PATCH 1/5] blockjob: do not allow coroutine double entry or entry-after-completion Jeff Cody
2017-11-20 11:16   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-11-20 13:36     ` Jeff Cody
2017-11-21 10:47       ` Stefan Hajnoczi
2017-11-20 22:25     ` Paolo Bonzini
2017-11-21 12:42       ` Kevin Wolf
2017-11-20  2:46 ` [Qemu-devel] [PATCH 2/5] coroutine: abort if we try to enter coroutine scheduled for another ctx Jeff Cody
2017-11-20 11:28   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-11-20 13:42     ` Jeff Cody [this message]
2017-11-20  2:46 ` [Qemu-devel] [PATCH 3/5] coroutines: abort if we try to enter a still-sleeping coroutine Jeff Cody
2017-11-20 11:43   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-11-20 13:45     ` Jeff Cody
2017-11-21 10:17       ` Stefan Hajnoczi
2017-11-20 22:30   ` [Qemu-devel] " Paolo Bonzini
2017-11-20 22:35     ` Jeff Cody
2017-11-20 22:47       ` Paolo Bonzini
2017-11-20 23:08         ` Jeff Cody
2017-11-20 23:13           ` Paolo Bonzini
2017-11-20 23:31             ` Jeff Cody
2017-11-20  2:46 ` [Qemu-devel] [PATCH 4/5] qemu-iotests: add option in common.qemu for mismatch only Jeff Cody
2017-11-20  2:46 ` [Qemu-devel] [PATCH 5/5] qemu-iotest: add test for blockjob coroutine race condition Jeff Cody

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=20171120134240.GH5399@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.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).