Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp147263imw; Tue, 12 Jul 2022 16:29:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u5KchcixcFSWbVVinfFpqht3+RteZrj3RiCOTmgQCd+oGBElsE7hd3NbfkrC3PFamJN8P3 X-Received: by 2002:a17:907:7f1a:b0:726:2b37:7b82 with SMTP id qf26-20020a1709077f1a00b007262b377b82mr553250ejc.366.1657668571322; Tue, 12 Jul 2022 16:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657668571; cv=none; d=google.com; s=arc-20160816; b=food4gfTXhARVIQdndR68Vq9SJbr8x463KSiSIK+sHzGECm1VMoya6MBMIbQAeg8xY r95X1iPkHDWpzUh39F72rMzvVz54E+qgRaPgPEMmcdhOY3Yg6LQWCsiAhuwdWUiuF9u8 PK4eYSA0KmRpxD3RkLFS8a1TXAv8Cu0RRfL/zuXrQbhSo37RreUSrj1NBYdcKBhdTk7n fs+i164wlreoU6g+J9oSM/3ROjKlEx4FErczpfWwr4zQtS85dXWBdbhx45c4nIH/tYNd UpckrNCSREMokQQHn6tap99R9PqimBXJEqZxzz+2IJ//68Z7SScDHTWJVpEXIJG60YI/ UL4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0kilpuaWkkH1jWKZwcnpv75y3bBAyVMGJWLT8pq7Zew=; b=DtMO4MVt/vwc4kX/Epoa8wE/BphNoEoaYXXB3/PuN5ZLz6254y39y6FNbncxhl7iUv eM7SNMJfgofoY2w6/Yoca0RpqUemuUPhjJ0Oj5jhz2ukubkxsjvcURCqOOXslcc3NwUe cREMqJXk7G9vMYNqrkuL9QYxQTGQ6N/jBICnmy55iz7Ot6PSY//JI8p/AE4Wx55n0e0e kDxHfZGmN/hhHXfTIZ1Zs9fXT52gowgE8oLvBrNO+3wmNXr78F5QnSUe+I2Hk+5E/FVV 42lSlHKeYC4qrCDzTRiansF4dRd4HBce1N5gFfLqUUSrU8R+D/fNv1P447aMBdgzC5QZ etUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZBE5KGyR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id um9-20020a170906cf8900b007269a9c3019si2126184ejb.818.2022.07.12.16.28.47; Tue, 12 Jul 2022 16:29:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZBE5KGyR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233824AbiGLXER (ORCPT + 99 others); Tue, 12 Jul 2022 19:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbiGLXEP (ORCPT ); Tue, 12 Jul 2022 19:04:15 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBBE2CDC2 for ; Tue, 12 Jul 2022 16:04:14 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-10c0d96953fso12210825fac.0 for ; Tue, 12 Jul 2022 16:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0kilpuaWkkH1jWKZwcnpv75y3bBAyVMGJWLT8pq7Zew=; b=ZBE5KGyRMkxibp5iaQK1l2yLFQs3jMAWpu5gwk0mkKX4ubei8nAy3KENVxr6zAoHjv GxxAukLzTPcow4xb39vYwDGdcaSRPa60fmvrQz7t5M+INg1M5ckPSC915vA9q2vN94AD /SGqziGRgsU+lRLMnfhy3E5QN+LwNKSm54tmpu0mNnq5YnUHuf05goqCVAxNqaaAiN6B kCkPthpHgFI7wBZw9z3V/ubta+xmhbhQHRM/O5EcP+46woLYQpwn+fg2Dj/B6KQdkz8q cxYdjJT7Re3j22yGvnr+ktEYQOKJ6wkxisMXfv/a2tIwVaodgTZvM0zkiXaKA3U/CSDX wuPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0kilpuaWkkH1jWKZwcnpv75y3bBAyVMGJWLT8pq7Zew=; b=ypJlHlv4jzwBXd/zPwd56mDGZHRZ7rQTHY2u56/yAh7IGgL6NFtCmRuVIfj+YY4iox O7/do1rrjAzg+nK1UJpJlnJkQWLs3R8TSYiNJIxwks+UN/gAaGsJPtggQpt0yWmcuTx4 2hZwKE+fMkxCRV1heR97lZJ54vPYCTPE2lUpX9DrkysYrlbTdDeyY4ZSzpo6nekv/vhJ fycis+PH3VbbTLvXWSYAB6NgQSjGxjSI44qcp0me5xjTdvN/TtbuEJD/ZvVNCG4NahkG YEK5Lm75A73IubFydggyBes+juFjuhsyBSFRMIpti9YEezZ7j89yxZSCIM9693nZxCCj dXJw== X-Gm-Message-State: AJIora/RyNHfcrg1ed2YxvcywHCvwDHvHiljZiqTJfsqb4Lh7F4/TEsB DpWd5zFaYYs+fvJK1uhVTEVs07QghHD5kTwqGfl/rQ== X-Received: by 2002:a05:6870:d349:b0:f5:e9ea:5200 with SMTP id h9-20020a056870d34900b000f5e9ea5200mr3194460oag.235.1657667052905; Tue, 12 Jul 2022 16:04:12 -0700 (PDT) MIME-Version: 1.0 References: <20220628220938.3657876-1-yosryahmed@google.com> <20220628220938.3657876-3-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 12 Jul 2022 16:03:37 -0700 Message-ID: Subject: Re: [PATCH v6 2/4] KVM: mmu: add a helper to account memory used by KVM MMU. 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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 7, 2022 at 2:08 PM Sean Christopherson wrote: > > On Tue, Jun 28, 2022, Yosry Ahmed wrote: > > Add a helper to account pages used by KVM for page tables in memory > > secondary pagetable stats. This function will be used by subsequent > > patches in different archs. > > > > Signed-off-by: Yosry Ahmed > > --- > > include/linux/kvm_host.h | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 3b40f8d68fbb1..032821d77e920 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -2241,6 +2241,16 @@ static inline void kvm_handle_signal_exit(struct kvm_vcpu *vcpu) > > } > > #endif /* CONFIG_KVM_XFER_TO_GUEST_WORK */ > > > > +/* > > + * If more than one page is being (un)accounted, @virt must be the address of > > + * the first page of a block of pages what were allocated together (i.e > > + * accounted together). > > Sorry for the belated thoughts... > > If you spin a v7, can you add a note to call out that mod_lruvec_page_state() is > itself thread-safe? Caught my eye because the TDP MMU usage happens while holding > mmu_lock for read. > Sure! I will send a v7 anyway to address the comments on patch 1. Thanks! > > + */ > > +static inline void kvm_account_pgtable_pages(void *virt, int nr) > > +{ > > + mod_lruvec_page_state(virt_to_page(virt), NR_SECONDARY_PAGETABLE, nr); > > +} > > + > > /* > > * This defines how many reserved entries we want to keep before we > > * kick the vcpu to the userspace to avoid dirty ring full. This > > -- > > 2.37.0.rc0.161.g10f37bed90-goog > >