All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	KVM <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
	Gleb Natapov <gleb@redhat.com>,
	Avi Kivity <avi@cloudius-systems.com>,
	Eric Blake <eblake@redhat.com>,
	Luonengjun <luonengjun@huawei.com>,
	"Huangweidong (C)" <weidong.huang@huawei.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Gaowei (UVP)" <gao.gaowei@huawei.com>,
	"chenliang (T)" <chenliang88@huawei.com>
Subject: Re: 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	[thread overview]
Message-ID: <20140218103828.GB8114@redhat.com> (raw)
In-Reply-To: <D3E216785288A145B7BC975F83A2ED10448FC24D@SZXEMA510-MBS.china.huawei.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
Cc: "chenliang (T)" <chenliang88@huawei.com>,
	Avi Kivity <avi@cloudius-systems.com>,
	"Huangweidong (C)" <weidong.huang@huawei.com>,
	KVM <kvm@vger.kernel.org>, Gleb Natapov <gleb@redhat.com>,
	Luonengjun <luonengjun@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Gaowei (UVP)" <gao.gaowei@huawei.com>
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	[thread overview]
Message-ID: <20140218103828.GB8114@redhat.com> (raw)
In-Reply-To: <D3E216785288A145B7BC975F83A2ED10448FC24D@SZXEMA510-MBS.china.huawei.com>

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

  reply	other threads:[~2014-02-18 10:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18  2:38 hotplug: VM got stuck when attaching a pass-through device to the non-pass-through VM for the first time Zhanghaoyu (A)
2014-02-18  2:38 ` [Qemu-devel] " Zhanghaoyu (A)
2014-02-18 10:38 ` Michael S. Tsirkin [this message]
2014-02-18 10:38   ` Michael S. Tsirkin
2014-02-18 10:42   ` Paolo Bonzini
2014-02-18 10:42     ` [Qemu-devel] " Paolo Bonzini
2014-02-18 10:51     ` Michael S. Tsirkin
2014-02-18 10:51       ` [Qemu-devel] " Michael S. Tsirkin
2014-02-18 11:05       ` Paolo Bonzini
2014-02-18 11:05         ` [Qemu-devel] " Paolo Bonzini
2014-02-18 11:16         ` Michael S. Tsirkin
2014-02-18 11:16           ` [Qemu-devel] " Michael S. Tsirkin
2014-02-24 11:38         ` Zhanghaoyu (A)
2014-02-24 11:38           ` [Qemu-devel] " Zhanghaoyu (A)
2014-02-18 11:17     ` Zhanghaoyu (A)
2014-02-18 11:17       ` [Qemu-devel] " Zhanghaoyu (A)
2014-02-18 10:59   ` Zhanghaoyu (A)
2014-02-18 10:59     ` [Qemu-devel] " Zhanghaoyu (A)
  -- strict thread matches above, loose matches on Subject: below --
2014-02-18  2:03 Zhanghaoyu (A)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140218103828.GB8114@redhat.com \
    --to=mst@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=avi@cloudius-systems.com \
    --cc=chenliang88@huawei.com \
    --cc=eblake@redhat.com \
    --cc=gao.gaowei@huawei.com \
    --cc=gleb@redhat.com \
    --cc=haoyu.zhang@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=luonengjun@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weidong.huang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.