All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Reiter <s.reiter@proxmox.com>
Cc: vsementsov@virtuozzo.com, slp@redhat.com,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	mreitz@redhat.com, stefanha@redhat.com, jsnow@redhat.com,
	dietmar@proxmox.com
Subject: Re: qemu_coroutine_yield switches thread?
Date: Thu, 16 Apr 2020 10:28:49 +0200	[thread overview]
Message-ID: <20200416082849.GA6014@linux.fritz.box> (raw)
In-Reply-To: <5dde1955-49db-2626-1fa5-332e4d7a0928@proxmox.com>

Am 16.04.2020 um 10:06 hat Stefan Reiter geschrieben:
> Hi list,
> 
> quick question: Can a resume from a qemu_coroutine_yield happen in a
> different thread?
> 
> Well, it can, since I'm seeing it happen, but is that okay or a bug?

Yes, it can happen. At least for devices like IDE where a request is
started during a vmexit (MMIO or I/O port write), the coroutine will
usually begin its life in the vcpu thread and then move to the main loop
thread.

This is not a problem because the vcpu thread holds the BQL while
running the request coroutine.

> I.e. in a backup-job the following can sporadically trip:
> 
>   unsigned long tid = pthread_self();
>   qemu_get_current_aio_context(); // returns main context
>   qemu_coroutine_yield();
>   qemu_get_current_aio_context(); // still returns main context, but:
>   assert(tid == pthread_self()); // this fails
> 
> It seems to be called from a vCPU thread when it happens. VM uses no
> iothreads.

This must be a guest request that was intercepted by the backup job. I
think it wouldn't happen for the background copy, these requests already
start in the main loop.

Kevin



  reply	other threads:[~2020-04-16  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16  8:06 qemu_coroutine_yield switches thread? Stefan Reiter
2020-04-16  8:28 ` Kevin Wolf [this message]
2020-04-16 10:09   ` Dietmar Maurer
2020-04-16 11:04     ` Kevin Wolf

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=20200416082849.GA6014@linux.fritz.box \
    --to=kwolf@redhat.com \
    --cc=dietmar@proxmox.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=s.reiter@proxmox.com \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.