From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacob Pan Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Date: Thu, 18 Mar 2021 17:22:34 -0700 Message-ID: <20210318172234.3e8c34f7@jacob-builder> References: <1614463286-97618-1-git-send-email-jacob.jun.pan@linux.intel.com> <1614463286-97618-6-git-send-email-jacob.jun.pan@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1614463286-97618-6-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Sender: "iommu" To: LKML , Joerg Roedel , Lu Baolu , David Woodhouse , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker Cc: "Tian, Kevin" , Dave Jiang , Raj Ashok , Jonathan Corbet , Alex Williamson , Jason Gunthorpe , Wu Hao Hi Jean, Slightly off the title. As we are moving to use cgroup to limit PASID allocations, it would be much simpler if we enforce on the current task. However, iommu_sva_alloc_pasid() takes an mm_struct pointer as argument which implies it can be something other the the current task mm. So far all kernel callers use current task mm. Is there a use case for doing PASID allocation on behalf of another mm? If not, can we remove the mm argument? Thanks, Jacob > /** > * iommu_sva_alloc_pasid - Allocate a PASID for the mm > @@ -35,11 +44,11 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm, > ioasid_t min, ioasid_t max) mutex_lock(&iommu_sva_lock); > if (mm->pasid) { > if (mm->pasid >= min && mm->pasid <= max) > - ioasid_get(mm->pasid); > + ioasid_get(iommu_sva_pasid, mm->pasid); > else > ret = -EOVERFLOW; > } else { > - pasid = ioasid_alloc(&iommu_sva_pasid, min, max, mm); > + pasid = ioasid_alloc(iommu_sva_pasid, min, max, mm); > if (pasid == INVALID_IOASID) > ret = -ENOMEM; Thanks, Jacob