Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1868021iob; Fri, 29 Apr 2022 15:01:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkeU4xmpMV51XJPIudHjOt+C+8sCU6SkbQgpCa66xZq9Thar5BIPt+UdC5gMUF5nCouUm9 X-Received: by 2002:a2e:b712:0:b0:24f:150e:1a71 with SMTP id j18-20020a2eb712000000b0024f150e1a71mr790831ljo.240.1651269682784; Fri, 29 Apr 2022 15:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651269682; cv=none; d=google.com; s=arc-20160816; b=ql4lPabdU2SCpkGwHif9FndXJ8O7B9IFCiTiisUJ43fia/kd1UUSW8xZCuaQxfv2Yw 70526o19Br7XFes6/JQ9Pci3U0A4+riUb0i9MYgaiBeVyFQ9yToE8+zAriW6dPMItu// r/tpOtHkYitubzOd7w7O5YTj/ZtOnrZ7LzIW5i+8B4v+7Hx083onX2wkqhyGDbCVqQgn S345awYRXitK1kmNjHzJeTq18VjEszJMnPD9HTE3YoTlpRJslqYvZdDVUMZY8vEoOsk/ pdFH5daki+iJRF4h6S2BlaD5IT4EyxlGbX14vKNX9SSynZ6+Imi5uTkO2rxktMyrWiXT 51Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=focMG0Yvzu8kTNlJIkjfWrJiugje96+mCpIttRqo5P4=; b=zPqFrCgkT0tHPuyR4pacXrf67AYapZouCTirZYElXqyzSFDho6YikLdYKui3heT/HA 9dPVQ7tJYJIMmyryA/lukjKo5FmQbcg5ndkOFDe09oKe9zYKSkGJ1kAlAp7RmhpWB9q3 GmmgNrgnpaiRHn4eRqC/33qyApx2hSRvCb/zCr5cP22LitfztUOQGcGW73s1nlqyYeXm 70zTh0+QER+3P2f/sUP6TMHDF7A05t9Lv1JTwmUQ0z05Xig5mF6Y2o+H/JmqWKrdtBzC QQuvZZzUPLIDsASqQJmKq/YKcOMJuQYwRwbj6U1bS80F36wfJ5mzPm8n7HZVac7hAl4+ kV6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GOeTnHyf; 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 j15-20020a196e0f000000b0046b91b6d016si6797247lfc.265.2022.04.29.15.00.50; Fri, 29 Apr 2022 15:01:22 -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=GOeTnHyf; 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 S1353430AbiD1XxM (ORCPT + 99 others); Thu, 28 Apr 2022 19:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353427AbiD1XxI (ORCPT ); Thu, 28 Apr 2022 19:53:08 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF459AC05E for ; Thu, 28 Apr 2022 16:49:46 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 125-20020a1c1983000000b003941f354c62so64107wmz.0 for ; Thu, 28 Apr 2022 16:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=focMG0Yvzu8kTNlJIkjfWrJiugje96+mCpIttRqo5P4=; b=GOeTnHyfLUj1kYuuIm0Y/SV6rdbaURUuZyug5U8+bM9txNVDB4zqvMsTo6LgWxqqJ+ EJzVOKlCGbXzZnVXdg3zImUfxT1mhWA8cbxLRGVt1mE5eBxCAY3hnU4fMZFKFe1/ysTG cyomFq/31PJ7L9dLLImNGTzmHFLpGkzqWJGCsZd6ESc2YMwmrym/vaV+ntsJIKN6uPzN GHJN6ZJmWTueQxTkthcuYUVcXcDsF4uUX/S+zj4KBcwgIjmuet5DXc3NMlNVPJ+MF4Jl g76wI45mkRhG8Ow9F+ienA/5IabcbdIA62pAqypAHshKR/CNShI7i+XFMGHcSQdqfi8n ZW7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=focMG0Yvzu8kTNlJIkjfWrJiugje96+mCpIttRqo5P4=; b=MzqhZOja0vJd3qQ8wSjDGuG6t6/VSC9NELWbJAufex3MK62wOMHAKToNpPwZRgH7PZ 0ivzH0kiJdEjYURkwlJeMBe4JBAPvoZl1gFaC2/HdLv4sixtM3K2bOUbkCrzlbYLL0Bx hXBi9qU/aIDP53o7jx0Wk5Y9+Nu2GuVsdicfzZ62Bp4yg3nVUjNGRm9ULCyI6ds4jYjy 9F0nJUH/fWgBRSm+2KtYDO1Q3hoKDQT151hzZtOMkig7jEuJQfN4mLThX0SgjQLjbL65 sC7p27hIBm4GK8L2dZiVpihE23ln59NKQG0+tTxwzRC+55XcPgIjdndUxy6RCj17ILDx L4tw== X-Gm-Message-State: AOAM5319OfeIEDRRfD/yv4PLlDLy9GLQnepf12UmbadRJbEg2CL1ODT1 8l9XQFvvlyhWIuTrWTWZUB1S1oSEzuW6OHOs/MMysA== X-Received: by 2002:a05:600c:1c88:b0:394:dfa:917f with SMTP id k8-20020a05600c1c8800b003940dfa917fmr536458wms.27.1651189785285; Thu, 28 Apr 2022 16:49:45 -0700 (PDT) MIME-Version: 1.0 References: <20220426053904.3684293-1-yosryahmed@google.com> <20220426053904.3684293-5-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 28 Apr 2022 16:49:09 -0700 Message-ID: Subject: Re: [PATCH v3 4/6] KVM: arm64/mmu: count KVM page table pages in pagetable stats To: Oliver Upton 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 Content-Type: text/plain; charset="UTF-8" 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 Thu, Apr 28, 2022 at 10:45 AM Oliver Upton wrote: > > 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 so much for the insights, will send out v4 according to our discussion. > > -- > Thanks, > Oliver