hotplug: VM got stuck when attaching a pass-through device to the non-pass-through VM for the first time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, all

The VM will get stuck for a while(about 6s for a VM with 20GB memory) when attaching a pass-through PCI card to the non-pass-through VM for the first time. 
The reason is that the host will build the whole VT-d GPA->HPA DMAR page-table, which needs a lot of time, and during this time, the qemu_global_mutex
lock is hold by the main-thread, if the vcpu thread IOCTL return, it will be blocked to waiting main-thread to release the qemu_global_mutex lock,
so the VM got stuck.
The race between qemu-main-thread and vcpu-thread is shown as below,

              QEMU-main-thread                                vcpu-thread           
                     |                                             |
      qemu_mutex_lock_iothread                     qemu_mutex_lock(&qemu_global_mutex)
                     |                                             |
        +----loop- ->+                               +----loop---->+               
        |            |                               |             |
        |  qemu_mutex_unlock_iothread                | qemu_mutex_unlock_iothread 
        |            |                               |             |              
        |           poll                             |    kvm_vcpu_ioctl(KVM_RUN) 
        |            |                               |             |              
        | qemu_mutex_lock_iothread                   |             |
        |            |                               |             | 
 --------------------------------------------------------------------------------------
        |            |                               |  qemu_mutex_lock_iothread
        |   kvm_device_pci_assign                    |             |              
        |            |                               |   blocked to waiting main-thread to release the qemu lock
        |      about 6 sec for 20GB memory           |             |              
        |            |                               |             |                     
        +------------+                               +-------------+              


Any advises?

Thanks,
Zhang Haoyu

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux