From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 1/1] KVM: Fix potentially recursively get kvm lock Date: Wed, 13 May 2009 10:14:19 -0300 Message-ID: <20090513131419.GA3976@amt.cnet> References: <200905121705.53176.sheng.yang@intel.com> <1242164187.4788.4.camel@2710p.home> <20090512220908.GA22626@amt.cnet> <200905131007.55189.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alex Williamson , Avi Kivity , "kvm@vger.kernel.org" To: "Yang, Sheng" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:33325 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760180AbZEMNOm (ORCPT ); Wed, 13 May 2009 09:14:42 -0400 Content-Disposition: inline In-Reply-To: <200905131007.55189.sheng.yang@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, May 13, 2009 at 10:07:54AM +0800, Yang, Sheng wrote: > > KVM: workaround workqueue / deassign_host_irq deadlock > > > > I think I'm running into the following deadlock in the kvm kernel module > > when trying to use device assignment: > > > > CPU A CPU B > > kvm_vm_ioctl_deassign_dev_irq() > > mutex_lock(&kvm->lock); worker_thread() > > -> kvm_deassign_irq() -> > > kvm_assigned_dev_interrupt_work_handler() > > -> deassign_host_irq() mutex_lock(&kvm->lock); > > -> cancel_work_sync() [blocked] > > > > Workaround the issue by dropping kvm->lock for cancel_work_sync(). > > > > Reported-by: Alex Williamson > > From: Sheng Yang > > Signed-off-by: Marcelo Tosatti > > Another calling path(kvm_free_all_assigned_devices()) don't hold kvm->lock... > Seems it need the lock for travel assigned dev list? Sheng, The task executing the deassign irq ioctl has a reference to the vm instance. This solution is just temporary though until the locks can be split and then dropping kvm->lock around cancel_work_sync will not be necessary anymore.