[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] hotplug: VM got stuck when attaching a pass-through dev
From: |
Michael S. Tsirkin |
Subject: |
Re: [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 12:38:28 +0200 |
On Tue, Feb 18, 2014 at 02:38:40AM +0000, Zhanghaoyu (A) wrote:
> 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
What if you detach and re-attach?
Is it fast then?
If yes this means the issue is COW breaking that occurs
with get_user_pages, not translation as such.
Try hugepages with prealloc - does it help?
--
MST