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 AE296C46CD2 for ; Tue, 30 Jan 2024 16:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 309D26B00B0; Tue, 30 Jan 2024 11:57:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B9756B00B1; Tue, 30 Jan 2024 11:57:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 181B26B00B2; Tue, 30 Jan 2024 11:57:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 072A76B00B0 for ; Tue, 30 Jan 2024 11:57:21 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CC49214084D for ; Tue, 30 Jan 2024 16:57:20 +0000 (UTC) X-FDA: 81736583040.03.15D38F5 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by imf17.hostedemail.com (Postfix) with ESMTP id EB7B640019 for ; Tue, 30 Jan 2024 16:57:17 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="PSV6pn/N"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of souravpanda@google.com designates 209.85.208.53 as permitted sender) smtp.mailfrom=souravpanda@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706633838; a=rsa-sha256; cv=none; b=evob7INN64xILYxztstR0+ZLeoGS85EZaYt392o1LR8HNNWXmElGfud4LWaEXGawnn7NRm nONjk+dVgYgL1SMzogIhaReQbMkRJKWZgTP9A3AeyMKZEd3yXrFXz9WfmM7hKjY6+ao+uo DClHnotMfVPYtUTeTFkV/HR/Rx1O/9w= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="PSV6pn/N"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of souravpanda@google.com designates 209.85.208.53 as permitted sender) smtp.mailfrom=souravpanda@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706633838; 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=R2VOiJHA5wNA8QOYwXlsQ/TCi7T47Wk0gU0OJARNkWY=; b=oF5gnivGzVxBVBRuyouBfXXIjRVwsliCBKeHLuN1Aaqs8XobvMSGxu8fq3io3F7grtKgu7 n2wZbEIbHGDtlSolJzjjJwvVD0jcJE6aVIeqbNzR3Cqs34YP9LTd0j7DCgrekCRQ1TBYol EljXI4ljPpkVSEbulpOzp2YcNh74L7A= Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-55817a12ad8so4384780a12.2 for ; Tue, 30 Jan 2024 08:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706633836; x=1707238636; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=R2VOiJHA5wNA8QOYwXlsQ/TCi7T47Wk0gU0OJARNkWY=; b=PSV6pn/N+OOUjwCwV3H0tHKsgtUT88BbI/sTr32W25f4knfGxecdXJVtXV8JaHdMwH QDhZBPoBpb7MWe6ntiOqSAmOn3IKsLGYKJ34XrPjd12rbCVhZgTHYPhRDS20wG0RGOwA aWFfb5ISeHyL+sAV/W5A5XM6PyxtmEBU1zifLVqnABiiCjR+UGI+C7OcZ2/lhNV++IDG q/YxPG/4c7ZUL3Q7ItkjLcqC+NKGxKG/veNhabbs321E1Mx1rQ8BQCtb63YOtfXj24r7 nEwkzNGZin/RVRLaBC9fY/1J364pFLK1dBAxg3OaJzXkpyzvnp6pWc4vgXH5Jar85/qr 34zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706633836; x=1707238636; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R2VOiJHA5wNA8QOYwXlsQ/TCi7T47Wk0gU0OJARNkWY=; b=kxTvcZNfw4NaUUWU8YxZow/Fqk3LYLGtKb2CExnABh03Ou9wNTV6NJYjR0wSs6q9K8 lJN+Ue381UvfWFJCk+7gubuwii1bgiXDODXJto99y5XcMWDVY7NI/GEtRK/O/6A5C/+N JsMAxQl9WVp2rqpMyU6CMWg5B7V6RCURkLOCKOiTLdRfALjZOfKTD8GKSFjJ74D+Fg33 pRIZJbRs87KANvGPCpZw+rPGNIbYg/q1QSvhMFYZyE5H4Q+GX34hOm37WKKFd1591XBr tU7i9C6E5hA3x0cQmL3clKKYUlhwRmHzA2UVxFbOjrRBP08nYOLg0SUXgdQ0kzNwKKTf y95w== X-Gm-Message-State: AOJu0YzazNszBmVQ2IyRAnsOUBJQ+Ksr6bJ7m4co6SZaPeDlZH9vnTr9 5vY1wAVnDrmolBEC1tH3ZV/ds8vpHGb1dVWcqoW4ZOF5DCm78ysz9DdCHthKB2l7cu2kpMQQ6I/ Nz7SYpsm6yqwU6tjpKil+M5AMUMmwkP+fk7Zi X-Google-Smtp-Source: AGHT+IFzwMAa+qYPy9TkJz3yUp7eEf3uUN/m43DYLud0I+kHpppSvuIF26hwGmwZpdQSFRi7rzYrZvst7F2SqT5JYEc= X-Received: by 2002:a17:906:4a04:b0:a36:47d9:92e3 with SMTP id w4-20020a1709064a0400b00a3647d992e3mr752684eju.36.1706633836247; Tue, 30 Jan 2024 08:57:16 -0800 (PST) MIME-Version: 1.0 References: <20240129224204.1812062-1-souravpanda@google.com> <20240129224204.1812062-2-souravpanda@google.com> <2024012948-hungry-tibia-5345@gregkh> In-Reply-To: <2024012948-hungry-tibia-5345@gregkh> From: Sourav Panda Date: Tue, 30 Jan 2024 08:57:04 -0800 Message-ID: Subject: Re: [PATCH v7 1/1] mm: report per-page metadata information To: Greg KH Cc: corbet@lwn.net, rafael@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, muchun.song@linux.dev, rppt@kernel.org, david@redhat.com, rdunlap@infradead.org, chenlinxuan@uniontech.com, yang.yang29@zte.com.cn, tomas.mudrunka@gmail.com, bhelgaas@google.com, ivan@cloudflare.com, pasha.tatashin@soleen.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, kirill.shutemov@linux.intel.com, wangkefeng.wang@huawei.com, adobriyan@gmail.com, vbabka@suse.cz, Liam.Howlett@oracle.com, surenb@google.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, weixugc@google.com Content-Type: multipart/alternative; boundary="00000000000092b59a06102ca7d8" X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EB7B640019 X-Stat-Signature: 8jdh8r41jk7i7qebdbcsw8jrw1odzbkn X-HE-Tag: 1706633837-997406 X-HE-Meta: U2FsdGVkX1/EK9vhP57xZ9YpZQVIQzL/tMPJ7fUCrn7Q16HlyZ3cU+kV9KU/YHpJEfoVsPeC3YLULW+kKH8WDvULlk/HDzCETzai/2uKl1NNDmq+Rj9vsWKjK/ejFSUzwWUBYK0ZAv/mF0/6+RCCl8wfiqKAmj/7txPr08tPCq4UAVaRMGcPTCi0yb7GGEB/I8OiqAtb3c6E/UZ0uDn/pEeFQLaJF5JMc6OKjK0+SkUye6yFWn6qpUIyKDs95Y0J6UwB/rh59EGum7YHaMg7V6+De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KJmHtFAztAjWOKFGw2GO8PIN50M+aqkoB5XlIHt4BJ3oVyFPmY+C1KDzdjpFN8PtOzHALbYVx2CUUtBsNaFykctamTLzV9iZzsS4R/a5quKR8wmKs/ANLgsr/PTUbDw26oZXJsx6Csqbt7asiSaOIOr1wx5pAOT//VLHsKkt92Jra21P4qi 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: List-Subscribe: List-Unsubscribe: --00000000000092b59a06102ca7d8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Greg for reviewing the patch. Makes sense; I shall move it to the end of the file. With regards, Sourav Panda On Tue, Jan 30, 2024 at 8:35=E2=80=AFAM Greg KH wrote: > On Mon, Jan 29, 2024 at 02:42:04PM -0800, Sourav Panda wrote: > > Adds two new per-node fields, namely nr_page_metadata and > > nr_page_metadata_boot, to /sys/devices/system/node/nodeN/vmstat > > and a global PageMetadata field to /proc/meminfo. This information can > > be used by users to see how much memory is being used by per-page > > metadata, which can vary depending on build configuration, machine > > architecture, and system use. > > > > Per-page metadata is the amount of memory that Linux needs in order to > > manage memory at the page granularity. The majority of such memory is > > used by "struct page" and "page_ext" data structures. In contrast to > > most other memory consumption statistics, per-page metadata might not > > be included in MemTotal. For example, MemTotal does not include membloc= k > > allocations but includes buddy allocations. In this patch, exported > > field nr_page_metadata in /sys/devices/system/node/nodeN/vmstat would > > exclusively track buddy allocations while nr_page_metadata_boot would > > exclusively track memblock allocations. Furthermore, PageMetadata in > > /proc/meminfo would exclusively track buddy allocations allowing it to > > be compared against MemTotal. > > > > This memory depends on build configurations, machine architectures, and > > the way system is used: > > > > Build configuration may include extra fields into "struct page", > > and enable / disable "page_ext" > > Machine architecture defines base page sizes. For example 4K x86, > > 8K SPARC, 64K ARM64 (optionally), etc. The per-page metadata > > overhead is smaller on machines with larger page sizes. > > System use can change per-page overhead by using vmemmap > > optimizations with hugetlb pages, and emulated pmem devdax pages. > > Also, boot parameters can determine whether page_ext is needed > > to be allocated. This memory can be part of MemTotal or be outside > > MemTotal depending on whether the memory was hot-plugged, booted with, > > or hugetlb memory was returned back to the system. > > > > Suggested-by: Pasha Tatashin > > Signed-off-by: Sourav Panda > > --- > > Documentation/filesystems/proc.rst | 3 +++ > > fs/proc/meminfo.c | 4 ++++ > > include/linux/mmzone.h | 4 ++++ > > include/linux/vmstat.h | 4 ++++ > > mm/hugetlb_vmemmap.c | 19 ++++++++++++++---- > > mm/mm_init.c | 3 +++ > > mm/page_alloc.c | 1 + > > mm/page_ext.c | 32 +++++++++++++++++++++--------- > > mm/sparse-vmemmap.c | 8 ++++++++ > > mm/sparse.c | 7 ++++++- > > mm/vmstat.c | 26 +++++++++++++++++++++++- > > 11 files changed, 96 insertions(+), 15 deletions(-) > > > > diff --git a/Documentation/filesystems/proc.rst > b/Documentation/filesystems/proc.rst > > index 49ef12df631b..d5901d04e082 100644 > > --- a/Documentation/filesystems/proc.rst > > +++ b/Documentation/filesystems/proc.rst > > @@ -993,6 +993,7 @@ Example output. You may not have all of these field= s. > > AnonPages: 4654780 kB > > Mapped: 266244 kB > > Shmem: 9976 kB > > + PageMetadata: 513419 kB > > KReclaimable: 517708 kB > > Slab: 660044 kB > > SReclaimable: 517708 kB > > Why are you adding it to the middle of the file? Are you sure the > userspace tools that parse this file today can handle an unknown field > here, and not just at the end of the file? > > thanks, > > greg k-h > --00000000000092b59a06102ca7d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks=C2=A0Greg for reviewing the patch. Makes sense; I s= hall move it to the end of the file.=C2=A0

With regards,=
Sourav Panda



On Tue, Jan = 30, 2024 at 8:35=E2=80=AFAM Greg KH <gregkh@linuxfoundation.org> wrote:
On Mon, Jan 29, 2024 at 02:42:04PM -08= 00, Sourav Panda wrote:
> Adds two new per-node fields, namely nr_page_metadata and
> nr_page_metadata_boot, to /sys/devices/system/node/nodeN/vmstat
> and a global PageMetadata field to /proc/meminfo. This information can=
> be used by users to see how much memory is being used by per-page
> metadata, which can vary depending on build configuration, machine
> architecture, and system use.
>
> Per-page metadata is the amount of memory that Linux needs in order to=
> manage memory at the page granularity. The majority of such memory is<= br> > used by "struct page" and "page_ext" data structur= es. In contrast to
> most other memory consumption statistics, per-page metadata might not<= br> > be included in MemTotal. For example, MemTotal does not include memblo= ck
> allocations but includes buddy allocations. In this patch, exported > field nr_page_metadata in /sys/devices/system/node/nodeN/vmstat would<= br> > exclusively track buddy allocations while nr_page_metadata_boot would<= br> > exclusively track memblock allocations. Furthermore, PageMetadata in > /proc/meminfo would exclusively track buddy allocations allowing it to=
> be compared against MemTotal.
>
> This memory depends on build configurations, machine architectures, an= d
> the way system is used:
>
> Build configuration may include extra fields into "struct page&qu= ot;,
> and enable / disable "page_ext"
> Machine architecture defines base page sizes. For example 4K x86,
> 8K SPARC, 64K ARM64 (optionally), etc. The per-page metadata
> overhead is smaller on machines with larger page sizes.
> System use can change per-page overhead by using vmemmap
> optimizations with hugetlb pages, and emulated pmem devdax pages.
> Also, boot parameters can determine whether page_ext is needed
> to be allocated. This memory can be part of MemTotal or be outside
> MemTotal depending on whether the memory was hot-plugged, booted with,=
> or hugetlb memory was returned back to the system.
>
> Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> Signed-off-by: Sourav Panda <souravpanda@google.com>
> ---
>=C2=A0 Documentation/filesystems/proc.rst |=C2=A0 3 +++
>=C2=A0 fs/proc/meminfo.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 |=C2=A0 4 ++++
>=C2=A0 include/linux/mmzone.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0|=C2=A0 4 ++++
>=C2=A0 include/linux/vmstat.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0|=C2=A0 4 ++++
>=C2=A0 mm/hugetlb_vmemmap.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0| 19 ++++++++++++++----
>=C2=A0 mm/mm_init.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 3 +++
>=C2=A0 mm/page_alloc.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 |=C2=A0 1 +
>=C2=A0 mm/page_ext.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 32 +++++++++++++++++++++---------
>=C2=A0 mm/sparse-vmemmap.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 |=C2=A0 8 ++++++++
>=C2=A0 mm/sparse.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 7 ++++++-
>=C2=A0 mm/vmstat.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 26 +++++++++++++++++++++++-
>=C2=A0 11 files changed, 96 insertions(+), 15 deletions(-)
>
> diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesy= stems/proc.rst
> index 49ef12df631b..d5901d04e082 100644
> --- a/Documentation/filesystems/proc.rst
> +++ b/Documentation/filesystems/proc.rst
> @@ -993,6 +993,7 @@ Example output. You may not have all of these fiel= ds.
>=C2=A0 =C2=A0 =C2=A0 AnonPages:=C2=A0 =C2=A0 =C2=A0 =C2=A04654780 kB >=C2=A0 =C2=A0 =C2=A0 Mapped:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A026= 6244 kB
>=C2=A0 =C2=A0 =C2=A0 Shmem:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 9976 kB
> +=C2=A0 =C2=A0 PageMetadata:=C2=A0 =C2=A0 =C2=A0513419 kB
>=C2=A0 =C2=A0 =C2=A0 KReclaimable:=C2=A0 =C2=A0 =C2=A0517708 kB
>=C2=A0 =C2=A0 =C2=A0 Slab:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0660044 kB
>=C2=A0 =C2=A0 =C2=A0 SReclaimable:=C2=A0 =C2=A0 =C2=A0517708 kB

Why are you adding it to the middle of the file?=C2=A0 Are you sure the
userspace tools that parse this file today can handle an unknown field
here, and not just at the end of the file?

thanks,

greg k-h
--00000000000092b59a06102ca7d8--