* [QUESTION] About virtio and eventloop
@ 2023-01-16 8:18 zhukeqian via
2023-01-16 8:54 ` 答复: " zhukeqian via
2023-01-16 16:16 ` Stefan Hajnoczi
0 siblings, 2 replies; 4+ messages in thread
From: zhukeqian via @ 2023-01-16 8:18 UTC (permalink / raw)
To: Michael S. Tsirkin, Stefan Hajnoczi, Peter Maydell
Cc: qemu-devel@nongnu.org, Wubin (H), Chentao (Boby), Wanghaibin (D),
Zhangbo (Oscar), limingwang (A), Wangyan, lihuachao
[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]
Hi all maintainers and community friends,
Recently I am reviewing and learning the virtio and eventloop implementation of latest QEMU,
and now I have a questions for help:
In general, the IO requests of virtio is popped in iothread/mainloop and may submitted to "async IO
Engine" (io_uring/linux aio/threadpool). Once the IO operation is done, the "async IO engine" will send notification
to iothread/mainloop through evenfd or bottomhalf, and the completion action for the IO request (add used ring and
notify guest) is done in iothread/mainloop.
And let's look at the "deactive" procedure of virtio-pci devices (when guest write 0 to device status or system
triggered reset), the basic requirement is that device should stop handling IO requests and accessing virtqueue before
returning back to guest, as the guest may destroy virqueue once deactivation is done.
QEMU invokes stop_ioeventfd() callback to perform above actions. It unregisters ioeventfd from eventloop and KVM,
1. but I can't find code that ensuring IO operations in "async IO engine" are done.
2. And if IO operation is blocked, is vCPU thread will blocked when do deactivate?
It's great that if anyone can help!
Thanks,
Keqian
[-- Attachment #2: Type: text/html, Size: 14380 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* 答复: [QUESTION] About virtio and eventloop
2023-01-16 8:18 [QUESTION] About virtio and eventloop zhukeqian via
@ 2023-01-16 8:54 ` zhukeqian via
2023-01-16 16:16 ` Stefan Hajnoczi
1 sibling, 0 replies; 4+ messages in thread
From: zhukeqian via @ 2023-01-16 8:54 UTC (permalink / raw)
To: Michael S. Tsirkin, Stefan Hajnoczi, Peter Maydell
Cc: qemu-devel@nongnu.org, Wubin (H), Chentao (Boby), Wanghaibin (D),
Zhangbo (Oscar), limingwang (A), Wangyan, lihuachao
[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]
I found blk_drain() is invoked by virtio_blk_reset(), so only the second question remains :).
发件人: zhukeqian <>
发送时间: 2023年1月16日 16:18
收件人: 'Michael S. Tsirkin' <mst@redhat.com>; 'Stefan Hajnoczi' <stefanha@redhat.com>; 'Peter Maydell' <peter.maydell@linaro.org>
抄送: qemu-devel@nongnu.org; Wubin (H) <wu.wubin@huawei.com>; Chentao (Boby) <boby.chen@huawei.com>; Wanghaibin (D) <wanghaibin.wang@huawei.com>; Zhangbo (Oscar) <oscar.zhangbo@huawei.com>; limingwang (A) <limingwang@huawei.com>; Wangyan <wangyan122@huawei.com>; lihuachao <lihuachao1@huawei.com>
主题: [QUESTION] About virtio and eventloop
Hi all maintainers and community friends,
Recently I am reviewing and learning the virtio and eventloop implementation of latest QEMU,
and now I have a questions for help:
In general, the IO requests of virtio is popped in iothread/mainloop and may submitted to “async IO
Engine” (io_uring/linux aio/threadpool). Once the IO operation is done, the “async IO engine” will send notification
to iothread/mainloop through evenfd or bottomhalf, and the completion action for the IO request (add used ring and
notify guest) is done in iothread/mainloop.
And let’s look at the “deactive” procedure of virtio-pci devices (when guest write 0 to device status or system
triggered reset), the basic requirement is that device should stop handling IO requests and accessing virtqueue before
returning back to guest, as the guest may destroy virqueue once deactivation is done.
QEMU invokes stop_ioeventfd() callback to perform above actions. It unregisters ioeventfd from eventloop and KVM,
1. but I can’t find code that ensuring IO operations in “async IO engine” are done.
2. And if IO operation is blocked, is vCPU thread will blocked when do deactivate?
It’s great that if anyone can help!
Thanks,
Keqian
[-- Attachment #2: Type: text/html, Size: 8210 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [QUESTION] About virtio and eventloop
2023-01-16 8:18 [QUESTION] About virtio and eventloop zhukeqian via
2023-01-16 8:54 ` 答复: " zhukeqian via
@ 2023-01-16 16:16 ` Stefan Hajnoczi
2023-01-18 11:10 ` zhukeqian via
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2023-01-16 16:16 UTC (permalink / raw)
To: zhukeqian
Cc: Michael S. Tsirkin, Stefan Hajnoczi, Peter Maydell,
qemu-devel@nongnu.org, Wubin (H), Chentao (Boby), Wanghaibin (D),
Zhangbo (Oscar), limingwang (A), Wangyan, lihuachao
On Mon, 16 Jan 2023 at 03:20, zhukeqian via <qemu-devel@nongnu.org> wrote:
> And if IO operation is blocked, is vCPU thread will blocked when do deactivate?
Yes, blk_drain() is a synchronous function. It blocks until in-flight
I/O has finished. The vcpu thread will be blocked in
virtio_pci_common_write().
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [QUESTION] About virtio and eventloop
2023-01-16 16:16 ` Stefan Hajnoczi
@ 2023-01-18 11:10 ` zhukeqian via
0 siblings, 0 replies; 4+ messages in thread
From: zhukeqian via @ 2023-01-18 11:10 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: Michael S. Tsirkin, Stefan Hajnoczi, Peter Maydell, qemu-devel,
Wubin (H), Chentao (Boby), Wanghaibin (D), Zhangbo (Oscar),
limingwang (A), Wangyan, lihuachao
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
Hi Stefan, this indeed helps, thank you.
Keqian
On Mon, 16 Jan 2023 at 03:20, zhukeqian via <qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>> wrote:
> And if IO operation is blocked, is vCPU thread will blocked when do deactivate?
Yes, blk_drain() is a synchronous function. It blocks until in-flight
I/O has finished. The vcpu thread will be blocked in
virtio_pci_common_write().
Stefan
[-- Attachment #2: Type: text/html, Size: 1524 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-18 11:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 8:18 [QUESTION] About virtio and eventloop zhukeqian via
2023-01-16 8:54 ` 答复: " zhukeqian via
2023-01-16 16:16 ` Stefan Hajnoczi
2023-01-18 11:10 ` zhukeqian via
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).