Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1160570iob; Thu, 28 Apr 2022 21:40:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZo724Aw8P+lLdZ0ltjdtScxrBInMIsfwWSsr7pT0oxxQzBb87cBCcodEm9E1Lu3Pn38r5 X-Received: by 2002:a2e:9dca:0:b0:24f:2924:9295 with SMTP id x10-20020a2e9dca000000b0024f29249295mr8033801ljj.480.1651207238030; Thu, 28 Apr 2022 21:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651207238; cv=none; d=google.com; s=arc-20160816; b=elguTtGciJQQOAYsVGmWZBihyXJcxk7aSa1+sjczMVWML7rbKPLmTWfY7TsUR3pKfH MiKcByrzf9b/WQcqw0Uf6lnqt8UblDeAN5J9axQ+n4SOcw1SQHYpysO2ED8VoXbj5siz TTW4poSHnNpTEpRJbqk6UNTD1Pz+8D2u7pAkEQlTxXy16n6uXQ2rAYBmYi6F/mDIe5/f LsEVlekjVCndn+9rnFVZgcqLSOlB0N2KEyU19VYCuGgJR2WcCtLL04lGBE2NR2ZFkyWx rV6VgdvcUOi1EuesbLiVKPLJ2uUfugCrfuZYcW/vGDuR2MB1TQRpWYUIY3eLDgbwf+V6 hpog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rYkNgcXPFsN0AZS9Gdq00dTATV9XxHLGEv5CoQhxVgg=; b=IcEcEh8p+pgbgZciaL4ntGFj33Yvo0bkUkeARje80BmykEidzHjZASe2vTWL+cFpIh xKuVic2Z5su26JACYEiWOfyetMjFm8MWmMCq3qX9h3IX4nG4it1TdpBu+8WgK6lDzQOt EU8xdfYeDqiqEQ+Lol5Qct9irOGbkuBn64sbVBPUrSYjxUvhYjFcXwE2Ui3hTP9g79Af xcSJKo1cnxRzySaINd28JJKTQ+IJlnU+LbAFP6pZouvuKudB3Dc9R8x0SvYYbYM7AZB2 oEYPio/xRH4cSHJR7NewvKhnHNzDolFnkMYev7YbpHAzCtYtTPcbOSmJe68soIjwpmB8 LPeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hzMsoV3D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a2e8e86000000b0024f11cec4b8si5778282ljk.175.2022.04.28.21.40.10; Thu, 28 Apr 2022 21:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hzMsoV3D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350606AbiD1RtK (ORCPT + 99 others); Thu, 28 Apr 2022 13:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350592AbiD1RtI (ORCPT ); Thu, 28 Apr 2022 13:49:08 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8522486E28 for ; Thu, 28 Apr 2022 10:45:52 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id g21so7235860iom.13 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=mOpcpjqCuAD6crwHRJaKLwwsVt5HZQ6A6rnhzfCs8fI7x/wDCJWzHBHz0xoUIdClZz 9n9WKUMoQ6+4DGT4doWzJVw6DR0VTqzr3iEcnKcyiak7So9kTDCNp3qF9F3UjTUCAzgS 4JUjgvnwrv8Cc5MJ10v7PTJ1GeDI23kKSneLTB0AG/z1LDTZHadBjWOi0tyVneHNiW/m bVGpc16RRmiJSqAkKCQBVzIAQiREPnipltrWOME6X2dRr1R23UlnwuxvTRrfAHR+Bmw5 7S8gI5RwsELmhbPxCPuspr5jSfdw35+ou2rOwT/dvC6Z7ypDgxA365zVLXZcw5jCesJb C88g== X-Gm-Message-State: AOAM530Sd89sBLo7Mrxft+/d9fKP2W+dg7kRlHbY/ncIdjQWFhZeyRfn MunR+AMGoTlB33+7jP4vTAmGhQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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