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 1A81EECAAA1 for ; Tue, 30 Aug 2022 21:52:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B2F28D0018; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 862548D0001; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 729978D0018; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 64B908D0001 for ; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4D89940CCB for ; Tue, 30 Aug 2022 21:52:39 +0000 (UTC) X-FDA: 79857608838.27.BB1E7F3 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf14.hostedemail.com (Postfix) with ESMTP id E41A5100013 for ; Tue, 30 Aug 2022 21:52:38 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 73so3488401pga.1 for ; Tue, 30 Aug 2022 14:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=kmi765rhdWrzQirlOzDuA6v2AsLs7icy29dLcvjyZaY=; b=hWJ7zNlkecdEXTrVZ6wmkEknTN/2exZUrz57/hU7W4XRQNtZqa+j7DxnleUp3IhKBb sPjQfJCIpekxST95aTOvA6LRmjGl/9uM3t36fhzVjmgsHhFGbG/O8T0o1vgEyeLA5C0I EFGHin0OUfFk0fiXENOHWlBqiA7nVmwWjwoJSedO1iB8vWSr7VHZW2nPJIXqSCBO/+pl sOwVvJuTcV0RbXyJlpScwEsj8aMQTbBVhWXan+gXoZK5KecfX5JTb9nvfZqtbC+UjDPf k0jWJ+//LY8Te/xXhINDpZFf2p1eG1WkkfXxk1m7qr7C9e/izZw1Pye0n6Us513YUn22 Sv0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=kmi765rhdWrzQirlOzDuA6v2AsLs7icy29dLcvjyZaY=; b=mipQISywj+MaTk/TGV6NeN6LO/aD896vVAEITNsBSW51MiD/ba6a/VL4LLkeWDoEvh JJhgGeZaATe3sCUn7DkTnHQoB9iTjg1vvId5Pkxb9rPDSshowiJDtHsWpg1daJD2CC4I 3JTq5JLdKfih7Jlz1OLCQ3y39sO8aSjQMLz8T5WtQqi/+t1GuZ7QHV2Kg6tzx/xEdCjY X9NWYODDSm0ecXZGw4yyu88ud/PrFcGgiDuyR6jfUMkMRN/4qACor9qnPz8ZAE6XFla5 q2A0Bawqlzkx7biAEILK+qxy7Dc7vCo30Xhlvy72bYTpwOPdarcPCwl9fNt4xsNLrIST H9rw== X-Gm-Message-State: ACgBeo1hVo53cCGl0W61t6K9VTaf6GZcbLTe8B8XfImI95QpXz6U8bcI Kal5MaHYcCYwwJWX3sQMvH0fkQ== X-Google-Smtp-Source: AA6agR6asL5tWEMD9qdeUkMoP6zzYNAqZvPkbIyCF6qv1uEQUKWXuBujKh4awFSCPYR/F9Y2M19nxA== X-Received: by 2002:aa7:8742:0:b0:537:ee75:601a with SMTP id g2-20020aa78742000000b00537ee75601amr17381844pfo.37.1661896357847; Tue, 30 Aug 2022 14:52:37 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id k6-20020a170902ce0600b0015e8d4eb1dbsm10181118plg.37.2022.08.30.14.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 14:52:37 -0700 (PDT) Date: Tue, 30 Aug 2022 21:52:33 +0000 From: Sean Christopherson To: Yosry Ahmed 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@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v7 3/4] KVM: x86/mmu: count KVM mmu usage in secondary pagetable stats. Message-ID: References: <20220823004639.2387269-1-yosryahmed@google.com> <20220823004639.2387269-4-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hWJ7zNlk; spf=pass (imf14.hostedemail.com: domain of seanjc@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661896358; a=rsa-sha256; cv=none; b=lLdKdhmegcAIE083h1D7v1Jrywa1Qg9tT+cH8c9M7vWYQ4PjOPKOXaIjemEgkq35V1Bfgi fzF3AmhN9KVOHYou3sUpCOtq1JD2TlHgz52Z+rg4yeOLTfhUDohuX6lDpzScfdLjoyfSjc MnH22S2FMvVmrTKKbkwmTNmc7vfLZyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661896358; 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=kmi765rhdWrzQirlOzDuA6v2AsLs7icy29dLcvjyZaY=; b=6fFUoHkhz55KzxZaeRDJ17Yy8jrGXxGbVMD3BObljsyPLO7myCtf1N2Fy2cWD0i5eDnJ92 KrH6zjHp3IhAG6YgUDisWTELdeWkpf52G6M8JMEefTVE3XjEPppRsZXzRLhjmQVkq1OLzm xsuJbrVbcma5/q2QxP3jMfb28QxKBEE= X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hWJ7zNlk; spf=pass (imf14.hostedemail.com: domain of seanjc@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-Stat-Signature: uo1sjckdo8h4ddwou5ixi9w7xqjtqphf X-Rspamd-Queue-Id: E41A5100013 X-HE-Tag: 1661896358-104451 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, 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: 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.