[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: qemu_coroutine_yield switches thread?
From: |
Kevin Wolf |
Subject: |
Re: qemu_coroutine_yield switches thread? |
Date: |
Thu, 16 Apr 2020 10:28:49 +0200 |
User-agent: |
Mutt/1.12.1 (2019-06-15) |
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