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 73C7AC0502A for ; Fri, 26 Aug 2022 21:26:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0038940008; Fri, 26 Aug 2022 17:26:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAEC7940007; Fri, 26 Aug 2022 17:26:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D76B7940008; Fri, 26 Aug 2022 17:26:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C4030940007 for ; Fri, 26 Aug 2022 17:26:10 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8D5D4AB3AE for ; Fri, 26 Aug 2022 21:26:10 +0000 (UTC) X-FDA: 79843026900.31.0F2AC84 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by imf12.hostedemail.com (Postfix) with ESMTP id 5049E40009 for ; Fri, 26 Aug 2022 21:26:10 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id e20so3166383wri.13 for ; Fri, 26 Aug 2022 14:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=6UsE1Ljxz5h0xq3FFSdwmgCBOa2/vJlV8vw/uQpbLSQ=; b=SWFjPL7/UKZ4cZdo+JI7Bm2LG8Zc5kFuduxCLX8+HwW0QibBTetn/y2E41mk+x5paO JIzNbPVmE/Ekp/CzgnD2lphM56nu+cGQgvXiZ7OsW7wiDezSmmZwBWSBekAXujhOa0V0 A/+blidel2lSXN57C4fj+Mly1CkPB7JfH8fuOLQhwEdLJ5xIgzgdP41dV/v/Oq6fs9v0 LJnhM8cgZlGCe5bOOQ2JX0Rjt2uG1lGNw0/ekwO8fuwTjSJ6hE1BnAi1yzYcJ9yAPRpa cvbehGZsoN5xor3oKmd+C683+iy9LUhdk3WtP7wGbPJfzVQ4Bu4/vzWsAhyUKcA6bwn9 MK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=6UsE1Ljxz5h0xq3FFSdwmgCBOa2/vJlV8vw/uQpbLSQ=; b=aHvH0iErwgSOXsyy0Bxxv7Ih/LTvSi0wN/SJ+RqMy+bhWkFt1PRLOn3++SvkC67LLD 7cyqe5rphx9k1Lf9sq8lsLBdMWBrSNaNw6IDXjg/kiGiJBpCksC7LBEKqcOcerymGzAd S59pC16m53qTz3hQEqy8JVloFsNDp2YywtyVTGrsVk4/68ZoTTi1OW8kSwqyLOFucQKL IYWlsKqvploSwSulpcouJOf0VIdCIGx1FKd9GhuxWw2yfZx0HUzaYDkZN53/mPUFXlIN 3wf7qfa/P6+hUEp3I0kHPwqM+nb6LWGo8/2QkS2X24F/uhMNCIinQQizYtHOmEGCrIsJ Atxg== X-Gm-Message-State: ACgBeo2luyajFvTYZjeriIwVP2Plbl1gFrwowvEZe0w+ei9Bs8us4agP 0CWIaL7ZfYKfE378YmVGpLsRaG1J+S5v1DRnB40QsA== X-Google-Smtp-Source: AA6agR4Hp1hENOCVVKgBgmda4N9xAiLK7ePDAp+2BKobakE/3YgGIHlFS8hcVYDNGA2YUpMSmk/d68XvTzxr+wDrl7o= X-Received: by 2002:a5d:6d0c:0:b0:225:4ff9:7e67 with SMTP id e12-20020a5d6d0c000000b002254ff97e67mr776077wrq.534.1661549168831; Fri, 26 Aug 2022 14:26:08 -0700 (PDT) MIME-Version: 1.0 References: <20220823004639.2387269-1-yosryahmed@google.com> <20220823004639.2387269-4-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 26 Aug 2022 14:25:32 -0700 Message-ID: Subject: Re: [PATCH v7 3/4] KVM: x86/mmu: count KVM mmu usage in secondary pagetable stats. 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661549170; a=rsa-sha256; cv=none; b=C9yQyIxExKdGX/7rEp+iSaFX4BZqsyPZeQQ4VL+pAUyTXxWQ2qIgA7jjMKNY1tKfXRa0jt T+OkJPwShj3sV8s7+p2DRcBVLLqiSf2tp88NKXpAVAzEvr6qvyoyqFo7tu9j+bVcr0RGfk lZ45fUowREHeIt7qN67gENfjmhNMOug= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="SWFjPL7/"; spf=pass (imf12.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661549170; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6UsE1Ljxz5h0xq3FFSdwmgCBOa2/vJlV8vw/uQpbLSQ=; b=7ldD59uuPQW4Lu3mMiKIUP1/9V4WjdPBorzyuZH9KShsYcJNeUmbWfSggNZfAyLtfv5MZN pzZgigHVYbZL7JrBGuwO5Zwa3al+Uj9kNXydR64/Tr1GPW8d1QjPuiejkZWDannU0gzjtM dMPAqB7K49pro4kerrFF4sIY/mwVz0A= X-Stat-Signature: zw11ytxxziz6q3ken3ih8k1c84f85u3x X-Rspamd-Queue-Id: 5049E40009 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="SWFjPL7/"; spf=pass (imf12.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1661549170-644789 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 Fri, Aug 26, 2022 at 1:20 PM Sean Christopherson wrote: > > On Tue, Aug 23, 2022, Yosry Ahmed wrote: > > Count the pages used by KVM mmu on x86 in memory stats under secondary > > pagetable stats (e.g. "SecPageTables" in /proc/meminfo) to give better > > visibility into the memory consumption of KVM mmu in a similar way to > > how normal user page tables are accounted. > > > > Signed-off-by: Yosry Ahmed > > Reviewed-by: Sean Christopherson > > --- > > arch/x86/kvm/mmu/mmu.c | 16 ++++++++++++++-- > > arch/x86/kvm/mmu/tdp_mmu.c | 12 ++++++++++++ > > 2 files changed, 26 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index e418ef3ecfcb..4d38e4eba772 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -1665,6 +1665,18 @@ static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, long nr) > > percpu_counter_add(&kvm_total_used_mmu_pages, nr); > > } > > > > +static void kvm_account_mmu_page(struct kvm *kvm, struct kvm_mmu_page *sp) > > +{ > > + kvm_mod_used_mmu_pages(kvm, +1); > > + kvm_account_pgtable_pages((void *)sp->spt, +1); > > +} > > + > > +static void kvm_unaccount_mmu_page(struct kvm *kvm, struct kvm_mmu_page *sp) > > +{ > > + kvm_mod_used_mmu_pages(kvm, -1); > > + kvm_account_pgtable_pages((void *)sp->spt, -1); > > +} > > Hrm, this is causing build on x86 issues for me. AFAICT, modpost doesn't detect > that this creates a new module dependency on __mod_lruvec_page_state() and so doesn't > refresh vmlinux.symvers. > > ERROR: modpost: "__mod_lruvec_page_state" [arch/x86/kvm/kvm.ko] undefined! > make[2]: *** [scripts/Makefile.modpost:128: modules-only.symvers] Error 1 > make[1]: *** [Makefile:1769: modules] Error 2 > make[1]: *** Waiting for unfinished jobs.... > Kernel: arch/x86/boot/bzImage is ready (#128) > make[1]: Leaving directory '/usr/local/google/home/seanjc/build/kernel/vm' > make: *** [Makefile:222: __sub-make] Error 2 > > Both gcc and clang yield the same behavior, so I doubt it's the compiler doing > something odd. Cleaning the build makes the problem go away, but that's a poor > band-aid. > > If I squash this with the prior patch that adds kvm_account_pgtable_pages() to > kvm_host.h, modpost detects the need to refresh and all is well. > > Given that ARM doesn't support building KVM as a module, i.e. can't run afoul > of whatever modpost weirdness I'm hitting, I'm inclined to squash this with the > previous patch and punt on the modpost issue so that we can get this merged. > > Any objections? Or thoughts on what's going wrong? I am not familiar at all with modpost so I have no idea what's going wrong, but I have no problem with squashing the patches if you think this works best.