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 06E2DC433F5 for ; Thu, 28 Apr 2022 17:45:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67DBA6B00D4; Thu, 28 Apr 2022 13:45:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6068F8D0016; Thu, 28 Apr 2022 13:45:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F166B00D6; Thu, 28 Apr 2022 13:45:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 326346B00D4 for ; Thu, 28 Apr 2022 13:45:53 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EA3632ACA2 for ; Thu, 28 Apr 2022 17:45:52 +0000 (UTC) X-FDA: 79407015744.04.504F611 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by imf20.hostedemail.com (Postfix) with ESMTP id 903F61C0072 for ; Thu, 28 Apr 2022 17:45:48 +0000 (UTC) Received: by mail-io1-f41.google.com with SMTP id 125so7261308iov.10 for ; Thu, 28 Apr 2022 10:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rYkNgcXPFsN0AZS9Gdq00dTATV9XxHLGEv5CoQhxVgg=; b=hzMsoV3D0yJ0Unlop+rpTzklIYhRnWH7ICsyDlDVFdcLE9BIlkNP73Wm+4oXNVuiB8 plJ8GuyyvEt6ZXQbKxd1muNdZzq09naSLXrKhBTeETybRl01LEoPVDN68ktaYn9l0zsi yoyQHHe1wradnURDVY6+HNGMMkWazXFQRLoTut+ycpEUb54hblTXLdMjgsITAqGXMdx5 3Y8FH49L78ooub0KNRfiN5ke97caoBhhHNMCuuOQncS7BD/mI1wPI6p0qS0ilNo4Z01F oWlrVzL07peONZe79tOTcyd8YQZsNWlwpVd98T9TgcHmPXq0Kuzw5WruzgVtu+f1uIoR iH0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rYkNgcXPFsN0AZS9Gdq00dTATV9XxHLGEv5CoQhxVgg=; b=0YZ0df8geXSm9R0jT4OYQ6NhZTcDTybYj/NhrR/iPS27KVNv133knRqr5KNBCg7C8n rT5lbW8n6Pc+r2orloHFG2biOL3MI9GXW1YustOFGatgNp5GwS3aE0ssk/6Ly2XAjz/Y zV83m0ngAWWqwP1Wg/9YY3B+bYLMt2jNzYbabawHxe19/J5XLRdwqW8Zs/XziQUBTsB8 na5SlaTYmuT0VKSOyJuLvz6DOIdcq5H4sUBfKESPNrPxe0m7RgydD8nwukLquRm/zoWI u7cllr3nIugQWSDiopxFa6xWRx2+C4jX0v5+XMCbkQpMhhDUUFFfiyzKASAZ/znXLrYu megw== X-Gm-Message-State: AOAM532CLQTXqvMgQoiR/1z4FAjMeXg4UYtP1jMNC4H1FzVANUAnFGAP c5OFIvvThTG3eHW+2YRzal9XAA== X-Google-Smtp-Source: ABdhPJx/sYY/i7dOFt3+PaiV4KhSUz6X+tqTVPbVDr2OqPDCjEE/yaOau4YnhKo+v4gz0/SI7nAHRg== X-Received: by 2002:a02:cc48:0:b0:32b:14:4186 with SMTP id i8-20020a02cc48000000b0032b00144186mr6761137jaq.189.1651167951414; Thu, 28 Apr 2022 10:45:51 -0700 (PDT) Received: from google.com (194.225.68.34.bc.googleusercontent.com. [34.68.225.194]) by smtp.gmail.com with ESMTPSA id f15-20020a056e020c6f00b002cbc9935527sm269640ilj.83.2022.04.28.10.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 10:45:50 -0700 (PDT) Date: Thu, 28 Apr 2022 17:45:47 +0000 From: Oliver Upton To: Yosry Ahmed Cc: Sean Christopherson , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , James Morse , Catalin Marinas , Shameer Kolothum , Marc Zyngier , Alexandru Elisei , Suzuki K Poulose , linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Linux Kernel Mailing List , linux-fsdevel@vger.kernel.org, Linux-MM , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH v3 4/6] KVM: arm64/mmu: count KVM page table pages in pagetable stats Message-ID: References: <20220426053904.3684293-1-yosryahmed@google.com> <20220426053904.3684293-5-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 903F61C0072 X-Stat-Signature: 6wu7dw17cj4c47bo73zbxyztkytyd3oq Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hzMsoV3D; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of oupton@google.com designates 209.85.166.41 as permitted sender) smtp.mailfrom=oupton@google.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1651167948-267313 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: On Tue, Apr 26, 2022 at 12:27:57PM -0700, Yosry Ahmed wrote: > > What page tables do we want to account? KVM on ARM manages several page > > tables. > > > > For regular KVM, the host kernel manages allocations for the hyp stage 1 > > tables in addition to the stage 2 tables used for a particular VM. The > > former is system overhead whereas the latter could be attributed to a > > guest VM. > > Honestly I would love to get your input on this. The main motivation > here is to give users insights on the kernel memory usage on their > system (or in a cgroup). We currently have NR_PAGETABLE stats for > normal kernel page tables (allocated using > __pte_alloc_one()/pte_free()), this shows up in /proc/meminfo, > /path/to/cgroup/memory.stat, and node stats. The idea is to add > NR_SECONDARY_PAGETABLE that should include the memory used for kvm > pagetables, which should be a separate category (no overlap). What > gets included or not depends on the semantics of KVM and what exactly > falls under the category of secondary pagetables from the user's pov. > > Currently it looks like s2 page table allocations get accounted to > kmem of memory control groups (GFP_KERNEL_ACCOUNT), while hyp page > table allocations do not (GFP_KERNEL). So we could either follow this > and only account s2 page table allocations in the stats, or make hyp > allocations use GFP_KERNEL_ACCOUNT as well and add them to the stats. > Let me know what you think. I think it is reasonable to just focus on stage 2 table allocations and ignore all else. As Marc pointed out it isn't workable in other contexts anyway (pKVM), and keeps the patch tidy too. GFP_KERNEL_ACCOUNT for hyp allocations wouldn't make sense, as it is done at init to build out the system page tables for EL2. -- Thanks, Oliver