Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp39187rdb; Wed, 21 Feb 2024 16:22:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUyNT3G5whi1mJ7wr7MgSrk7KhDr1vl7a20yhSB5TSWfkgzSJMENTn5pHHhtmDs7wRRAwhtQs5rLVGyG6dPwUozr0MZ/DS4RfQG+P1xvg== X-Google-Smtp-Source: AGHT+IEaDyghOB3Y5XDV1XCXMycQtkcQnnz0sBgyRYtUcvlcI6verjAjUfMcgxCOnYpVWmMQsW29 X-Received: by 2002:a17:903:18f:b0:1db:e673:8ba6 with SMTP id z15-20020a170903018f00b001dbe6738ba6mr11817522plg.32.1708561332688; Wed, 21 Feb 2024 16:22:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708561332; cv=pass; d=google.com; s=arc-20160816; b=im/ZuWzlXAlwlMS57B43lv+vYylJKb/Cd3OxP128zKwO+uyGwYU4gZw6mWIjSbJik3 +AjsckwxAe8Apv14OqvuO0XYz8fRDR9/GyuyV3TTsMlTPARo1Zt4rmWzhBEE+KzEyDrF FqcSRVlyKhFxpBUSyLWi1WLzvS4Hz3IqI5VU1zdRhTghcL5hFFMz2gWeORQNuThc/3dT n93tZsk0hiWVzfEEh7JN6ChYcz8uMgbjAwclGYWHh+MYnbHvIZ6A9MzJW33gVRYdTcSC QAoAdhRtyTlsQXO5sulBtQ2dBlaoEH5EUyj6cmngH7JvWJWJrPDHV+gsUdz7VItbV5JS gtjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9rn4mWdOER6tRcIB1iLpkedD4oyQHhFAy8BqoLay5HA=; fh=AIGdPasmaAw5XTsBKJlH8oNNrJg/sMPJKuhgUhmzR6k=; b=GCjsjpmH+faMNmM9UIwezH1g1YQSvgf3BUu1YMGqz4rn0x5mEG84Wujg53kSUJmnD8 6yHJl6thTxwBPXFfKGaEZhUgbDAgYJI/RdTAummqScwH9KBxrl72IIPYQOrvb2U3eF8s EGPNdGF1jEyHxGAKYIKwn2uvCSb4Nv/RBXCz7RC6G58X5+dOcntS/hjoxwBB0PkXzBzC 8ys28YAvDQH/12sO5SgULQSSlXriNsj8SfeJXdpz6ok3vNb62+c8TtNZe63f9l9ltpA3 r3IF06XJuxG8JYIdWzTSj4eMR2Yo4Dq73obJ/vvb/Xuk9h+kSSJOytQiPnaVee61kIaU 67Iw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=MgcZg+65; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-75718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75718-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h22-20020a170902ac9600b001d50ecf8686si8855270plr.520.2024.02.21.16.22.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:22:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=MgcZg+65; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-75718-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75718-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FF93284F7A for ; Thu, 22 Feb 2024 00:22:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E1D6FBF2; Thu, 22 Feb 2024 00:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="MgcZg+65" Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25F5C320B for ; Thu, 22 Feb 2024 00:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708561317; cv=none; b=UG/VEPrTeiJ9AmDjzQ92J3MP8ngiM/3pUysovik47nS8vxrAmA1w+8c5a36kNGaZ70FjnbQvQHh/9ty1FjFIxO4NgP+kzw5tTfoHkUDfUwuOVnByW88KZWRLDkZncLhjKMfZLUOX8MA1elu9lGIGS4wg/xP3aJXN1kTwBrYkYj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708561317; c=relaxed/simple; bh=ULWx7GnGcbkzH+Hk8ucwqEKl61im90Y5FaAmJnZtJAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VKJJO7SddpjYqf7be5D6TL5wBU5XV3lZ/pk2dvYlG/p4T1WUDnJ/PduyS6YJsb728jfOg2Rj4+11T6FiMsOqOf92nz5bcb5nA1a8JHo/UaQ6VxLOL2ZgYHpIgyv1AfjcPcatnhkjL1fQLjzE+3HvIyOoi7zizNeTquOQrR/OeWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=MgcZg+65; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-68f51ba7043so31242466d6.3 for ; Wed, 21 Feb 2024 16:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1708561314; x=1709166114; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=9rn4mWdOER6tRcIB1iLpkedD4oyQHhFAy8BqoLay5HA=; b=MgcZg+65Vvf3eaGqKA5NYMlqvoMc4UiKldYMGimRMSN8bQIK0NRXQ0FKRKAKjOxSot Bssdjpj+HfxFZnetE6jgTuKheGtF04qKzVcAnNV+4tCtvAHwPezDYUR4YQFpEoqUcuy2 JIN5YhHfBLRlvutKyOMDClQJz2G4qTwAEE+MexxY7vThbI0GkkQu5VUYYb5nHB/tKNGV 3/BWBcxXhWtHmBoFUeiHkxr04IXKyVGw40F2MhTtUVwlWHK4vPpBDRh8KFKKEJQulrlb QjbpgcDelPqeQk96DbvIYt0Mp3aSz/ncDX7G4L4DxVyr1LJwaLeo1SocD6ekZzsS2aIy psvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708561314; x=1709166114; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9rn4mWdOER6tRcIB1iLpkedD4oyQHhFAy8BqoLay5HA=; b=O9TfYq2EoLf6/uo4hINY9ycbdl4zO3vb1QRZ8cRVsR6RZsdbf5kOzn4l0pObCRBzED o3DENy3rEU0Sb/HWYfdiS5H8PXUM9bQa1hppKc/mkp9uQDd1Vl3EJbapFc30KKOEWefy YvTOcp1t3mHqytRtcDFnZic8VjkBRIAHXYap7EGwYD8yejvDkUEEATqdUnn8h500fTbv 9RlOmxvShkvdwMMkBWJpiDDHjwEJKEyzlSvskbJrmyg1Ke2Jx3GvHrMgbyj8l8xNyOCz GfilUiD47EjopIrKtWQJZUir525iSQ26GBbCa5ENY52S24tHuEaDKr4I1XF1ltT3cqx4 ZmHw== X-Forwarded-Encrypted: i=1; AJvYcCW8GllZh3aqfI3t44PPeSFTfh6mH1I9PRCwZZ62eoJFe2X30Z1z/kwY7ak1qxAK4GKA8byti0rqzUpEVULOZQP1WyoMC1/It3uG9BqA X-Gm-Message-State: AOJu0Yww2HG4vmHMc4lotjSziU2p3nW+gMer1ao9U/spAFERKemz1gzT hdjR1WyL3N9G2RnqKMY1Gu0jPy3ZoyVUOP7UdhTEN4N5leTw+k3bpEqxYE6EXpY= X-Received: by 2002:ad4:5ce3:0:b0:68f:8d7c:73cd with SMTP id iv3-20020ad45ce3000000b0068f8d7c73cdmr10367841qvb.8.1708561314072; Wed, 21 Feb 2024 16:21:54 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id lb25-20020a056214319900b0068f9bb1a247sm1871280qvb.19.2024.02.21.16.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:21:53 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rcwqW-00DQWC-Tn; Wed, 21 Feb 2024 20:21:52 -0400 Date: Wed, 21 Feb 2024 20:21:52 -0400 From: Jason Gunthorpe To: Pasha Tatashin Cc: Will Deacon , 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: <20240222002152.GG13491@ziepe.ca> 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Feb 16, 2024 at 02:48:00PM -0500, Pasha Tatashin wrote: > On Fri, Feb 16, 2024 at 12:58 PM Will Deacon wrote: > > > > 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. > > 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. Right, SeanC mentioned that the purpose of SecPageTables was to capture all non-mm page table radix allocations. > I would appreciate the opinion of IOMMU maintainers on this: is it > preferable to bundle the information with 'SecPageTables' or maintain > a separate field? I think you should keep them together. I don't think we should be introducing new counters, in general. Detailed memory profile should come from some kind of more dynamic and universal scheme. Hopefully that other giant thread about profiling will reach some conclusion. Jason