Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2976557pxj; Mon, 10 May 2021 15:28:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBGQHt5rx0BgpBhaYTzt35QUaISD3wek4J/mSH8oTw6Ubq5VylOllQD0UG8qbaj48A8io4 X-Received: by 2002:a17:906:e08c:: with SMTP id gh12mr28883922ejb.115.1620685686282; Mon, 10 May 2021 15:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620685686; cv=none; d=google.com; s=arc-20160816; b=w/SBhMN6INrcYaT1gHpNHHeh3eknN4CCDlMCPbunw8BbDyuhgdEXdsfeqgl4n/pRI1 9NS/r4ZP06WImUnCat+m7MxQizt+dLtCH+6iaOYsMxafmPv8EXEHhoHfLTlFJAP4zjU0 KAOCh5l/fmPtAHsxuSSd/wmXzCiMj1yJCNir8aAdrd0XwqB97MORHw6fRLkg9IBaHuK5 1nHZGDG5uVriHuwM+NX9/UkDxBqNhFrqD6UfS5uOfWpc/NiB7zCW9r6VKUe+P+LWLEeI wgKWjMk5DrvPr6w6kP6BUvUMCh/UNaffnxi7AOhwhbv6XQpi5N62RHtji7rzBruNh08L U8Vw== 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=DCpZDxdDJfJWWm/b46GibWVb0HTCRwN2hf3syLopAW4=; b=wTPt+S19I9FPxV5t1bnmDbPCumrOL8kZLCg1BaqqdrIJM0y+YjnnRfqucOdEMs1ttI gTnObWu3/SLy+jz9eeOwSeimDkgS8j8KaHkK2r+ywad7C3jXcoRc0KqUE+VwDcIrOxgS z0j8UKnMgLwJqTiQycK3XIu7EHyBICxxMtLAYEep3AJ5NCjhQ2rvmVEIPP9I1LRWogh5 0t0b4o4jY2jAl7H+1gEouSCazmC/9xAn/azUxxMoRiYWWkDlKjlJfZcyvM0P0ViZr2zP 2Lxpf8l+xl838tbw9PfMRgQedI3imMdShfx8ym4aR+LMC2WKZ4yErDOSkXySra0dRiwp ap7Q== 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 kb26si14639584ejc.352.2021.05.10.15.27.42; Mon, 10 May 2021 15:28:06 -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 S231376AbhEJW1r (ORCPT + 99 others); Mon, 10 May 2021 18:27:47 -0400 Received: from mga09.intel.com ([134.134.136.24]:65501 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231368AbhEJW1f (ORCPT ); Mon, 10 May 2021 18:27:35 -0400 IronPort-SDR: ACj4mbbfIcAwS4u1dCJGNoEOCL41bCs1O8kcJy1hngtYf7Q95vMzHM5U2u07QRsooR43Xi0zQB lj8bM/YwYZ9w== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="199370758" X-IronPort-AV: E=Sophos;i="5.82,288,1613462400"; d="scan'208";a="199370758" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 15:26:29 -0700 IronPort-SDR: yCwHeJ6rRkGtKNof8GEjqbaKxAz/e7UvMdOJ0H5gQ+/vROArz2qCNRf+ThKjmZy9CsF3QLI59T YjeHavqKiVRA== X-IronPort-AV: E=Sophos;i="5.82,288,1613462400"; d="scan'208";a="430065112" 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; 10 May 2021 15:26:29 -0700 Date: Mon, 10 May 2021 15:28:54 -0700 From: Jacob Pan To: Jason Gunthorpe Cc: "Raj, Ashok" , "Tian, Kevin" , Jean-Philippe Brucker , Alex Williamson , "Liu, Yi L" , Auger Eric , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "cgroups@vger.kernel.org" , Tejun Heo , Johannes Weiner , Jean-Philippe Brucker , Jonathan Corbet , "Wu, Hao" , "Jiang, Dave" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210510152854.793ee594@jacob-builder> In-Reply-To: <20210510163956.GD1002214@nvidia.com> References: <20210505180023.GJ1370958@nvidia.com> <20210505130446.3ee2fccd@jacob-builder> <20210506122730.GQ1370958@nvidia.com> <20210506163240.GA9058@otc-nc-03> <20210510123729.GA1002214@nvidia.com> <20210510152502.GA90095@otc-nc-03> <20210510153111.GB1002214@nvidia.com> <20210510162212.GB90095@otc-nc-03> <20210510163956.GD1002214@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 Mon, 10 May 2021 13:39:56 -0300, Jason Gunthorpe wrote: > I still think it is smarter to push a group of RID's into a global > allocation group and accept there are potential downsides with that > than to try to force a global allocation group on every RID and then > try to fix the mess that makes for non-ENQCMD devices. The proposed ioasid_set change in this set has a token for each set of IOASIDs. /** * struct ioasid_set - Meta data about ioasid_set * @nh: List of notifiers private to that set * @xa: XArray to store ioasid_set private IDs, can be used for * guest-host IOASID mapping, or just a private IOASID namespace. * @token: Unique to identify an IOASID set * @type: Token types * @quota: Max number of IOASIDs can be allocated within the set * @nr_ioasids: Number of IOASIDs currently allocated in the set * @id: ID of the set */ struct ioasid_set { struct atomic_notifier_head nh; struct xarray xa; void *token; int type; int quota; atomic_t nr_ioasids; int id; struct rcu_head rcu; struct misc_cg *misc_cg; /* For misc cgroup accounting */ }; To satisfy your "give me a PASID for this RID" proposal, can we just use the RID's struct device as the token? Also add a type field to explicitly indicate global vs per-set(per-RID). i.e. ioasid_t ioasid_alloc(struct ioasid_set *set, ioasid_t min, ioasid_t max, int type, void *private) Where flags can be: enum ioasid_hwid_type { IOASID_HWID_GLOBAL, IOASID_HWID_PER_SET, }; We are really talking about the HW IOASID, just a reminder. Thanks, Jacob