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 33555ECAAD6 for ; Fri, 26 Aug 2022 20:20:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39CD86B0073; Fri, 26 Aug 2022 16:20:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34B15940007; Fri, 26 Aug 2022 16:20:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23B936B0075; Fri, 26 Aug 2022 16:20:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 15E936B0073 for ; Fri, 26 Aug 2022 16:20:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DBB8CAB645 for ; Fri, 26 Aug 2022 20:20:05 +0000 (UTC) X-FDA: 79842860370.25.03E8490 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf15.hostedemail.com (Postfix) with ESMTP id 85FE0A0029 for ; Fri, 26 Aug 2022 20:20:05 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id z187so2533087pfb.12 for ; Fri, 26 Aug 2022 13:20:05 -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=Yy3h91/LZL0yMN3Y+gPnYCc8uzqqu6+PEMw/uYOkvrQ=; b=QI2iqRq9/94E6zl7r9mZw4F+7Daqhq8WErAzs7MCXRZvrz4GpEbY7Dstc+ZZ2JEyb2 q0xcA8xKqPk01eYmQLRlBIm9I9enL9gle1pvxTgv3hEVqdUw5C4cSi7lwuKtIjcxf5KZ MNemfeMqo0zzfRvxEdPkaXJq+V0CXBJoNhrKZhmH2a/6fEvyddf2Pci6F7c3hz5Uh2KZ p9XfmAZB3QDZNhI51WLuUsrX5a34H43X0h0MgNESMM7lb3mZRO5lRiW8QfXtTjK0Iio8 Bx/faeNKIHAHpdLZt2Qt47/Jnw19TxwGoB6eZJ5V4qbulyod0s+zhEZ6nWzqexbUBQl1 6MGQ== 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=Yy3h91/LZL0yMN3Y+gPnYCc8uzqqu6+PEMw/uYOkvrQ=; b=fSDeZg6p2JX67NNgedxPrXnZOcxVsErnq9v5HunVW1PGS++/U7xXS+kt9j9vZzs5dT 4t88GPGnWLE6b1m616sWsiE+ZJTenAjlEP1Lmaz69sUnw7ED882vt206rKLevcScdmP5 C7efPfKrxTrbMFZyd4LptshpqBRg6P6NeZG+alRhc0BQ1VYyYXxOlKlkn9M4V45dx7p4 Ph6cBcfG+KONJQOzY1EqH/hkhZbgFZ6+yE6+gZL0nTYOknUH/jHD9da7xaXF7TkQwpR7 ldbEYvAl558iYc51pVDGyc8ZRxbF7GB4x58nsnxKcVJQcJKOiuWImls2QSrppx2IdAco niYA== X-Gm-Message-State: ACgBeo2L8erfPwRLvF+GNylb6bAMDJudgL5Fk2TcOYPQPWVansE4Mz08 oOopUH5B6qHg9DK5L3udKAbejw== X-Google-Smtp-Source: AA6agR5n02jhbK1nhPu/jZhpJFX2d1euSOaYUkGIxcjNNi+QlVmGNtQ1h1+3uTxVaQGYEwd8dNh3mw== X-Received: by 2002:a05:6a00:4147:b0:52e:2d56:17c8 with SMTP id bv7-20020a056a00414700b0052e2d5617c8mr5478964pfb.51.1661545204289; Fri, 26 Aug 2022 13:20:04 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id x21-20020a63f715000000b0042b117e8bf8sm1843703pgh.23.2022.08.26.13.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 13:20:03 -0700 (PDT) Date: Fri, 26 Aug 2022 20:20:00 +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: <20220823004639.2387269-4-yosryahmed@google.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661545205; a=rsa-sha256; cv=none; b=P7iuRGq0oHBQm4g1i13AsPuGowsJ25oG4gorC1VnrsK+OL8J3yKJKyPWnH5zT/do8WZxgg bKPX7ENCZcmlquJDLra3ZVn7R7FLRmDaLCDrDZqX88ZvnldEL5ANUTnbChN1mDGXt7rUvE zK4ExSL6YfP1hF8IHrsVgSJOe/X2rdU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QI2iqRq9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of seanjc@google.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=seanjc@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661545205; 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=Yy3h91/LZL0yMN3Y+gPnYCc8uzqqu6+PEMw/uYOkvrQ=; b=ZZ+HbCiMxYQSEL67Nbl+0rsDr1q9PhUL0ghcXPzqaT6cqzRSStSlGfN5flnly3HmjU2VOD ma3J7LsysGwBiEjTipMNpB6eXa1FNpXcrzLavQxhna+zqV1zc+Fkbyv1FUlBFWOfkIkHFr 1nSK6rJe2bPB72qjToCToqR5imFwfNc= X-Rspamd-Queue-Id: 85FE0A0029 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QI2iqRq9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of seanjc@google.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=seanjc@google.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: 7ydk5q94dia7fxb8pxem3j5uwmftictc X-HE-Tag: 1661545205-701536 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 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?