linux/Documentation/vm
Joao Martins 4917f55b4e mm/sparse-vmemmap: improve memory savings for compound devmaps
A compound devmap is a dev_pagemap with @vmemmap_shift > 0 and it means
that pages are mapped at a given huge page alignment and utilize uses
compound pages as opposed to order-0 pages.

Take advantage of the fact that most tail pages look the same (except the
first two) to minimize struct page overhead.  Allocate a separate page for
the vmemmap area which contains the head page and separate for the next 64
pages.  The rest of the subsections then reuse this tail vmemmap page to
initialize the rest of the tail pages.

Sections are arch-dependent (e.g.  on x86 it's 64M, 128M or 512M) and when
initializing compound devmap with big enough @vmemmap_shift (e.g.  1G PUD)
it may cross multiple sections.  The vmemmap code needs to consult @pgmap
so that multiple sections that all map the same tail data can refer back
to the first copy of that data for a given gigantic page.

On compound devmaps with 2M align, this mechanism lets 6 pages be saved
out of the 8 necessary PFNs necessary to set the subsection's 512 struct
pages being mapped.  On a 1G compound devmap it saves 4094 pages.

Altmap isn't supported yet, given various restrictions in altmap pfn
allocator, thus fallback to the already in use vmemmap_populate().  It is
worth noting that altmap for devmap mappings was there to relieve the
pressure of inordinate amounts of memmap space to map terabytes of pmem. 
With compound pages the motivation for altmaps for pmem gets reduced.

Link: https://lkml.kernel.org/r/20220420155310.9712-5-joao.m.martins@oracle.com
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-04-28 23:16:16 -07:00
..
damon Docs/damon: update outdated term 'regions update interval' 2022-03-22 15:57:12 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
active_mm.rst docs/vm: fix 'mm_count' vs 'mm_users' counter confusion 2020-10-13 18:38:32 -07:00
arch_pgtable_helpers.rst mm: ptep_clear() page table helper 2022-01-15 16:30:28 +02:00
balance.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
free_page_reporting.rst mm/page_reporting: add free page reporting documentation 2020-04-07 10:43:39 -07:00
frontswap.rst frontswap: remove frontswap_shrink 2022-01-22 08:33:38 +02:00
highmem.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
hmm.rst mm/migrate.c: remove MIGRATE_PFN_LOCKED 2021-11-11 09:34:35 -08:00
hugetlbfs_reserv.rst docs/vm: Minor editorial changes in the THP and hugetlbfs 2019-04-30 06:34:40 -06:00
hwpoison.rst x86/mce: Remove the tolerance level control 2022-02-23 11:09:25 +01:00
index.rst mm/hugetlb_vmemmap: move comment block to Documentation/vm 2022-04-28 23:16:15 -07:00
ksm.rst docs: get rid of :c:type explicit declarations for structs 2020-10-15 07:49:40 +02:00
memory-model.rst docs: remove description of DISCONTIGMEM 2021-06-29 10:53:55 -07:00
mmu_notifier.rst docs/vm: trivial fixes to several spelling mistakes 2020-10-22 16:11:04 -06:00
numa.rst docs: cgroup-v1: add it to the admin-guide book 2019-07-15 11:03:02 -03:00
overcommit-accounting.rst docs/vm: clarify overcommit amount sysctl behavior 2021-12-16 15:53:22 -07:00
page_frags.rst docs: vm: page_frags.rst: Fix the reference of stale function 2020-05-15 11:34:55 -06:00
page_migration.rst mm: migrate: correct the hugetlb migration stats 2022-01-15 16:30:30 +02:00
page_owner.rst tools/vm/page_owner_sort.c: provide allocator labelling and update --cull and --sort options 2022-04-28 23:15:57 -07:00
page_table_check.rst docs/vm: Fix typo in *harden* 2022-01-27 11:22:34 -07:00
remap_file_pages.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
slub.rst mm/slub: clarify verification reporting 2021-06-16 09:24:42 -07:00
split_page_table_lock.rst Documentation: fix typos in split page table lock description 2021-01-18 13:27:18 -07:00
transhuge.rst mm: gup: remove FOLL_SPLIT 2021-04-30 11:20:37 -07:00
unevictable-lru.rst mm/munlock: update Documentation/vm/unevictable-lru.rst 2022-04-01 11:46:09 -07:00
vmalloced-kernel-stacks.rst docs/vm: add vmalloced-kernel-stacks document 2022-01-15 16:30:28 +02:00
vmemmap_dedup.rst mm/sparse-vmemmap: improve memory savings for compound devmaps 2022-04-28 23:16:16 -07:00
z3fold.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00
zsmalloc.rst docs/vm: rename documentation files to .rst 2018-04-16 14:18:15 -06:00