Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp255723pxf; Thu, 25 Mar 2021 03:25:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ryep6iGCoAJp94SrQargm43kJxNaqYagbOCaZlq9LYPHDfrDPENhv04CZbXGpiTnmJts X-Received: by 2002:a05:6402:1d39:: with SMTP id dh25mr8485448edb.282.1616667959525; Thu, 25 Mar 2021 03:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616667959; cv=none; d=google.com; s=arc-20160816; b=jMv5o6zObPWa9zS8snG8umM3AABXqKREdA0my2wKB0Xun1ri0xcFxlyVBhLWLcTqBI BTw91C3SuRfxWBmawUnz3twN4OlDoWL7Ok/iXnaJ2Cmyd0W8WS7nr5ykEWfpYTIzbrkO nEb2GQ8vdlnevDE4tys3Vhus+cSVyQ9aUC3kJJJZYTK36BFsJ+eNlzmGaAj5ku429JC7 nmIw8kcThLigU0e0i/sJeBfsml8g1KyHX+OINUwFgOUd3LqKVjHBb1ptcXIiF/jBO33y QCOR01wKIgYpezyQN68K3YOq4uln5k7b1vv/X7EEEgz5y4W/s9RLBBmpcilDS39Ab59H gIXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2bl+T//9tmIfvggnKu8W5/72RtiA3Lc/gNcBZ4TaNT0=; b=Er3mc29wGyjEWUYaLEzZl1fPL+f7MbC0UWs0DmN/Dk3F+sAEakDUD/VCGoBtuCLrAA mdSHiP5Tl2egvKnl8hsXklSUlSHFnQ2HXNZ2918uCv0ZSdrrWUx1j8qvzGMjbkkoL99z ei0tbJRYYoQDX2m0y3+SME9A2Uf5PlgS6TThebJ/Iz8ZOjwoXRvUjb1zjff1ipz0W4S+ ivcqBK3Vcx8tKYRm8qpqyAjo+hT8fkTTxqF+XjnhvCV0fHmM5e4I232xEWwtYIX+zLUX Wv0CC1POWU/zU7D2d9uGfFL9CHVuWPlrpZGe/h7HJ8JpAigZxeHv0O93JG/K38u0SI8A 894w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDBMmQHj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rp14si4053824ejb.435.2021.03.25.03.25.36; Thu, 25 Mar 2021 03:25:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=HDBMmQHj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbhCYKWC (ORCPT + 99 others); Thu, 25 Mar 2021 06:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbhCYKWA (ORCPT ); Thu, 25 Mar 2021 06:22:00 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF231C06174A for ; Thu, 25 Mar 2021 03:21:59 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v4so1667346wrp.13 for ; Thu, 25 Mar 2021 03:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2bl+T//9tmIfvggnKu8W5/72RtiA3Lc/gNcBZ4TaNT0=; b=HDBMmQHjxhDfBDa8NUpbssXQOf02VdhzwNOvL6z/sjlS/ob6nTDjDFdk7Rx19nR1hs SQS1m7CNqJDQUJQrPvFOlRsKplOR4HvnzIgwuwJzay62ap35JEwN/qhpACoPzMAWxfWI XO4MYnlDxfTay5ZNPPLBaE8XvkwnoB0y15l1GoemjCgivvxfYqd4SqDye10bL/U1sDgq 2q58EeYToO3fsZktwBu5V51IOdt2ibMB1IaBNKKSb4cr+C+as3JCUfzbgdL92Xba3w9V ql45gXFLeCm10iNBjvSTa/BEbpZQtQ6N4qHGai0lWRLpSVaztsL2TRhlDZbX05OJR9Pk EKxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2bl+T//9tmIfvggnKu8W5/72RtiA3Lc/gNcBZ4TaNT0=; b=BUQ6U3ciYZ331+I4eM5mHCFbzP0/vsPCEsbGtsTQpDfPuYQWAJv35524PUgB0fdnTN hEFiC0aMUUTU7exV0kucss56aj0b5OIIj2TA9doXoEoNwLHzx/21G1vJWs55RT89goWb 24N1rKeG7Dcz2FL3YFU4jiGF3SDiuIgseu0ReXxYlB1DY8JNDXUI2f0K2tP4Iht7Ru7n MayKARTBOwBLW8bYBG7EloqYt8Hql1s4+npq7+7zMvYWYos3G6mMl0qSCZUnpThQfcal D9GcVzTzYc/APKEGs33h8gfbzELOLmWgwRXBu1pTIr1SdXtFEBkJw7XGNiImJNsO+8FE fHcg== X-Gm-Message-State: AOAM531/mRwrPa+qFaOg2Qy8m1z/6z2RDWuPKGEO1TrCIBQ8jYngk4im iJzsn4EhDBxifryo2Rarv8jmSA== X-Received: by 2002:a05:6000:12c5:: with SMTP id l5mr7958343wrx.208.1616667718538; Thu, 25 Mar 2021 03:21:58 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id g15sm5458756wmq.31.2021.03.25.03.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 03:21:58 -0700 (PDT) Date: Thu, 25 Mar 2021 11:21:40 +0100 From: Jean-Philippe Brucker To: Jacob Pan Cc: Jason Gunthorpe , 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 Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: References: <20210318172234.3e8c34f7@jacob-builder> <20210319124645.GP2356281@nvidia.com> <20210319135432.GT2356281@nvidia.com> <20210319112221.5123b984@jacob-builder> <20210324100246.4e6b8aa1@jacob-builder> <20210324170338.GM2356281@nvidia.com> <20210324151230.466fd47a@jacob-builder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210324151230.466fd47a@jacob-builder> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 24, 2021 at 03:12:30PM -0700, Jacob Pan wrote: > 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; > } Does that allow PASID allocation during driver probe, in kernel_init or modprobe context? Thanks, Jean