Some thoughts about per-queue iothreads in VirtIOBlock
Hi!
Recently, I have started working on the real multi-queue implementation for the VirtIOBlock device and came to conclusion that for the time being it may work only with RAW images. The reason is obviously lack of the true thread-safe multi-queue block layer, but recently I have seen the following message from Stefan
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg04791.html
It appears like Paolo has already started implementing this feature, so I wonder whether the work is abandoned or not, and could anyone point me out to any of those patches? As I understood from Stefan description, it is expected to change significantly the approach we use to interact with BlockDriverState.
Thanks,
Edgar
Quoted 8 lines · Edgar Kaziakhmedov
Hi!
Recently, I have started working on the real multi-queue implementation for the VirtIOBlock device and came to conclusion
that for the time being it may work only with RAW images. The reason is obviously lack of the true thread-safe multi-queue block layer, but recently I have seen the following message from Stefan
Quoted 5 lines
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg04791.html
It appears like Paolo has already started implementing this feature, so I wonder whether the work is abandoned or not, and
could anyone point me out to any of those patches
I have almost finished getting rid of the AioContext lock (aio_context_acquire and aio_context_release), which is the final step of thread-safety and a prerequisite for multiqueue. Unfortunately it's stalled a bit due to all the Meltdown and Spectre mess, which yes is still going on after some months. :(
Quoted 3 lines
As I understood from
Stefan description, it is expected to change significantly the approach we use to interact with BlockDriverState.
I don't think the change is very large actually, at least for on-disk devices. I haven't yet considered network devices such as libiscsi or ceph.
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Edgar Kaziakhmedov
As I understood from
Stefan description, it is expected to change significantly the approach we use to interact with BlockDriverState.I don't think the change is very large actually, at least for on-disk devices. I haven't yet considered network devices such as libiscsi or ceph.
Well, in that case, I will keep working on per-queue iothreads with an existing interface.
I asked because it might be reasonable to create BlockBackend device for each queue context and use them independently to avoid some additional locks and synchronization. On the other hand, it can lead to multiple opening of the same image, but as I said it doesn't seem to be a problem for the simplest formats such as raw.
Quoted 4 lines
Paolo
.
Quoted 10 lines · Edgar Kaziakhmedov
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Edgar Kaziakhmedov
As I understood from
Stefan description, it is expected to change significantly the approach we use to interact with BlockDriverState.I don't think the change is very large actually, at least for on-disk devices. I haven't yet considered network devices such as libiscsi or ceph.
Quoted 8 lines
Well, in that case, I will keep working on per-queue iothreads with an existing interface.
I asked because it might be reasonable to create BlockBackend device for each queue context and
use them independently to avoid some additional locks and synchronization. On the other hand, it can lead to multiple
opening of the same image, but as I said it doesn't seem to be a problem for the simplest formats such as raw.
The special case for raw approach is not suitable for upstream QEMU. It's what we started with in -device virtio-blk,x-data-plane=on (see the old dataplane implementation in QEMU v1.4).
It took a lot of work to make the IOThread use the QEMU block layer instead of a special case code path for raw.
Currently QEMU is not that far away from being able to use BlockDriverState from multiple threads for multiqueue.
Paolo, can you share your current progress and pointers to what needs to be done next? Maybe Edgar can help complete the work.
Stefan
Quoted 17 lines · Stefan Hajnoczi
Quoted 8 lines · Edgar Kaziakhmedov
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Edgar Kaziakhmedov
As I understood from
Stefan description, it is expected to change significantly the approach we use to interact with BlockDriverState.I don't think the change is very large actually, at least for on-disk devices. I haven't yet considered network devices such as libiscsi or ceph.
Quoted 8 lines
Well, in that case, I will keep working on per-queue iothreads with an existing interface.
I asked because it might be reasonable to create BlockBackend device for each queue context and
use them independently to avoid some additional locks and synchronization. On the other hand, it can lead to multiple
opening of the same image, but as I said it doesn't seem to be a problem for the simplest formats such as raw.
Quoted 3 lines
The special case for raw approach is not suitable for upstream QEMU. It's what we started with in -device virtio-blk,x-data-plane=on (see the old dataplane implementation in QEMU v1.4).
Yes, definitely. I went through the whole development path and analyzed all your patches. Moreover, it is clear that this approach is not suitable for the upstream, but I am considering it like the first step toward per-queue iothread implementation, for now the work seems to be almost done, may be it might take one more week to refine and debug.
Quoted 11 lines
It took a lot of work to make the IOThread use the QEMU block layer instead of a special case code path for raw.
Currently QEMU is not that far away from being able to use BlockDriverState from multiple threads for multiqueue.
Paolo, can you share your current progress and pointers to what needs to be done next? Maybe Edgar can help complete the work.
Stefan