On Tue, Dec 5, 2023 at 5:31 PM Sourav Panda <souravpanda@xxxxxxxxxx> 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 memblock > allocations but includes buddy allocations. In this patch, exported > field nr_page_metadata in /sys/devices/system/node/nodeN/vmstat would It is OK to have nr_page_metadata field in nodeN/vmstat based on this discussion: https://lore.kernel.org/linux-mm/CA+CK2bB2=raEP8W5GDW_JY7TDvwtSCbkQjvn=SvbjUjPETXZow@xxxxxxxxxxxxxx > 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 <pasha.tatashin@xxxxxxxxxx> > Signed-off-by: Sourav Panda <souravpanda@xxxxxxxxxx> Reviewed-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> Pasha