Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp46563pxf; Wed, 24 Mar 2021 20:31:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7rUU35DN4nnN4mLXYUbcWqD2NkGAAiioe2GuMRQlCQ2TWeWunt035q6SAez90bGswiL0Y X-Received: by 2002:a05:6402:2744:: with SMTP id z4mr6802812edd.347.1616643076211; Wed, 24 Mar 2021 20:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643076; cv=none; d=google.com; s=arc-20160816; b=xV56ciVF1SuH80kkvbJSsffUjlSy4BamURRO9+s1456GoPOmEvr4WocLn47uFG0C/d hAhA62mstqFCLcWYfpKxWEi6cPO21r4TUUwuE1aaTDDF9F5/6/MxfOZ8tob3rwO58aN1 lq2OvsrNz0yR5kNGh85B19w09lqeUnKOEqht8zIsUIKGB+gZAzDURouTaS0SSr5WBE/N WhscFjXRLFmbO24mATo6s4pLO6TT8Ogw7J5NueSjD2mahRTrAiwhG9Dgtz+0jo5Ii/Ee 518efVjbDHs4jLhPoPLO/yv6ZKlCwOd9U9kDOQflhs7tphzyuCLGwqcYA+A3+QL+iUR+ xLzA== 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=cctSm86LUD/4zb/D7zldrB5oSfRvMb63koTYF4cVn98=; b=Liv7JI9CDW9tKItmCzIkIpc4y1DDmDYZUlJiF7FEEOyxQGTyfuzDoMsxw+c9xmyNfq Dtcpc8tXr5Vjg16E7ytOx/u0MOZtA7tSUQqOvqcPvbChhmrxIt9l0BvfwdbWihvHC2gr 4berGE74Gv0BakxeUQuYpv66H8FI99XTSnprVJxX3nUBxq78lQNhKtbsHSjs9qA1sNCY LLOVJU/v34Dz5FwtnU/eE75ZIyq3Pm6Y0WB0pximBKehrIUm/ZWd9g1PtafOfxvTjHg2 9mqRJOk7V2jQLZpPfPHNnITOtaQlJ1R9U1Q7SvHtvaHN1fW8J8Q10lKbSEDImbWc0DSi L7PA== 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 k4si2980522edq.442.2021.03.24.20.30.53; Wed, 24 Mar 2021 20:31:16 -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 S238716AbhCXWKQ (ORCPT + 99 others); Wed, 24 Mar 2021 18:10:16 -0400 Received: from mga18.intel.com ([134.134.136.126]:35225 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbhCXWKF (ORCPT ); Wed, 24 Mar 2021 18:10:05 -0400 IronPort-SDR: 9zxKobfwZxPI+CPFirI8c+VdQGflbVDgBZjm7+dtgAfGNEpqMOGjZXF57LYkCAdi+BiXLTYFS/ HMUQYqGXJW2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9933"; a="178348424" X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="178348424" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 15:10:03 -0700 IronPort-SDR: DQZSaLihhzL2eMMuOF5/+Gq/kYGub32TVjHTLJr/fySOgtaPJemHSPHFCx7OFGJFZBYCPKhCq1 tkpDOzoJ4dTA== X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="413927681" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 15:10:03 -0700 Date: Wed, 24 Mar 2021 15:12:30 -0700 From: Jacob Pan To: Jason Gunthorpe Cc: Jean-Philippe Brucker , 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 , Alex Williamson , Eric Auger , 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: <20210324151230.466fd47a@jacob-builder> In-Reply-To: <20210324170338.GM2356281@nvidia.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> <20210318172234.3e8c34f7@jacob-builder> <20210319124645.GP2356281@nvidia.com> <20210319135432.GT2356281@nvidia.com> <20210319112221.5123b984@jacob-builder> <20210324100246.4e6b8aa1@jacob-builder> <20210324170338.GM2356281@nvidia.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 Jason, On Wed, 24 Mar 2021 14:03:38 -0300, Jason Gunthorpe wrote: > On Wed, Mar 24, 2021 at 10:02:46AM -0700, Jacob Pan wrote: > > > Also wondering about device driver allocating auxiliary domains for > > > their private use, to do iommu_map/unmap on private PASIDs (a clean > > > replacement to super SVA, for example). Would that go through the > > > same path as /dev/ioasid and use the cgroup of current task? > > > > For the in-kernel private use, I don't think we should restrict based on > > cgroup, since there is no affinity to user processes. I also think the > > PASID allocation should just use kernel API instead of /dev/ioasid. Why > > would user space need to know the actual PASID # for device private > > domains? Maybe I missed your idea? > > There is not much in the kernel that isn't triggered by a process, I > would be careful about the idea that there is a class of users that > can consume a cgroup controlled resource without being inside the > cgroup. > > We've got into trouble before overlooking this and with something > greenfield like PASID it would be best built in to the API to prevent > a mistake. eg accepting a cgroup or process input to the allocator. > Make sense. But I think we only allow charging the current cgroup, how about I add the following to ioasid_alloc(): misc_cg = get_current_misc_cg(); ret = misc_cg_try_charge(MISC_CG_RES_IOASID, misc_cg, 1); if (ret) { put_misc_cg(misc_cg); return ret; } BTW, IOASID will be one of the resources under the proposed misc cgroup. Thanks, Jacob