qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] hotplug: VM got stuck when attaching a pass-through device


From: Zhanghaoyu (A)
Subject: [Qemu-devel] hotplug: VM got stuck when attaching a pass-through device to the non-pass-through VM for the first time
Date: Tue, 18 Feb 2014 02:38:40 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]