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 72739C48260 for ; Fri, 16 Feb 2024 19:48:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5FDE8D0003; Fri, 16 Feb 2024 14:48:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE6B18D0002; Fri, 16 Feb 2024 14:48:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C60308D0003; Fri, 16 Feb 2024 14:48:41 -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 AF0008D0002 for ; Fri, 16 Feb 2024 14:48:41 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7E3011602D2 for ; Fri, 16 Feb 2024 19:48:41 +0000 (UTC) X-FDA: 81798704442.17.395892B Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by imf27.hostedemail.com (Postfix) with ESMTP id 9EBA14000A for ; Fri, 16 Feb 2024 19:48:39 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=I92rrOgz; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.208.181 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708112919; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XMO1uzBf5Ipo+B8nJFhezHnHhPZI6cIYH4qqZglP7mw=; b=lF7K6o9R/ee+XssLfJpbpR9Hh6H39TNlri8ue3zT6AIRDMNtEYzO4cWw8R2aCP9ilK0U5H BDUGDCou6m/WGPUS35yKDcu/vJGNnoZgT59LsgMWjZIc0j9YE01XMEFfpXRKFHDtTGBtM0 up+YYhHnq/WH630kIQKBxBxkwpNdjd4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=I92rrOgz; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.208.181 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708112919; a=rsa-sha256; cv=none; b=QG56N5cWp+1YuWpHmZm3d+mnz2/YoD8IGz12a/guV413MrySaue1MB7OeWRZs/znjsnhFl hPtZq0tmWqAs/4ro2uiFIJAvamjmg15CtdLg9DU0g5NqQbPxvdoS6oKj+ek70rCtAhYJwJ 28Wx8j2ejckv6XM3FHOCByHQ92y3lJg= Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d0c7e6b240so33147191fa.0 for ; Fri, 16 Feb 2024 11:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708112917; x=1708717717; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XMO1uzBf5Ipo+B8nJFhezHnHhPZI6cIYH4qqZglP7mw=; b=I92rrOgz4BTVerSwncpUqGUzGGsXQvvA7EugloDwIg/M5KvtuPlh+au0yQs/MYjF90 wjdxZBalBTmXmOkgRRav5k6xTyRrpmWf2hLvpMhOY+9qp9BAPbezpjXp06L7QW1C32kg 7CEdTHuYOK1UuNPmjtWJYOqSe4mhIXRlq66lh6CIRIzxOgcSkZosnL7xm0y6aLTdaZJl EFGNG2Kbhrfua2HU4OGUwfbWJm9svFUb87OIG+wCl3OVME0ZUki9+bfw8bZSfDQVbldl xqLQI5ktRZHdQaI0riU05hLUzp3koXgZbxp6dkShDAVfvsrk4J323pjN90OY+33Qa37u mtrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708112917; x=1708717717; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XMO1uzBf5Ipo+B8nJFhezHnHhPZI6cIYH4qqZglP7mw=; b=jkMYJNaQL/nJY5nubXIFezJ6s4mLmMRIxP4ftwjsavGw95Pl9Rn4xv52FWxochr3mS V6OlxX9J0FVVdWTl/i+pzYg4utTFjcv4TxFbpRCI5nFL4Q4TZPaWJ0I52hUNczuEcrrg M23o14kMIQyr7o+0LAYnwl27ejSOxf5AV/MyKhgmiV8yIDDSNbY4ZSRkhGKg3d+rWWip P5x6wjFkX0rXs8KM76eG9g7WQ14WR6CtlopvxKwBr42s6MORc2LlOKd1k5JW8Hnk1f8E wLL8fTl+CFLjtW4ml3+uqKfsPb+YA3UPAWx3TheWkLIvsdgdrGAclbs7dBM4toWhOolP Ov7g== X-Forwarded-Encrypted: i=1; AJvYcCXw1ar/KN+Q/oz5IB+9Kr4r8JFPay1Z+nguIXjSVts1ZBPwd8VoevBKFIvzrr24PnKUMeprzCubucXtYHHzAnRyXnY= X-Gm-Message-State: AOJu0YwtHqTtv/yRfU7lQTMiWayQTvTZHx1GmqEZgXBagkstdS3mWd7f qhf2xWEjnK+e3Wuuy1CmI1U+E+7VcpqYlcG+LF9PQe5HUNBvXcCHneQCuYJrhmS1MRV3D3eattU HR5jiDuXT9RAJAX2OAszyAQO9fF1des1Py+urxA== X-Google-Smtp-Source: AGHT+IEiJLDM3GyyGWObGaRCyMN7MxvgX2HQgceLg5ERcIU76EjTibg8tg0F0e6PZPfErw11n01+i2wIipIreSPlOTo= X-Received: by 2002:ac2:5bd1:0:b0:511:a021:220a with SMTP id u17-20020ac25bd1000000b00511a021220amr4183994lfn.21.1708112917508; Fri, 16 Feb 2024 11:48:37 -0800 (PST) MIME-Version: 1.0 References: <20231226200205.562565-1-pasha.tatashin@soleen.com> <20231226200205.562565-11-pasha.tatashin@soleen.com> <20240213131210.GA28926@willie-the-truck> <20240216175752.GB2374@willie-the-truck> In-Reply-To: <20240216175752.GB2374@willie-the-truck> From: Pasha Tatashin Date: Fri, 16 Feb 2024 14:48:00 -0500 Message-ID: Subject: Re: [PATCH v3 10/10] iommu: account IOMMU allocated memory To: Will Deacon 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Enc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UgY09yDfO8LxLsnbwPJdfp5ucknKpZzlhgvU R+rhQNUN PXl8hVvCoH5OX8UOG9qjE5f9zLAdMvdRW7l4cKhHW6VcTNbqgrEqXznZGstMskKJnUW7lll2FZePdZ0zCdSDlqEL5aVZolJ84zdC/vGMDDQZiDhcurcHaozykruNR4mwWlUNx 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 Fri, Feb 16, 2024 at 12:58=E2=80=AFPM Will Deacon wrot= e: > > On Tue, Feb 13, 2024 at 10:44:53AM -0500, Pasha Tatashin wrote: > > > > SecPageTables > > > > - Memory consumed by secondary page tables, this curre= ntly > > > > - currently includes KVM mmu allocations on x86 and ar= m64. > > > > + Memory consumed by secondary page tables, this curre= ntly 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 domai= ns? > > > For systems that e.g. rely on an IOMMU for functional host DMA, it se= ems > > > 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. I agree; I also prefer a new field in /proc/meminfo named 'IOMMUPageTables'. This is what I proposed at LPC, but I was asked to reuse the existing 'SecPageTables' field instead. The rationale was that 'secondary' implies not only KVM page tables, but any other non-regular page tables. I would appreciate the opinion of IOMMU maintainers on this: is it preferable to bundle the information with 'SecPageTables' or maintain a separate field? Pasha