From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5862C48260 for ; Tue, 13 Feb 2024 13:12:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21DDB6B007E; Tue, 13 Feb 2024 08:12:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CE136B0080; Tue, 13 Feb 2024 08:12:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0961C6B0082; Tue, 13 Feb 2024 08:12:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ED8B76B007E for ; Tue, 13 Feb 2024 08:12:30 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B77E21C14A3 for ; Tue, 13 Feb 2024 13:12:30 +0000 (UTC) X-FDA: 81786819660.23.631276C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 35B881C0009 for ; Tue, 13 Feb 2024 13:12:27 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lCIC4VOm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of will@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707829949; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MQTbHUGx7FHYJyFgknLCGMEQMejMBL+PzMgACrPiXTs=; b=foqeuxmfMd2VQ6DzWwWgbdDkHtrX7SjAIgN1vtLKfW9omcfEgUFudkc776HmogOGoe9Wk+ xQut7Zu0y9oBqFkF0ypjyjQeIYxlQJWgHdNdOqflhMJk51+sBHw29N/4v5YrVi9Nb1jHe9 q1OMktqtA5qS7H/tJrVz7UOYajXqwGI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lCIC4VOm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of will@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707829949; a=rsa-sha256; cv=none; b=RSdPpNHuqU64zHrbgJkZgqzHITlmOhDbaFOg/b8Cj0hI4y4Pce3c0NUasfJNIO9ZfaRggP OAldrACUwJotcdflNi80iEQSY7GcpCJllZ2KnD5drWo8jBQbxwZEsK5FPBq8wB1OwEjUcc MkiJeDk4npCASxKA0434TditMOcXAS4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4190CCE1BA4; Tue, 13 Feb 2024 13:12:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E8FFC433C7; Tue, 13 Feb 2024 13:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707829942; bh=0xP8I+Qej1cBpPDnNiDZJmh7/DqD49joD1ERj3DvfKk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lCIC4VOmOV8x0JsCqVrhzsGXz5txq4HxyFPJQRNTQh3KKT2Il8RF8+xeahTD5vCl5 Kektsz/mfJ/JF35E4m5MMed5MRfMr6AfYG18l3OHogPx0QMHtC27U91R9ksMBhJ7LC QrvfK3L/7OQ2iqeglywl+CEqt2Kk1nqFfANGVdzwrbq09GCHd1PFvhMsW+yndJN2EI 7AKa7uQuypabSxDDmx7RIiGt05YBvnxfcDyb7e4cAzPNfO0Its8Aro6czQ6i5gQbBA 2KpPkjnKmYQ164gn/9NIeHWvTjE9mVJFzcMrCxOJS/SnPSYLIExFrgWV58G9p+7QNg Scf3fQWeQ5fiA== Date: Tue, 13 Feb 2024 13:12:11 +0000 From: Will Deacon To: Pasha Tatashin Cc: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: Re: [PATCH v3 10/10] iommu: account IOMMU allocated memory Message-ID: <20240213131210.GA28926@willie-the-truck> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> <20231226200205.562565-11-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231226200205.562565-11-pasha.tatashin@soleen.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User: X-Stat-Signature: a6r6zcbza9g1n85uhu4rrg5ffjxwbd36 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 35B881C0009 X-HE-Tag: 1707829947-321440 X-HE-Meta: U2FsdGVkX1+snOqueW/T3siFDuF4oJv9P0yBCLUBULj8ynwQlTFWkZEWBwmb9l5YDasXilBN7yj8JfWBGcCVoqzi+AV47vngwBUTcRy/IW838RXZmRXh+QnZ+MhfA6ZxdsiXyzvjpNGs2qAtcXmtopB/DbGp3VB+vUMnFXFRkQqqdYaukwZ9G4x1t/b0G73AR7AJbmdNNl99UyFuaIBQEwTgyC1Y+mUT8lcd6YD19la4zsA8646FgIv32Ba26fAOjTZLdgXQYYIVHRw85rKyokRfNjtlm+6cPwjRTyD8Lf2hIBYzdw69qhNakf9PIF1vWqFwWhr76jgSnfrN1G6clBkANadcMtxEuZgpfe8MthPihKIsvMWEIniT87BV91GIaEAH1AaxTE5FIujG/hgrbeTlzT/D76RKR5+vMItX6eBk0NpX6gbc+5xaAOAiAxS2Ai2Fy+iFZxJvbFYZg7mtdL52f71E7SCFpsGtSeaSsMMfu3fPu5fbOrs0knN7KG/yrXS1W5dp7quYNyQHmx2DjtyVv+6VdboyinTvhAdGQROwJEENCz91ZJRLXWe5N3RBOc680DKVjojjASGGUy79SAo6lGmOApcBQT4cMKolEU8KoFZgueSbZ+4poFUEiQrn2Y1sa0eq3rboDiBGPQ+shbQ9x0LjFiYWZ77a004BD1oU+dVOTH8CvjDFwuQ80jqCh2sc7mVV/jIDFkB/xslcrI5I2JKYcIrNxPbTWj2znKu/tojUrBYfOdEw0NS7yvViWorHeCvpF6TBp+uxN6lZLboK4tzAikg+rKdL+/d2nYbgSyxMhABVgDMo95StSwznIVMncSAYgm342q5oWHWOqiXOnLciWIbPPxVK2bvGDM3KBGGsRqk+LDKxgq4T2XN21RrhXjeHgprB0FlQwceFV3W7F9IFyceLo51RDLQCa11qQwsMxnsBzPct6PqmCTbRT7fJoBrcGwiCjHIz0j0 q2T5YhPG Wj5bJc2dDOpYo0oKNERAr1+NhuTJrad72M1HxjceqIlsUP5i+a9JPf8ANaSXk97F74fcNcdslRvOwmNbu4Nb1lNAISeNf+xcyWzldbz8wnC92GHc3UJa4f8pPGtjLxYvVcYlotTKyvh8wFrqcn2Yp/HcViBV8M/22P5kjqeL3xfkr5wJQMxjzbdJvqgJZ9ozeDrHZZ18uD/0KpbL8ju5s8X9cp3IFoiXl/XALyNRswmjG+D3R9BI7/aP5FYfR2m2y00jAikclP5qOl5TpqyuBQh9HOQABd3sG9jxj39BNul4PXEJhEAHZAm+ZNu2hxH1tU7TX X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Pasha, On Tue, Dec 26, 2023 at 08:02:05PM +0000, Pasha Tatashin wrote: > In order to be able to limit the amount of memory that is allocated > by IOMMU subsystem, the memory must be accounted. > > Account IOMMU as part of the secondary pagetables as it was discussed > at LPC. > > The value of SecPageTables now contains mmeory allocation by IOMMU > and KVM. > > Signed-off-by: Pasha Tatashin > --- > Documentation/admin-guide/cgroup-v2.rst | 2 +- > Documentation/filesystems/proc.rst | 4 ++-- > drivers/iommu/iommu-pages.h | 2 ++ > include/linux/mmzone.h | 2 +- > 4 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst > index 3f85254f3cef..e004e05a7cde 100644 > --- a/Documentation/admin-guide/cgroup-v2.rst > +++ b/Documentation/admin-guide/cgroup-v2.rst > @@ -1418,7 +1418,7 @@ PAGE_SIZE multiple when read back. > sec_pagetables > Amount of memory allocated for secondary page tables, > this currently includes KVM mmu allocations on x86 > - and arm64. > + and arm64 and IOMMU page tables. > > percpu (npn) > Amount of memory used for storing per-cpu kernel > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > index 49ef12df631b..86f137a9b66b 100644 > --- a/Documentation/filesystems/proc.rst > +++ b/Documentation/filesystems/proc.rst > @@ -1110,8 +1110,8 @@ KernelStack > PageTables > Memory consumed by userspace page tables > SecPageTables > - Memory consumed by secondary page tables, this currently > - currently includes KVM mmu allocations on x86 and arm64. > + Memory consumed by secondary page tables, this currently includes > + KVM mmu and IOMMU allocations on x86 and arm64. While I can see the value in this for IOMMU mappings managed by VFIO, doesn't this end up conflating that with the normal case of DMA domains? For systems that e.g. rely on an IOMMU for functional host DMA, it seems wrong to subject that to accounting constraints. Will