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 5070DC433EF for ; Thu, 30 Jun 2022 21:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9DBC8E0002; Thu, 30 Jun 2022 17:02:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B26168E0001; Thu, 30 Jun 2022 17:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C8298E0002; Thu, 30 Jun 2022 17:02:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 871408E0001 for ; Thu, 30 Jun 2022 17:02:31 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 580D012132F for ; Thu, 30 Jun 2022 21:02:31 +0000 (UTC) X-FDA: 79636125702.18.55392AD Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf28.hostedemail.com (Postfix) with ESMTP id 03A70C0048 for ; Thu, 30 Jun 2022 21:02:30 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id o4so345231wrh.3 for ; Thu, 30 Jun 2022 14:02:30 -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=VtUlpkuhliUwoUgmaGEH+kEoEeunaS6PJnDK/W1XYz4=; b=JfrrtzAQjyLxnw8RtQ5sQiSNUfohoaMNZW2kYvifXlmGWgHr7XJMl/LQ5yWh4ZDLRh EIUPHXZDb5Va4mirbCSRVDZCPMlakbWCUXbrVx3s9CYunFEZ1slL1J+n0+lLyBmkjvq6 dywxS4/phRbyRQsua97BR94hWDn23Q49DbtcSC9+zkt3E5pfCOfz49pW3hhqdvrjGdv+ pKKf1x3hKQqAQrlbcPos/8s8jUYluEAVcvGGsPGpoOXyv0wrj0LnCa606tZy9ddxQBAt cF8lFcME2E999BhE7foEKF9XdpoRPCaTJec6Ks6Sa9LMwb5hg+yO+AGHFhUc1+iXyNs+ Ct9g== 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=VtUlpkuhliUwoUgmaGEH+kEoEeunaS6PJnDK/W1XYz4=; b=25p0OfG1g3RuWrcl9ICFHMGjq9zqQDVMr1RYE5+Fp3TyDWBTHB8eOObrIKxjst0LQl IRhk5bohvRSi0VZwk0dc/OUU5a85BViiZQ07UKtp1187D8vTGnbjOiX4gh0+ow4z3o4O jNDF2lmP8vrjx2SvR3hoBuTxBNN/4l6p8K+KuvO/p6ASFMvWm+3+bAHJ9QB70rv7jq+5 6CLORJjBRQuw8IszJWHJtqGyeAsGQy2wPQmZJkAb9iFh5vVBcKLCaKOS+gr431AVA05+ eRoc1kTS6fanJB9JJcUxwn5yvwtNCXiaBKt3ViCA2RUrZyDMB5JmYlmVn5uI/+6L6i3g hMhg== X-Gm-Message-State: AJIora993Ad/KawUNchTBLVjqVdisj3ThIKJep3e+qSL9r4lrfAXdHfx f9ch8xK9/DAhsLHvAy9RLoW0XljcBFYM/jZgNdXDCg== X-Google-Smtp-Source: AGRyM1tplZDxrLp9WaTGqMe3midVuGQbVARcYH1sMixpR7FPn6Bu0DJJ+rFZvHMXvlCiQJACUGtNy4P+3OS3+ElQNfs= X-Received: by 2002:a05:6000:a1e:b0:21b:8c8d:3cb5 with SMTP id co30-20020a0560000a1e00b0021b8c8d3cb5mr10358939wrb.372.1656622949489; Thu, 30 Jun 2022 14:02:29 -0700 (PDT) MIME-Version: 1.0 References: <20220628220938.3657876-1-yosryahmed@google.com> In-Reply-To: <20220628220938.3657876-1-yosryahmed@google.com> From: Yosry Ahmed Date: Thu, 30 Jun 2022 14:01:52 -0700 Message-ID: Subject: Re: [PATCH v6 0/4] KVM: mm: count KVM mmu usage in memory stats To: Paolo Bonzini , Andrew Morton , Marc Zyngier Cc: Huang@google.com, Tejun Heo , Shaoqin , Cgroups , Linux Kernel Mailing List , Michal Hocko , Shakeel Butt , Jim Mattson , James Morse , Joerg Roedel , Wanpeng Li , Vitaly Kuznetsov , Sean Christopherson , Alexandru Elisei , Suzuki K Poulose , Roman Gushchin , Oliver Upton , Johannes Weiner , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Linux-MM , Zefan Li 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=1656622951; 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=VtUlpkuhliUwoUgmaGEH+kEoEeunaS6PJnDK/W1XYz4=; b=NdJs0zopg5eeIBMsGSmVgdfm2EWrFrEH5vCGvgf2Qh6NySsJdifxO0BVVwV1nnTwUKSiBc f6swR2thbIWxUbWem0USPYzUP+F+bvsF3NpybXP5MRpcAak1RvxUjR7MAPQfieIAr2xljw leibTuzlZihoT/NCITIiUsSoq1O2o7A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656622951; a=rsa-sha256; cv=none; b=k7Idl3qOD9ViNTGx5MaBVaptBM15G262H9Uy5N4Uy35axq8S4v1M+CgGjLmbus9d4zK89+ Dqb8GU6b19T7bGX90ezp+CKZg2w+MPBRBsI+2XPINHZ/e4k0AtQKw8m9kvErnvk7fLQWf0 Od1vFFHdX97d0UtrisAUgdFf8kisOWQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JfrrtzAQ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=yosryahmed@google.com X-Stat-Signature: x1m981ffp7dshmjx6k3xusbyu5pco4tf X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JfrrtzAQ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=yosryahmed@google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 03A70C0048 X-HE-Tag: 1656622950-364901 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: If/when this patchset gets merged, would it be through the mm tree or kvm tree? It is based on the kvm-queue branch so I am guessing it could be easier to go through kvm but I am not sure what the policy is here. Andrew or Paolo, do you mind clarifying the policy on such patchsets? Thanks! On Tue, Jun 28, 2022 at 3:09 PM Yosry Ahmed wrote: > > Add NR_SECONDARY_PAGETABLE memory stat and use it to account KVM mmu > usage as the first type of accounted secondary page tables. This stat > can be later extended to account for other types of secondary pages > tables (e.g. iommu page tables). > > Rationale behind why this is useful and link to extended discussion in > the first patch. > > --- > > Changes in V6: > - Rebased on top of kvm/queue and fixed conflicts. > - Fixed docs spaces and tabs (Sean). > - More narrative commit logs (Sean and Oliver). > - Updated kvm_account_pgtable_pages() documentation to describe the > rules of using it more clearly (Sean). > - Collected Acks and Reviewed-by's by Shakeel and Oliver (Thanks!) > > Changes in V5: > - Updated cover letter to explain more the rationale behind the change > (Thanks to contributions by Sean Christopherson). > - Removed extraneous + in arm64 patch (Oliver Upton, Marc Zyngier). > - Shortened secondary_pagetables to sec_pagetables (Shakeel Butt). > - Removed dependency on other patchsets (applies to queue branch). > > Changes in V4: > - Changed accounting hooks in arm64 to only account s2 page tables and > refactored them to a much cleaner form, based on recommendations from > Oliver Upton and Marc Zyngier. > - Dropped patches for mips and riscv. I am not interested in those archs > anyway and don't have the resources to test them. I posted them for > completeness but it doesn't seem like anyone was interested. > > Changes in V3: > - Added NR_SECONDARY_PAGETABLE instead of piggybacking on NR_PAGETABLE > stats. > > Changes in V2: > - Added accounting stats for other archs than x86. > - Changed locations in the code where x86 KVM page table stats were > accounted based on suggestions from Sean Christopherson. > > --- > > Yosry Ahmed (4): > mm: add NR_SECONDARY_PAGETABLE to count secondary page table uses. > KVM: mmu: add a helper to account memory used by KVM MMU. > KVM: x86/mmu: count KVM mmu usage in secondary pagetable stats. > KVM: arm64/mmu: count KVM s2 mmu usage in secondary pagetable stats > > Documentation/admin-guide/cgroup-v2.rst | 5 ++++ > Documentation/filesystems/proc.rst | 4 +++ > arch/arm64/kvm/mmu.c | 36 ++++++++++++++++++++++--- > arch/x86/kvm/mmu/mmu.c | 16 +++++++++-- > arch/x86/kvm/mmu/tdp_mmu.c | 12 +++++++++ > drivers/base/node.c | 2 ++ > fs/proc/meminfo.c | 2 ++ > include/linux/kvm_host.h | 10 +++++++ > include/linux/mmzone.h | 1 + > mm/memcontrol.c | 1 + > mm/page_alloc.c | 6 ++++- > mm/vmstat.c | 1 + > 12 files changed, 89 insertions(+), 7 deletions(-) > > -- > 2.37.0.rc0.161.g10f37bed90-goog >