I searched "vector_irqfd" globally, no place found to set/change irqfd's msi message, only irqfd's virq or users member may be changed in kvm_virtio_pci_vq_vector_use, kvm_virtio_pci_vq_vector_release, etc. So I think it's meaningless to do below check in virtio_pci_vq_vector_unmask, if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address)
And, I think the comparison between old msi message and new msi messge should be performed in kvm_update_routing_entry, the raw patch shown as below, Signed-off-by: Zhang Haoyu <haoyu.zh...@huawei.com> Signed-off-by: Zhang Huanzhong <zhanghuanzh...@huawei.com> --- hw/virtio/virtio-pci.c | 8 +++----- kvm-all.c | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b070b64..e4829a3 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -613,11 +613,9 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy, if (proxy->vector_irqfd) { irqfd = &proxy->vector_irqfd[vector]; - if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address) { - ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg); - if (ret < 0) { - return ret; - } + ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg); + if (ret < 0) { + return ret; } } diff --git a/kvm-all.c b/kvm-all.c index e6b262f..63a33b4 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1034,6 +1034,11 @@ static int kvm_update_routing_entry(KVMState *s, continue; } + if (entry->type == new_entry->type && + entry->flags == new_entry->flags && + !memcmp(&entry->u, &new_entry->u, sizeof(entry->u))) { + return 0; + } entry->type = new_entry->type; entry->flags = new_entry->flags; entry->u = new_entry->u; -- 1.7.3.1.msysgit.0 This patch works for both virtio-pci device and pci-passthrough device. MST and I had been discussed this patch before, this patch can avoid meaninglessly updating the routing entry in kvm hypervisor when new msi message is identical with old msi message, especially in some cases, for example, frequently mask/unmask per-vector masking control bit in ISR on some old linux guest(e.g., rhel-5.5), which gains much. At MST's request, the number will be provided later. Thanks, Zhang Haoyu