From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933520AbcKOPLg (ORCPT ); Tue, 15 Nov 2016 10:11:36 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:8706 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbcKOPLd (ORCPT ); Tue, 15 Nov 2016 10:11:33 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 14 Nov 2016 19:10:35 -0800 Subject: Re: [PATCH v12 11/22] vfio iommu: Add blocking notifier to notify DMA_UNMAP To: Alex Williamson References: <1479138156-28905-1-git-send-email-kwankhede@nvidia.com> <1479138156-28905-12-git-send-email-kwankhede@nvidia.com> <20161114165844.52537988@t450s.home> CC: , , , , , , , , X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: <2015af0a-cd66-8092-b075-10a1b434d35c@nvidia.com> Date: Tue, 15 Nov 2016 20:41:26 +0530 MIME-Version: 1.0 In-Reply-To: <20161114165844.52537988@t450s.home> X-Originating-IP: [10.24.216.210] X-ClientProxiedBy: DRHKMAIL103.nvidia.com (10.25.59.17) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> @@ -854,15 +857,29 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, >> if (dma->task->mm != current->mm) >> break; >> unmapped += dma->size; >> + >> + mutex_unlock(&iommu->lock); >> + if (iommu->external_domain && !RB_EMPTY_ROOT(&dma->pfn_list)) { >> + struct vfio_iommu_type1_dma_unmap nb_unmap; >> + >> + nb_unmap.iova = dma->iova; >> + nb_unmap.size = dma->size; >> + blocking_notifier_call_chain(&iommu->notifier, >> + VFIO_IOMMU_NOTIFY_DMA_UNMAP, >> + &nb_unmap); >> + >> + if (WARN_ON(!RB_EMPTY_ROOT(&dma->pfn_list))) >> + goto unmap_exit; >> + } >> + mutex_lock(&iommu->lock); > > Why are the mutexes pushed out so far, we are referencing way too much > stuff outside of the mutex here. The notifier head has its own > semaphore, so we should be able to squeeze the mutex opening to just > around the notifier call, in which case we only worry about the iommu > itself going way. > Right. Updating. Thanks, Kirti From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6fOb-0006GZ-Sc for qemu-devel@nongnu.org; Tue, 15 Nov 2016 10:11:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6fOY-0006cj-Mt for qemu-devel@nongnu.org; Tue, 15 Nov 2016 10:11:37 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:8712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6fOY-0006cV-Gl for qemu-devel@nongnu.org; Tue, 15 Nov 2016 10:11:34 -0500 References: <1479138156-28905-1-git-send-email-kwankhede@nvidia.com> <1479138156-28905-12-git-send-email-kwankhede@nvidia.com> <20161114165844.52537988@t450s.home> From: Kirti Wankhede Message-ID: <2015af0a-cd66-8092-b075-10a1b434d35c@nvidia.com> Date: Tue, 15 Nov 2016 20:41:26 +0530 MIME-Version: 1.0 In-Reply-To: <20161114165844.52537988@t450s.home> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v12 11/22] vfio iommu: Add blocking notifier to notify DMA_UNMAP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: pbonzini@redhat.com, kraxel@redhat.com, cjia@nvidia.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, kevin.tian@intel.com, jike.song@intel.com, bjsdjshi@linux.vnet.ibm.com, linux-kernel@vger.kernel.org >> @@ -854,15 +857,29 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, >> if (dma->task->mm != current->mm) >> break; >> unmapped += dma->size; >> + >> + mutex_unlock(&iommu->lock); >> + if (iommu->external_domain && !RB_EMPTY_ROOT(&dma->pfn_list)) { >> + struct vfio_iommu_type1_dma_unmap nb_unmap; >> + >> + nb_unmap.iova = dma->iova; >> + nb_unmap.size = dma->size; >> + blocking_notifier_call_chain(&iommu->notifier, >> + VFIO_IOMMU_NOTIFY_DMA_UNMAP, >> + &nb_unmap); >> + >> + if (WARN_ON(!RB_EMPTY_ROOT(&dma->pfn_list))) >> + goto unmap_exit; >> + } >> + mutex_lock(&iommu->lock); > > Why are the mutexes pushed out so far, we are referencing way too much > stuff outside of the mutex here. The notifier head has its own > semaphore, so we should be able to squeeze the mutex opening to just > around the notifier call, in which case we only worry about the iommu > itself going way. > Right. Updating. Thanks, Kirti