From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Subject: Re: [PATCH v7 3/4] KVM: x86/mmu: count KVM mmu usage in secondary pagetable stats. Date: Tue, 30 Aug 2022 21:52:33 +0000 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-Transfer-Encoding: 7bit Return-path: 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== Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu To: Yosry Ahmed Cc: Wanpeng Li , kvm@vger.kernel.org, Roman Gushchin , Michal Hocko , Shaoqin , linux-mm@kvack.org, Zefan Li , kvmarm@lists.cs.columbia.edu, Marc Zyngier , Joerg Roedel , Shakeel Butt , cgroups@vger.kernel.org, Huang@google.com, linux-arm-kernel@lists.infradead.org, Jim Mattson , Andrew Morton , linux-kernel@vger.kernel.org, Johannes Weiner , Tejun Heo , Paolo Bonzini , Vitaly Kuznetsov 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. 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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E972ECAAA1 for ; Tue, 30 Aug 2022 21:52:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 555BA4B931; Tue, 30 Aug 2022 17:52:43 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tAaBSPQ1p92t; Tue, 30 Aug 2022 17:52:42 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2A0D24B8B7; Tue, 30 Aug 2022 17:52:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9732D4B8B5 for ; Tue, 30 Aug 2022 17:52:40 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G+Hu6S-Gw7f3 for ; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 1FC984B8AE for ; Tue, 30 Aug 2022 17:52:39 -0400 (EDT) Received: by mail-pg1-f171.google.com with SMTP id r22so11843474pgm.5 for ; Tue, 30 Aug 2022 14:52:39 -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=k2Q62d2pfHx5EQ07JjYhAuxm+1/5I/rLyzGm4XmtOD+C7hPXIUc+mQr7UdQgEqYRjo Y+YqHm0Rs+gLEpUMvAIUuRoAqj59bXnbleRVPJSc3G9TrpwHeVn+cZDJYAl0G4tPMjcI le/VYoeSS5ZP3rDIZWYTq4uwjI1q7w2PgyDNVFLDwzLEMW6/L8iYiW4vnacDVmuKLCVI 1Qme64vTa9IYUiVb+WyOP9CoEeZxVUsadCwHLlj/F79cdCN3wn9YvecEUrRNlzuNqlFD wN5zLhyF5WXAGmIVdg29I+AMmcBs7IDPBXc/K6yAx4Wb5T6Z4HkvokxsMPiBqh5h8CLz Vykg== X-Gm-Message-State: ACgBeo2YtaPfsfV3vKefJ8dVGskia5lDanMMThdqU0E/9m0z3ASQ3Gfx zHKnHYIQuojtgCawVkTCtyHRMQ== 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 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-Disposition: inline In-Reply-To: Cc: Wanpeng Li , kvm@vger.kernel.org, Roman Gushchin , Michal Hocko , Shaoqin , linux-mm@kvack.org, Zefan Li , kvmarm@lists.cs.columbia.edu, Marc Zyngier , Joerg Roedel , Shakeel Butt , cgroups@vger.kernel.org, Huang@google.com, linux-arm-kernel@lists.infradead.org, Jim Mattson , Andrew Morton , linux-kernel@vger.kernel.org, Johannes Weiner , Tejun Heo , Paolo Bonzini , Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CE85ECAAD5 for ; Tue, 30 Aug 2022 21:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rtOeoEua7MwkURT/raURrSBLnu9/ddmNSk/9USXHbzc=; b=FJwNFu+apA92NG /zsQSpU6dKYC5gDa6nQjUEzGpT0ueiOu2jUeAY0cy1ExopdvMtAwj7gMxemCf0KO3zp4Ajisv3Q1K 9XksFD7DHC0Bj9vZ4sA1OZ936epTwBnrkWbM9OINjoHqsLx5qXCyHwUfQZ6w/EU7fOpOBwgXpo92W pcYEWUTQoHx8EhtfFRCeW5WYn/67bvQFI7aU41DsK5aMm5KemBFWVV479sPSwmoRZhN5Oi4vE+1Ec 0MfomPf02XcRxDvaqkeHIln+dqMPEPXGDoDVIlrg1cEW96GYl7ePIrAbwfHNXRdElmpUDiAgNuA9I zlzWJTiDi68qIbf0aEqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT9A5-002919-R9; Tue, 30 Aug 2022 21:52:45 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT9A2-0028zL-6e for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 21:52:43 +0000 Received: by mail-pf1-x431.google.com with SMTP id z187so12626096pfb.12 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=l5B/CD1cIX5ry+nELowrAXYZvrTxc6KWpXhN/rwMibFDHSd8U3HCYhz7hlFYC8LKl0 tVnu0GZrrP26hagvVK8zlb2CBOFGNAW/YT+Zi+k6bWd35LngtQA/YG+6gtVrQ21aS8xw ceacIR4yjpNjeQDZDGqsmfNQ8UoooUEp7vvcyxOTsHapo1Hr+1xfdRmNFsUOu9Np62Jh iitRGBVPlOMDHBhzHSknH3n9xrfDrpvqdnNqwH9+euzqad9aLuiSAlKubPacZKalMLwT uqX5cMpE4dyAhZh5ABfTF6oGWxO8hIU7Mla6QIrBUEnxraWO8pfxNVQN3LHC6McDmAXG VW3g== X-Gm-Message-State: ACgBeo00G2jFT3vyuvJZb94R3FWy/ZESA1mw0Xq0TIIuGPVIEIj4bN7d i+6Pr+z1xAFUkDqvoB8Xm4GVXA== 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_145242_264406_72638209 X-CRM114-Status: GOOD ( 26.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4561EECAAA1 for ; Tue, 30 Aug 2022 21:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbiH3V5g (ORCPT ); Tue, 30 Aug 2022 17:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbiH3V5N (ORCPT ); Tue, 30 Aug 2022 17:57:13 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37B69E11C for ; Tue, 30 Aug 2022 14:52:57 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id bh13so11848303pgb.4 for ; Tue, 30 Aug 2022 14:52:57 -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=DVEWf9hQI6LkcZ77UI7cPF32MeetMfGTFH3czO99B1XfsEYgmMlTqah5Dq39Dp9NKb 4tlRI+LGdVBSS0xSHG1sCYTqppmTSHkmM7Rxdqq1Yz9kmJ75CWfzBmnkry0m41yv/+tw kdz6YGDPfj7iDkKQeh11lwujJZtp++3FMEwr00aI1q58Mjjf0q/aN73n4HstBnVcTWAu 4ToOhUs+6J16ZaLky7zrfcCovS72h3+CEPeYTiaTH6R4Wyx7a1BRl2n78tvWcA3IhI1Y LwmbnFNYiezBi1Ruj5tHdC6gJ4pMjERfNTUk7YFl0gKlNy4kBlbYuC08NDghxKe14lT/ D9kg== X-Gm-Message-State: ACgBeo31qLHSr3I2RtL0fXLI37jknKuoQDxbFzwIvMFUWDe71rezxwgl M830s8gzob8EcysbJCJVjuh8tg== 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: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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.