Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp134018imw; Tue, 12 Jul 2022 16:11:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vE60OwoyruAE9wT0zJ0qkcmSxAaPx3gYVLp2e5dxk5MVOmEb8uXK6ePMmShCbeNevIqvon X-Received: by 2002:a17:902:7611:b0:16c:5c53:d932 with SMTP id k17-20020a170902761100b0016c5c53d932mr349791pll.1.1657667515161; Tue, 12 Jul 2022 16:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657667515; cv=none; d=google.com; s=arc-20160816; b=vFQkCQBWzWk41wlMQ45NURg3CV6/7umS5YwmQuKmvb80KPo9PwKcSaXLkArZhimN2h WzciLunis04YUy503lIiphuyfsG9LuneKuIRBRuET1yGFF74m0vhwJ88S9haXfCPo0V0 ykEuYcs8yZrx7pLpLRwORzNsEJtPdYAzQfYDFWg06hi0nPbcLroQaf8gZzfi9O2RyTui f8B3T2XekaQN0x+CVym5USwgRFp7jNOjDTBmZEno6RGacW8FgOB0jEjEi9yjOIPYKiMC +awdknEbAc/BTsGvc9ilR62aSNAmigY0tnF+Us3mmpcxphGhRdHSRiBgJfovGlLUb3uu FhWg== 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=qHwuHViFSN86tj0ChYoibxcY4E2c7D4JyTppJFZI4so=; b=W2AP9wm/x5+ZVmJq8+pwZ3CoTA22bPZ6rjpRhXqIcmoD01MSdu6jDz64w6d5UXv+Y/ zI7qrQy8MXFcIoZcduFqaTKUcnp24K0eeizcig6H0ENioTKe1D6008ShcAOwhq0Y9I1Z YNeFIewd9PnY6vpuRXmyEFkjdy4eTKtyZKTpmtcZ5ZNASpYih498zX7aGcV+suS4Rfl8 mz3Of26RubHhSSKj1t4dZPTfIyDwO72X4OZ/RjKNFDs7AF30kDlnzAsbWEu5KO2aWD+Y SZ6OBdVb3wclB6K8bM36xuoU+LJssV70CUG0HxXe3A77QUxZQ15KwVxmZ3vBKoWTfmm+ umXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Lhh55GnS; 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 g12-20020a056a0023cc00b00525417ce58dsi15020473pfc.242.2022.07.12.16.11.41; Tue, 12 Jul 2022 16:11:55 -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=Lhh55GnS; 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 S233817AbiGLXDn (ORCPT + 99 others); Tue, 12 Jul 2022 19:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiGLXDk (ORCPT ); Tue, 12 Jul 2022 19:03:40 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93251BC87 for ; Tue, 12 Jul 2022 16:03:39 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id p132so6312682oif.9 for ; Tue, 12 Jul 2022 16:03:39 -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=qHwuHViFSN86tj0ChYoibxcY4E2c7D4JyTppJFZI4so=; b=Lhh55GnSdOjPhbJGduTnxEGnWccw6kHOeEeY08jAZgJe0VqjmPoBdTPnONumi/pAun p+cHg4gHnhGSvibmw9wIMHwGbOMlbmWVVet0lyBNoQFKw49iIOLl44zlrlp+lgOkWr4N nI06n4Ji3hwluei1aEEzHQyZHr8WFbhVYRiJlwQVHmUD64NqpTZjoyhfvNHbS2GCc5aR uNpAcmjt7Eo2ZLV4iQ/jGK1hfJ4aVbxJui0znZqX9547wQXUukqWF8+PFEtZcDsj6osq cNrlBGb2ZoHRdeHJDRKTLI+onjdNABpheW4De5nAankciyk7viUqVbyzzoaaEs5liuGY qvhw== 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=qHwuHViFSN86tj0ChYoibxcY4E2c7D4JyTppJFZI4so=; b=puik5xsqFVktisDbr5DqTCzChx2Nm8+jKtzIHZ5P+YvFaBauAzpYUls4iouNHg2pnp KQo/6rrFmmcyt4zUbEYYrmdNBbj2oDKe//O+Rg4z8LvolWjmNX8EEHNoyYoiozRmlymk I3rNOVAfLkc86MiIJSCpeXtnpgPvql7x5QS4h1c4GvNSfghKwBaV0uHsKkId3PyJd1w0 uAU+k9Gx1frUJ6n7NzZlkBaKc7eRfLqE5c8cygIyRPRqAk4jGTcNT+AXNdSH9SQ/FZwD iqroifZaujNBivUkBJgnSuA450+H/n7kw6ecaxVr5xVidH+03L8rzTwddnejSHHgBwl4 x7gA== X-Gm-Message-State: AJIora/dl1OKhe4vNrhpjbl26Z/wF7nXBYsjCykaaFSyBPYdt7Qi3rDl HdqdGYbNZPtboFPxBBRo0KJ8ANsj8U3Y2ApDs1G6IQ== X-Received: by 2002:aca:e043:0:b0:32e:1ad1:2d4 with SMTP id x64-20020acae043000000b0032e1ad102d4mr3357976oig.235.1657667018762; Tue, 12 Jul 2022 16:03:38 -0700 (PDT) MIME-Version: 1.0 References: <20220628220938.3657876-1-yosryahmed@google.com> <20220628220938.3657876-2-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 12 Jul 2022 16:03:02 -0700 Message-ID: Subject: Re: [PATCH v6 1/4] mm: add NR_SECONDARY_PAGETABLE to count secondary page table uses. To: Sean Christopherson Cc: Tejun Heo , Johannes Weiner , Zefan Li , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Oliver Upton , Huang@google.com, Shaoqin , Cgroups , Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Linux-MM 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, T_SCC_BODY_TEXT_LINE,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 Thanks for taking another look at this! On Thu, Jul 7, 2022 at 1:59 PM Sean Christopherson wrote: > > On Tue, Jun 28, 2022, Yosry Ahmed wrote: > > We keep track of several kernel memory stats (total kernel memory, page > > tables, stack, vmalloc, etc) on multiple levels (global, per-node, > > per-memcg, etc). These stats give insights to users to how much memory > > is used by the kernel and for what purposes. > > > > Currently, memory used by kvm mmu is not accounted in any of those > > Nit, capitalize KVM (mainly to be consistent). > > > @@ -1085,6 +1086,9 @@ KernelStack > > Memory consumed by the kernel stacks of all tasks > > PageTables > > Memory consumed by userspace page tables > > +SecPageTables > > + Memory consumed by secondary page tables, this currently > > + currently includes KVM mmu allocations on x86 and arm64. > > Nit, this line has a tab instead of eight spaces. Not sure if it actually matters, > there are plenty of tabs elsewhere in the file, but all the entries in this block > use only spaces. > Will fix it. > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > > index aab70355d64f3..13190d298c986 100644 > > --- a/include/linux/mmzone.h > > +++ b/include/linux/mmzone.h > > @@ -216,6 +216,7 @@ enum node_stat_item { > > NR_KERNEL_SCS_KB, /* measured in KiB */ > > #endif > > NR_PAGETABLE, /* used for pagetables */ > > + NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. kvm shadow pagetables */ > > Nit, s/kvm/KVM, and drop the "shadow", which might be misinterpreted as saying KVM > pagetables are only accounted when KVM is using shadow paging. KVM's usage of "shadow" > is messy, so I totally understand why you included it, but in this case it's unnecessary > and potentially confusing. > > And finally, something that's not a nit. Should this be wrapped with CONFIG_KVM > (using IS_ENABLED() because KVM can be built as a module)? That could be removed > if another non-KVM secondary MMU user comes along, but until then, #ifdeffery for > stats the depend on a single feature seems to be the status quo for this code. > I will #ifdef the stat, but I will emphasize in the docs that is currently *only* used for KVM so that it makes sense if users without KVM don't see the stat at all. I will also remove the stat from show_free_areas() in mm/page_alloc.c as it seems like none of the #ifdefed stats show up there. > > #ifdef CONFIG_SWAP > > NR_SWAPCACHE, > > #endif