Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp209270iob; Mon, 2 May 2022 17:16:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXqzrV86EBdeNI3FXfW+SD499yIYA4axa21RypoZyQLagFNXIjnT2dlWRQcGzp8hWHYL83 X-Received: by 2002:a17:902:70cc:b0:154:1cc8:9df8 with SMTP id l12-20020a17090270cc00b001541cc89df8mr14141190plt.32.1651536999157; Mon, 02 May 2022 17:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651536999; cv=none; d=google.com; s=arc-20160816; b=th29yMVgddyvPVf0bBQ/l6exhgZM2+Z/taRyRtLUjG8al8eP8agLRLFtK4wz6LLfua 8TNVrjJ/zf874N57OAIZ9+jM7uePkpnZeCf3OKklbTfmsJ1XfBOAcKy65L6nKcB428Iu Ym+H9hv10y/9fLVplAPvmONtzT/iwuJiKGVS0F0xMi6+XAj88+7D78NquUiotlXJli0F cgGtpvs9fSSawOCKbzYj2Kl2sjt4GQso1QVvvTvh4WLTc5z7ScTNhtjFhx7wZojdv8UZ NYlY+W08h+NORw6P9jx+5IGxTN2pebV/lx8H6Yyku2jl7okulQDA7YsLnAKgRORKkQJd GgGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=LYOSqpfSEBhfIcQQEMAVtPdrgbMXt9q4XMcYcfQJms0=; b=Yp3WJaXZUfIz9UvCOdcATrHx42Xs6Il7GQ1K1gFvHz5E4zu9yHATJOsnNkrmH7aaqK HaX1YlhxF+MbJ7B+7FHEqQsMxocHeNQPQCuSRUmBfkuO6+lUwYkqdkAOo9AHl9vpJ0uf JuOaWGUD1i7LaNyIVD7Vc5YP8d9PLAefiFiRPSG6AF5hZiZkrelw8uzwEgaH2EiJuZYH 4iYSfATscc0US7/XtX8ZGuNwu6IA2/b6/9Supk2CmClsoMQ9KS3HW+o92XspPm8kbemw c/tTzE7IZtFTMw6Rnk/gH10yjyk356MTmYxCfHZ4FCrXzKNTuQp5FXcxLF00oleHZjup xGFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FKR/B9fZ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j2-20020a170902da8200b0015eabbad6c8si3198195plx.29.2022.05.02.17.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:16:39 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FKR/B9fZ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A495135A86; Mon, 2 May 2022 17:14:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384458AbiEBKF4 (ORCPT + 99 others); Mon, 2 May 2022 06:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384507AbiEBKF0 (ORCPT ); Mon, 2 May 2022 06:05:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432A663F3; Mon, 2 May 2022 03:01:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D4320B8136B; Mon, 2 May 2022 10:01:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F2EDC385AF; Mon, 2 May 2022 10:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651485707; bh=+lWf8A4QQf40c+YASmhZUbPkXSvAxkZ9F5BSWGticCQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FKR/B9fZmmLbqGk2BQuYviL/XzIJF1U2nKrfXCttl+j/KZdc5z9e4rcsXlHyk705n +pGtAhAn2D8QPRGZefbUbpnEb8LG0RC+pkZjWD/0MYs5sTcN+l5TR0DO10TF2SFytM 4MrhmJ/DwgcUmmRsvmn1INgekDoa9ty4EiAmC/NdhLiLrvoJxl5PluL08sW21BhooF 6H0SwL9kHmYP0ydts/IZkhBOaQAhEU03KSiAiyuBVWbYIc+LIjqmH3O/p5Y6gSDMxz +4Ycdw+3oDj5DFsMB9/pHUghXa20tyiG/vl7xF2eNhusq2WI0rWStOMcGLgqGxS0CL nubamuYv6PSvg== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nlSsD-008OF8-9K; Mon, 02 May 2022 11:01:45 +0100 Date: Mon, 02 May 2022 11:01:44 +0100 Message-ID: <87ilqoi77b.wl-maz@kernel.org> From: Marc Zyngier To: Yosry Ahmed Cc: Tejun Heo , Johannes Weiner , Zefan Li , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Oliver Upton , 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 v4 1/4] mm: add NR_SECONDARY_PAGETABLE to count secondary page table uses. In-Reply-To: <20220429201131.3397875-2-yosryahmed@google.com> References: <20220429201131.3397875-1-yosryahmed@google.com> <20220429201131.3397875-2-yosryahmed@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yosryahmed@google.com, tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, akpm@linux-foundation.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, oupton@google.com, 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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Fri, 29 Apr 2022 21:11:28 +0100, Yosry Ahmed wrote: > > Add NR_SECONDARY_PAGETABLE stat to count secondary page table uses, e.g. > KVM mmu. This provides more insights on the kernel memory used > by a workload. > > This stat will be used by subsequent patches to count KVM mmu > memory usage. > > Signed-off-by: Yosry Ahmed > --- > Documentation/admin-guide/cgroup-v2.rst | 5 +++++ > Documentation/filesystems/proc.rst | 4 ++++ > drivers/base/node.c | 2 ++ > fs/proc/meminfo.c | 2 ++ > include/linux/mmzone.h | 1 + > mm/memcontrol.c | 1 + > mm/page_alloc.c | 6 +++++- > mm/vmstat.c | 1 + > 8 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst > index 69d7a6983f78..828cb6b6f918 100644 > --- a/Documentation/admin-guide/cgroup-v2.rst > +++ b/Documentation/admin-guide/cgroup-v2.rst > @@ -1312,6 +1312,11 @@ PAGE_SIZE multiple when read back. > pagetables > Amount of memory allocated for page tables. > > + secondary_pagetables > + Amount of memory allocated for secondary page tables, > + this currently includes KVM mmu allocations on x86 > + and arm64. Can you please explain what the rationale is for this? We already account for the (arm64) S2 PTs as a userspace allocation (see 115bae923ac8bb29ee635). You are saying that this is related to a 'workload', but given that the accounting is global, I fail to see how you can attribute these allocations on a particular VM. What do you plan to do for IOMMU page tables? After all, they serve the exact same purpose, and I'd expect these to be handled the same way (i.e. why is this KVM specific?). Thanks, M. -- Without deviation from the norm, progress is not possible.