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 9A041C48260 for ; Fri, 16 Feb 2024 17:58:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A45168D0003; Fri, 16 Feb 2024 12:58:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F4B68D0001; Fri, 16 Feb 2024 12:58:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BC548D0003; Fri, 16 Feb 2024 12:58:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7B3128D0001 for ; Fri, 16 Feb 2024 12:58:10 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4D80B402FB for ; Fri, 16 Feb 2024 17:58:10 +0000 (UTC) X-FDA: 81798425940.05.89BC834 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id 2938B180012 for ; Fri, 16 Feb 2024 17:58:07 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nT6IeXcB; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708106288; 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=F2S6HVhuAAuFIS7K+GpT2rtTxr25Fbyr5/uG2pA+EVE=; b=Z4/cN2cZJLAH2AP2BpACkzYMKWc6UacxlTraFKTM/aUiYyUS2pJVnEz10xLjyZ+p7AwaRr AXJTTnGUtJHNA+eNNTXyzQkkJ60fDji3FVQeFLJQknS07Tv9FTasbKZzSO6E14Ik0XWDog rUZJ3LNXrs4qjfmrLXC3UjYMeeq/mLE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nT6IeXcB; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708106288; a=rsa-sha256; cv=none; b=epevj3KxJ3znu2hrF/WVZWOPlTHaYbNokZjEkKTu6UofYiaUKBIycKAfi2VJ06J31BrTPq /sRCjK74KCdFpZj2XkXdDQLkQvZU+70NuH8lwYvocd3tx0YgJi9cvObLFoNZnqIq9BATs7 hHgD1327pHiVJLHZAmu/ksC38/KRfA0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5603BCE2920; Fri, 16 Feb 2024 17:58:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53326C433C7; Fri, 16 Feb 2024 17:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708106283; bh=y2z4Q/0wnbBdLLtyxBXxt5K2cw4Zk8wNIb/HNMYSK+w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nT6IeXcB5A43SSuF9BwUjII4ilTrRHMPvyzAnUo1omQItjPLdK1yI1D9r6AZeDJjT Lwec75FjdfHRyDok4qKpynzHaY+jVireNBdMEX/3sIKAUUpmIhEG7WzhREkQiExlla CgQQTgxXPyDIS10jW64uzXwfZpoYlaicR7QgPuL2AkSdV1armgqhtJ8YVi3RmIUsAl Q2sDUO4AfPf2tDL7JF+EOIX5LDDCQbncjtrRPNNl7ClDtX9p0Tr4GtgrGyYSwu7tru dgGCbrO+S2RC7zBGm+KqHvQrvfNlefg2300BnAO27KjDWBt5rkFi4I/om5XiQtrGtZ +tSr/4cauSzEg== Date: Fri, 16 Feb 2024 17:57:52 +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: <20240216175752.GB2374@willie-the-truck> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> <20231226200205.562565-11-pasha.tatashin@soleen.com> <20240213131210.GA28926@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User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4OFeoNjo0TvQ+q/VQLZy3p OyLZPpza XckzwvTCDDgzW1TGmNp/JIxBSLRofnVLz89OrTcy0dk42RqcMABIZbf/unzMOv8/WchYJfZWCW4CsZ+vbs8TnL6MVf5SmuoBQhrYIE3HkdkOo+LKCgO6qeNmgSYrRAoqckqaWqJJMlTnSDYw0qMOnc2KTt6rd1IqMeIboyR6PFAqi9XyXxs4gso7tTQ6ce1OCJRck701jXu4dZP9RG37SbR85uFpfz7riuPU6ViZtVEdZy6Yri5gZu1JrBeGU2qerADrS 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: On Tue, Feb 13, 2024 at 10:44:53AM -0500, Pasha Tatashin wrote: > > > 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. > > Hi Will, > > > 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. > > The accounting constraints are only applicable when GFP_KERNEL_ACCOUNT > is passed to the iommu mapping functions. We do that from the vfio, > iommufd, and vhost. Without this flag, the memory useage is reported > in /proc/meminfo as part of SecPageTables field, but not constrained > in cgroup. Thanks, Pasha, that explanation makes sense. I still find it bizarre to include IOMMU allocations from the DMA API in SecPageTables though, and I worry that it will confuse people who are using that metric as a way to get a feeling for how much memory is being used by KVM's secondary page-tables. As an extreme example, having a non-zero SecPageTables count without KVM even compiled in is pretty bizarre. Will