KVM irqfd and ioeventfd(十九)

In previous article vhost architecture we mentioned that vhost and the guest signal each other by irqfd and ioeventfd mechanism.

So let us see how irqfd and ioeventfd mechanism can take this role. We can find the patches in linus tree which implement them:

KVM irqfd support patch: http://git.kernel.org/linus/721eecbf4fe995ca94a9edec0c9843b1cc0eaaf3
KVM ioeventfd support patch: http://git.kernel.org/linus/d34e6b175e61821026893ec5298cc8e7558df43a

irqfd

irqfd is a mechanism to inject a specific interrupt to a guest using a decoupled eventfd mechanism: Any legal signal on the irqfd (using eventfd semantics from either userspace or kernel) will translate into an injected interrupt in the guest at the next interrupt window.

One line description is:

irqfd: Allows an fd to be used to inject an interrupt to the guest

Go into the patch, we can see details:

Hook the irq inject wakeup function to a wait queue, and the wait queue will be added by the eventfd polling callback.

ioeventfd

While ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd signal when written to by a guest. The purpose of this mechanism is to make guest notify host in a lightweight way. This is lightweight because it will not cause a VMX/SVM exit back to userspace, serviced by qemu then returning control back to the vcpu. Why we need this mechanism because this kind of heavy-weight IO sync mechanism is not necessary for the triggers, these triggers only want to transmit a notify asynchronously and return as quickly as possible. It is expansive for them to use the normal IO.

Look into the implementation, it accepts the eventfd and io address from args, then register a kvm_io_device with them. And the write operation of the registered kvm_io_device is sending an eventfd signal. The signal function is eventfd_siganl().

So, this mechanism is:

ioeventfd: Allow an fd to be used to receive a signal from the guest

conclusion

A very simple conclusion of these two mechanism can be the following picture:
在这里插入图片描述
After knowing what irqfd and ioeventfd are and how they are implemented, the next section may be how to use them, for example in vhost?

原文链接:http://blog.allenx.org/2015/07/05/kvm-irqfd-and-ioeventfd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值