From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942943AbcJ0Oa1 (ORCPT ); Thu, 27 Oct 2016 10:30:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942804AbcJ0OaM (ORCPT ); Thu, 27 Oct 2016 10:30:12 -0400 Date: Thu, 27 Oct 2016 08:30:10 -0600 From: Alex Williamson To: Kirti Wankhede Cc: Alexey Kardashevskiy , , , , , , , , , Subject: Re: [Qemu-devel] [PATCH v9 04/12] vfio iommu: Add support for mediated devices Message-ID: <20161027083010.2d31e50e@t450s.home> In-Reply-To: References: <1476739332-4911-1-git-send-email-kwankhede@nvidia.com> <1476739332-4911-5-git-send-email-kwankhede@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 27 Oct 2016 14:30:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Oct 2016 18:01:51 +0530 Kirti Wankhede wrote: > On 10/27/2016 12:50 PM, Alexey Kardashevskiy wrote: > > On 18/10/16 08:22, Kirti Wankhede wrote: > >> VFIO IOMMU drivers are designed for the devices which are IOMMU capable. > >> Mediated device only uses IOMMU APIs, the underlying hardware can be > >> managed by an IOMMU domain. > >> > >> Aim of this change is: > >> - To use most of the code of TYPE1 IOMMU driver for mediated devices > >> - To support direct assigned device and mediated device in single module > >> > >> Added two new callback functions to struct vfio_iommu_driver_ops. Backend > >> IOMMU module that supports pining and unpinning pages for mdev devices > >> should provide these functions. > >> Added APIs for pining and unpining pages to VFIO module. These calls back > >> into backend iommu module to actually pin and unpin pages. > >> > >> This change adds pin and unpin support for mediated device to TYPE1 IOMMU > >> backend module. More details: > >> - When iommu_group of mediated devices is attached, task structure is > >> cached which is used later to pin pages and page accounting. > > > > > > For SPAPR TCE IOMMU driver, I ended up caching mm_struct with > > atomic_inc(&container->mm->mm_count) (patches are on the way) instead of > > using @current or task as the process might be gone while VFIO container is > > still alive and @mm might be needed to do proper cleanup; this might not be > > an issue with this patchset now but still you seem to only use @mm from > > task_struct. > > > > Consider the example of QEMU process which creates VFIO container, QEMU > in its teardown path would release the container. How could container be > alive when process is gone? If QEMU is sent a SIGKILL, does the process still exist? We must be able to perform cleanup regardless of the state, or existence, of the task that created it. Thanks, Alex From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH v9 04/12] vfio iommu: Add support for mediated devices Date: Thu, 27 Oct 2016 08:30:10 -0600 Message-ID: <20161027083010.2d31e50e@t450s.home> References: <1476739332-4911-1-git-send-email-kwankhede@nvidia.com> <1476739332-4911-5-git-send-email-kwankhede@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: jike.song@intel.com, cjia@nvidia.com, kvm@vger.kernel.org, Alexey Kardashevskiy , linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, kevin.tian@intel.com, kraxel@redhat.com, pbonzini@redhat.com, bjsdjshi@linux.vnet.ibm.com To: Kirti Wankhede Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org On Thu, 27 Oct 2016 18:01:51 +0530 Kirti Wankhede wrote: > On 10/27/2016 12:50 PM, Alexey Kardashevskiy wrote: > > On 18/10/16 08:22, Kirti Wankhede wrote: > >> VFIO IOMMU drivers are designed for the devices which are IOMMU capable. > >> Mediated device only uses IOMMU APIs, the underlying hardware can be > >> managed by an IOMMU domain. > >> > >> Aim of this change is: > >> - To use most of the code of TYPE1 IOMMU driver for mediated devices > >> - To support direct assigned device and mediated device in single module > >> > >> Added two new callback functions to struct vfio_iommu_driver_ops. Backend > >> IOMMU module that supports pining and unpinning pages for mdev devices > >> should provide these functions. > >> Added APIs for pining and unpining pages to VFIO module. These calls back > >> into backend iommu module to actually pin and unpin pages. > >> > >> This change adds pin and unpin support for mediated device to TYPE1 IOMMU > >> backend module. More details: > >> - When iommu_group of mediated devices is attached, task structure is > >> cached which is used later to pin pages and page accounting. > > > > > > For SPAPR TCE IOMMU driver, I ended up caching mm_struct with > > atomic_inc(&container->mm->mm_count) (patches are on the way) instead of > > using @current or task as the process might be gone while VFIO container is > > still alive and @mm might be needed to do proper cleanup; this might not be > > an issue with this patchset now but still you seem to only use @mm from > > task_struct. > > > > Consider the example of QEMU process which creates VFIO container, QEMU > in its teardown path would release the container. How could container be > alive when process is gone? If QEMU is sent a SIGKILL, does the process still exist? We must be able to perform cleanup regardless of the state, or existence, of the task that created it. Thanks, Alex From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzlhB-0007Kq-GK for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:30:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzlh6-0000SS-GG for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:30:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzlh6-0000Re-B5 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:30:12 -0400 Date: Thu, 27 Oct 2016 08:30:10 -0600 From: Alex Williamson Message-ID: <20161027083010.2d31e50e@t450s.home> In-Reply-To: References: <1476739332-4911-1-git-send-email-kwankhede@nvidia.com> <1476739332-4911-5-git-send-email-kwankhede@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v9 04/12] vfio iommu: Add support for mediated devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirti Wankhede Cc: Alexey Kardashevskiy , pbonzini@redhat.com, kraxel@redhat.com, cjia@nvidia.com, jike.song@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.tian@intel.com, qemu-devel@nongnu.org, bjsdjshi@linux.vnet.ibm.com On Thu, 27 Oct 2016 18:01:51 +0530 Kirti Wankhede wrote: > On 10/27/2016 12:50 PM, Alexey Kardashevskiy wrote: > > On 18/10/16 08:22, Kirti Wankhede wrote: > >> VFIO IOMMU drivers are designed for the devices which are IOMMU capable. > >> Mediated device only uses IOMMU APIs, the underlying hardware can be > >> managed by an IOMMU domain. > >> > >> Aim of this change is: > >> - To use most of the code of TYPE1 IOMMU driver for mediated devices > >> - To support direct assigned device and mediated device in single module > >> > >> Added two new callback functions to struct vfio_iommu_driver_ops. Backend > >> IOMMU module that supports pining and unpinning pages for mdev devices > >> should provide these functions. > >> Added APIs for pining and unpining pages to VFIO module. These calls back > >> into backend iommu module to actually pin and unpin pages. > >> > >> This change adds pin and unpin support for mediated device to TYPE1 IOMMU > >> backend module. More details: > >> - When iommu_group of mediated devices is attached, task structure is > >> cached which is used later to pin pages and page accounting. > > > > > > For SPAPR TCE IOMMU driver, I ended up caching mm_struct with > > atomic_inc(&container->mm->mm_count) (patches are on the way) instead of > > using @current or task as the process might be gone while VFIO container is > > still alive and @mm might be needed to do proper cleanup; this might not be > > an issue with this patchset now but still you seem to only use @mm from > > task_struct. > > > > Consider the example of QEMU process which creates VFIO container, QEMU > in its teardown path would release the container. How could container be > alive when process is gone? If QEMU is sent a SIGKILL, does the process still exist? We must be able to perform cleanup regardless of the state, or existence, of the task that created it. Thanks, Alex