Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp995060pxf; Thu, 18 Mar 2021 17:24:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgujZZpSKBdRDY3KexjVb7+BMPBQdeb1Z3KOi5GiNDaxrhCAU0PHMjh0UzQ91DVYt1TWF0 X-Received: by 2002:aa7:dbd3:: with SMTP id v19mr6669557edt.314.1616113490323; Thu, 18 Mar 2021 17:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616113490; cv=none; d=google.com; s=arc-20160816; b=HVHIqDer+UWug2xLOSQTWEd2kJxOgl6BXB2GyrVtlSyNKdnxs40tbMpFW0+P5SwYFf hFoNpxSZ5Kl4DDcUWPMygVSjFZGOXo7HjH8rJljKl1IwayX5wjxe33Lf3ctVi5JkyUvW by/RAHv8nBROuJF6UckAo39sO23B8bbtGGVzvay4HMhbWmee/WtMutbXRBbVFicLmJEy ZLJ33AdTqmLibXwzez+5eNfFMdLhKzSe+FNFy36tDiaxKVKW3J5p078X00BiPyJvocVV gWFtiwQ58HaKTq0zDTD9OGgozmJ5YeOiJzJGemGJ3N3C4oY/q/kUns/gW+SSpagFir69 7Rkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:ironport-sdr:ironport-sdr; bh=az7RyZN16zzWhe7PBxGuBDoxrzZZyslbfrAa4MqKY7o=; b=r3ndR1ry2uGF72Ptjt0EQBQXh38r7mNrXhTYI90wziSia+DyWsEwHGgdAjj0/RhDY5 8S0uhihLE2fEhysczufqSOGPXbgqO64VX0KB7AT6EEHG3x8QRHBTI3XVkhoxYcwexx6Y MmJaGvRlsV5lbDUh1GNNqiq8TUiY0PdSxmcga61z798Utang4E1t+xBPSIbsc50W1efn D/BEMnN4cwaZQkLgHqvFFxCKXJtRSw1Yym+4VST0lqUC3HMvEt81QmuWv6zxf95RpGQ4 GPbxlrVzFdQWoPa+7w0peKcFa+lskUBsf049EMQVWS3FFHf7otLewHDW4u6e1wo16tvY HEZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si2694751edv.113.2021.03.18.17.24.28; Thu, 18 Mar 2021 17:24:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbhCSAUS (ORCPT + 99 others); Thu, 18 Mar 2021 20:20:18 -0400 Received: from mga06.intel.com ([134.134.136.31]:25096 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbhCSAUL (ORCPT ); Thu, 18 Mar 2021 20:20:11 -0400 IronPort-SDR: fOwYUAiQBwpd/DcfK0gWJ/Ua0a7bVQHLX5pHte1DaLaNPe2N/lHt6RXG+h0xMC2iqjJ8mV3On7 vFjX3C6yIoyw== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="251148952" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="251148952" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 17:20:10 -0700 IronPort-SDR: vm0vhQeTnExLKln4ENqx3VU3gCMCBEb+VB9rFh8sV4Mo/w2VhojiBHVFosZE2BZUKHctyGKo/S rjkWZc8chQHw== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="413299077" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 17:20:10 -0700 Date: Thu, 18 Mar 2021 17:22:34 -0700 From: Jacob Pan To: LKML , Joerg Roedel , "Lu Baolu" , David Woodhouse , iommu@lists.linux-foundation.org, cgroups@vger.kernel.org, Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker Cc: Alex Williamson , Eric Auger , Jason Gunthorpe , Jonathan Corbet , Raj Ashok , "Tian, Kevin" , Yi Liu , Wu Hao , Dave Jiang , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210318172234.3e8c34f7@jacob-builder> In-Reply-To: <1614463286-97618-6-git-send-email-jacob.jun.pan@linux.intel.com> 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> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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