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 F009DECAAD4 for ; Tue, 30 Aug 2022 23:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77FBB6B0071; Tue, 30 Aug 2022 19:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72DE76B0072; Tue, 30 Aug 2022 19:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CEB98D0001; Tue, 30 Aug 2022 19:48:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4D3C06B0071 for ; Tue, 30 Aug 2022 19:48:51 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 16D17C0C1B for ; Tue, 30 Aug 2022 23:48:51 +0000 (UTC) X-FDA: 79857901662.17.E6A7062 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by imf09.hostedemail.com (Postfix) with ESMTP id A665514004C for ; Tue, 30 Aug 2022 23:48:50 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id s23so6521716wmj.4 for ; Tue, 30 Aug 2022 16:48:50 -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=tGVEnlLMpBamjr5zlczXq7fmwaznwoQ3idHABhgUuYM=; b=KO+U0jA43GLZcwdXeyIX5nApqOewvbCN/kEwEioSXyjvoFoRRmxVAcOEse3v+CVhbj jLnHHxVADcF5HhHRpQWGwFrUyrKwk/ndVvQHr5H0dAMUG9zgcyZoOT4OnkbuHncsWNgp IkNnbqP9J0Dxp7txF3JCyMDpfIQ1B2h7kA+vEyRJqPQlMXi0WVQapPgKkZ3OF2ek4sMn p7/0r48ezijpvcOm73x2lrXy/ZNJIVDm0GMPqolOSYldXS2Sms+cdrIs9fxhD8wqcVvN GHItupLX5AYb2kO185XF6k+WC4V1D2cTOf9gvnN9lUQf3v7aPT+RAye8vYV/E7rrdfK6 dVeA== 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=tGVEnlLMpBamjr5zlczXq7fmwaznwoQ3idHABhgUuYM=; b=vlemrWbI9ewhe/6tbbEOYQdS3KI7sSuDEI1f6MdBuEp0nGzwpG63A05rGHanAR39OC J7BQ9vWdDcQMfN4u+DHQJzr0oWJcq7qQ5Bcydi+RKBuLLlzfsVYCxr3IdijCSL95QOpO kQxZxGrgPRkLVReSqHE9KNzzNFBUDPfxrHwEZ8MwP7RT5RuYZlS1e8ES4HPFRlMnpsyP /jLgURtH+dYPiGr19TMFp+Lc7F4C15tb5AkxXBl+jzsi+Y3Vl2lHNC3kmJJLslKvhYa/ EpO1E/TXP/xjgAobl1kIqK5IiPO9k1W6HX2OAPF6CAAaC1rS3OXgj/kqRRjeMMpbCNmm DH3A== X-Gm-Message-State: ACgBeo33NsOtqor9aDiAWp6sfJ/NMeNgXY/uBKtZ7xSH1x1TpHbD226g 0qGX56Uer0xPylrsC9jF6h943/MaHwpYVJ8KAMRzlA== X-Google-Smtp-Source: AA6agR7kuj8FMBlUqHe1KsZByANta0qdtZ6dMTJPpi0P8kKLcTUdSOfhQ26jHFWjNyun/bjf1Y0GHPcdkLlVKxphkH4= X-Received: by 2002:a05:600c:1e05:b0:3a5:b441:e9c with SMTP id ay5-20020a05600c1e0500b003a5b4410e9cmr231944wmb.24.1661903329205; Tue, 30 Aug 2022 16:48:49 -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: Tue, 30 Aug 2022 16:48:12 -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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661903330; 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=tGVEnlLMpBamjr5zlczXq7fmwaznwoQ3idHABhgUuYM=; b=gRWUJ+2Oz/IT+Fkzy9tjqU9INx6u2edoNiAdpRQI79AdzJICg9eEpP3Ie3UgwuqpKC4dEn TqvJT+Ck0TQ+eGdsxcoVmwtcS8f5rqmxZMUD7ANEnIjAPgYgC3ubU1CnrU+ExFsnO3JyYj buQuQCIBhVL/JIOpRIyVWQ5rNf7bOLw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=KO+U0jA4; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661903330; a=rsa-sha256; cv=none; b=Fu8LSmSj/MqcF7yS7bES5A2omJ2rdfELFlFsnFLfJyzro8XNd3MJ9NDyMRd/7c6aQwamOS X+2TGbhE4wOQS5avEftNfXVABdsIOvwVxgdZYoPyB7TU9Mthn3d78NOxuwez6vvjldo++Z rKbAw0uEtlAiPi2FuTUHet6UGqNQu3k= Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=KO+U0jA4; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: gstfrnkpg1b7jfpuj96kfs5hpfjqyt7y X-Rspamd-Queue-Id: A665514004C X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1661903330-87953 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, Aug 30, 2022 at 2:52 PM Sean Christopherson wrote: > > On Fri, Aug 26, 2022, 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? > > Pushed the series with the squash to branch `for_paolo/6.1` at: > Thanks Sean! > https://github.com/sean-jc/linux.git > > Unless you hear otherwise, it will make its way to kvm/queue "soon". > > Please yell if there are objections.