Message ID | 5-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D6EEC32793 for <linux-arm-kernel@archiver.kernel.org>; Wed, 18 Jan 2023 18:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HEliZZSCWVkpYrFU43hwAGgyWe2wHKffpdfxRE02tME=; b=cvxzIuel9FyqgV ved6A1Jpu+h/FEwBz3TPROz6wKUAGMA0uzRHnKZ2kwZpktW1iMziQFnvL6zO7Ap9durIO+zSHQr0C LdcyfLE4i11XA8IDViBFj3nGWBCOpuKr2NxjvBaE1PCy6XXUeTuSNnJaHFR0mzqFiouW57dWKGgVo c4/p3mgcsiAOCJUhsfuuy0kl34LLp0+pUZBe5igcnSn0rZL4eTnDdC9th6RsRfsXozkeUB2O16V0G fCY9J9j1Pf5xJcQD3Zfv/02WJCGyGyXGUGzxvQdQKbDzfXVe07Ks+mWLqN6OlZqouDAdSvChc33di aEofnCKyyGGDe8w0U1Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pICkw-0029iy-Ir; Wed, 18 Jan 2023 18:01:52 +0000 Received: from mail-co1nam11on2065.outbound.protection.outlook.com ([40.107.220.65] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pICk1-00297h-H8; Wed, 18 Jan 2023 18:00:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0wBWJ5PLq7u65SEgYt76cVl9XecEOjRo5m+JyAiD1lpJ/3L+nBQuTzGn0U5tehiqFbwP9WCK0VmPFnFTmmDg5taSBf6gZCqUT2ypCpNPEFo2mZJXn5IUT9wFsZrXYKxaDqH/ENe4ODpIzkPVxEz2tpl5qu72nxbeih170IWToqNSgokjHCG7wLXsgKW26WjryCMRlTr4UySgtOqCIi5fVYRSGIRurJjPqbSP2OMQa6rc9IvtuQO7Z9DlfxDFEkiOgbYzgn7FwCAZ91lYFq5NHKE6eT2ptjVAyUGXBZnElBFujZ7GKFtjrU3QRitK5yAU72EvoWW9rNcgwmNNJOnyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hW/5mujLMwqrzVEZt7wBA4VSpYB7Lob2U3kTzSD4quE=; b=mYNdaHQSWoNrNpq41kqgmJvWo+v/BX19qun3XweTQCVUq6Yey1GpebsiBQgF+XsWmPNbbmOTtwjdSYIgQLP5O5VA62aW7SpMSLghstgnCFrzbTDb8lQ5Kec4Tu4HQkop2KnRBtR0oMUY7/zKJyhZ5TFaHnyKSZ8MmU2xfzxcUYXyGi4RC5wlO4B+jOeeyMkau3V7WHlMDkLRiJrxSKX5PGyaF4YqyqMo9/rLsuvKicP7freGhyYXtZQ3tm3/wf3tmrITZ0VI1/Qqe5JDmq7KAEe9j1rLiN27DxaGgMj4Q0MUDrQwq3gPQW24vnjQdkJxBDbKMkB6gnUSCaZY9zqV8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hW/5mujLMwqrzVEZt7wBA4VSpYB7Lob2U3kTzSD4quE=; b=IIS52DBDnuzB6GfbVJQb6RssA1TqQPqIywi8Emj3mrgbbWu3HmLg0AUD0Mc2NfvgOraj9jEhtP9LPhE5F7+Rmwv2gV4yriBSTropqB1oaD68ZKFPLiHwyFWi9lPR8dpUfFRM48P2x4tSNlMg9BKsKVE/OSos08v10r2WqfRZcvQFKBGd10gDwJ5I08KtB2uNNOKJ+d4ojThvIAXkVVzj3pJqOM7Gt0M3UwAFyxe76jVH/CJIs10OWkJ4RIds8i5MueImrQp+uqgB6VebWZANxB39ZfmURxUY/1bF6g5bexdvKfYUVJ5JDhNLIpuC3sRl/ZozlvkM77tf/XJxB5E/nQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:47 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:47 +0000 From: Jason Gunthorpe <jgg@nvidia.com> To: Lu Baolu <baolu.lu@linux.intel.com>, Joerg Roedel <joro@8bytes.org>, Kevin Tian <kevin.tian@intel.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Robin Murphy <robin.murphy@arm.com> Cc: Alex Williamson <alex.williamson@redhat.com>, ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger <borntraeger@linux.ibm.com>, dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle <schnelle@linux.ibm.com>, virtualization@lists.linux-foundation.org Subject: [PATCH v2 05/10] iommufd: Use GFP_KERNEL_ACCOUNT for iommu_map() Date: Wed, 18 Jan 2023 14:00:39 -0400 Message-Id: <5-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0072.namprd03.prod.outlook.com (2603:10b6:208:329::17) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: 9212b8d5-7b00-4766-3780-08daf97dec20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VhnY/VkdROsKqYj8be1fIWvj9/wmVvhCi5RdHSgcpUI3D7RXN7E/NlHyCI4IaGMavrRy7WNjLTj4gS7AK2XG0R/FnDvs9WhATGQa2YU6LxeWUKoL/vynL7JTTWUEPke5n3QrZfj9mXGYB7CYAiwt6jZMdowB2EcXF1GOlqIV+id3nw+evxRw/4Is4gBEq2bYD5OzLylzWikOdoRCsiT5NT9G5UhHG0KjehYI5QfYYd02QF9nmv8zsgZ5H2OJJKEM/V23Mmv1BZJPm/nS3n3OjalJI/aG38hqnjo7hwicwEeKGZfQY2Sl0QD5TSjgk6/h96NV6u/QLvrmLOyibsCaN92lDNgwEl7F7g/vQenbUi2xQLiBSjXtDJnKV2u/cCd0NJMP0cxBdgIC3YQ7N+wQ5TEpr/6Hdfk52AJAS7fGT6CBnZamQY+dDJv0Y/nHq5uLPRkPmMKzzptv5vNcNiiXgVUyonODB8Pkri5ht3WirfMhkhyPzsqphLwayA6Uu/Qi/9otYtdar/FZ4x8ecZ2zQWHy/fLGbV/SnPDZgfSzXUaqhBYaExRf0GtnYKjvrWUJsRFb8isvnw2n9T+3jKBIsRVWLwDfLFbVi44RMFAMzjiQGd61VBXqVLT5/HFWkfTT64Jpcgb7BiXKvjr9pQc3k4qxDZV+x4B1hFprJb6GCj+6O0LceZKU5GfeuLfapTEk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pY8Du1khAX41fW7ZAX/0US/CVQES0iyKzWtL1OlGRvz/lbP0CTnlZRWNiQXa8bCsNWsvg4H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ZUR8KqRSqOJNx8SeXx3lXftOfwjlhiwsRMWzsDMhlU2+p7OXfOWjU0b2yY0UMKtqBxQNz0btHFx64y3vmijmjTlnVaSUXrggGCxnN3cBjcSSo8Tf6pXa1v++GpmXSBKQhU9stZ4il6PShl57kw5uJfu7T/KMWgOY6Y57zTSeUtpQuPrWWBAkIlsSRXZIeEO9M56GAyLYKN0ijk36RnLl8JaWJIcA1mKZYrAPAD+7hRQ7YeCIJZ5VbIWCnFTcPNtU99KaSlgtsYzF7O9KByRA6pI+UQbZXCpSLwRQdB2IDx9rfiX/QyihqxndRqbkj3eRl3FvICX4BD2N2NHBUdqthY8WeHKx+JfTL9VpFFKerGKNcL8LCtPueI4JnikpeQCho4iw6MhcE1pOSWdP4Ip04cEf+HcwU4Mw3JA2+lOXwHw53Jg7A8Z+TqBeD4+qawsL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9212b8d5-7b00-4766-3780-08daf97dec20 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.6308 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 55MBwQPcT8/1g4nIe30PL0YyKmHQHK4QDIV6WRiXYMhdJmqH/hRVQGW0CN50XO91 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230118_100053_595287_148C9778 X-CRM114-Status: GOOD ( 11.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Let iommufd charge IOPTE allocations to the memory cgroup
|
expand
|
> From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Thursday, January 19, 2023 2:01 AM > > iommufd follows the same design as KVM and uses memory cgroups to limit > the amount of kernel memory a iommufd file descriptor can pin down. The > various internal data structures already use GFP_KERNEL_ACCOUNT. > > However, one of the biggest consumers of kernel memory is the IOPTEs > stored under the iommu_domain. Many drivers will allocate these at > iommu_map() time and will trivially do the right thing if we pass in > GFP_KERNEL_ACCOUNT. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index 22cc3bb0c6c55a..f8d92c9bb65b60 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -457,7 +457,7 @@ static int batch_iommu_map_small(struct iommu_domain *domain, while (size) { rc = iommu_map(domain, iova, paddr, PAGE_SIZE, prot, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (rc) goto err_unmap; iova += PAGE_SIZE; @@ -502,7 +502,7 @@ static int batch_to_domain(struct pfn_batch *batch, struct iommu_domain *domain, rc = iommu_map(domain, iova, PFN_PHYS(batch->pfns[cur]) + page_offset, next_iova - iova, area->iommu_prot, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (rc) goto err_unmap; iova = next_iova;
iommufd follows the same design as KVM and uses memory cgroups to limit the amount of kernel memory a iommufd file descriptor can pin down. The various internal data structures already use GFP_KERNEL_ACCOUNT. However, one of the biggest consumers of kernel memory is the IOPTEs stored under the iommu_domain. Many drivers will allocate these at iommu_map() time and will trivially do the right thing if we pass in GFP_KERNEL_ACCOUNT. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/iommufd/pages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)