The patch titled Subject: mm: hugetlb: introduce CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON has been added to the -mm tree. Its filename is mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Muchun Song <songmuchun@xxxxxxxxxxxxx> Subject: mm: hugetlb: introduce CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap pages associated with each HugeTLB page is default off. Now the vmemmap is PMD mapped. So there is no side effect when this feature is enabled with no HugeTLB pages in the system. Someone may want to enable this feature in the compiler time instead of using boot command line. So add a config to make it default on when someone do not want to enable it via command line. Link: https://lkml.kernel.org/r/20210616094915.34432-4-songmuchun@xxxxxxxxxxxxx Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: Chen Huang <chenhuang5@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxx> Cc: Xiongchun Duan <duanxiongchun@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ fs/Kconfig | 10 ++++++++++ mm/hugetlb_vmemmap.c | 6 ++++-- 3 files changed, 17 insertions(+), 2 deletions(-) --- a/Documentation/admin-guide/kernel-parameters.txt~mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on +++ a/Documentation/admin-guide/kernel-parameters.txt @@ -1577,6 +1577,9 @@ on: enable the feature off: disable the feature + Built with CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON=y, + the default is on. + This is not compatible with memory_hotplug.memmap_on_memory. If both parameters are enabled, hugetlb_free_vmemmap takes precedence over memory_hotplug.memmap_on_memory. --- a/fs/Kconfig~mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on +++ a/fs/Kconfig @@ -245,6 +245,16 @@ config HUGETLB_PAGE_FREE_VMEMMAP depends on X86_64 depends on SPARSEMEM_VMEMMAP +config HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON + bool "Default freeing vmemmap pages of HugeTLB to on" + default n + depends on HUGETLB_PAGE_FREE_VMEMMAP + help + When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap + pages associated with each HugeTLB page is default off. Say Y here + to enable freeing vmemmap pages of HugeTLB by default. It can then + be disabled on the command line via hugetlb_free_vmemmap=off. + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS --- a/mm/hugetlb_vmemmap.c~mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on +++ a/mm/hugetlb_vmemmap.c @@ -182,7 +182,7 @@ #define RESERVE_VMEMMAP_NR 2U #define RESERVE_VMEMMAP_SIZE (RESERVE_VMEMMAP_NR << PAGE_SHIFT) -bool hugetlb_free_vmemmap_enabled; +bool hugetlb_free_vmemmap_enabled = IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON); static int __init early_hugetlb_free_vmemmap_param(char *buf) { @@ -197,7 +197,9 @@ static int __init early_hugetlb_free_vme if (!strcmp(buf, "on")) hugetlb_free_vmemmap_enabled = true; - else if (strcmp(buf, "off")) + else if (!strcmp(buf, "off")) + hugetlb_free_vmemmap_enabled = false; + else return -EINVAL; return 0; _ Patches currently in -mm which might be from songmuchun@xxxxxxxxxxxxx are mm-memcontrol-fix-root_mem_cgroup-charging.patch mm-memcontrol-fix-page-charging-in-page-replacement.patch mm-memcontrol-bail-out-early-when-mm-in-get_mem_cgroup_from_mm.patch mm-memcontrol-remove-the-pgdata-parameter-of-mem_cgroup_page_lruvec.patch mm-memcontrol-simplify-lruvec_holds_page_lru_lock.patch mm-memcontrol-rename-lruvec_holds_page_lru_lock-to-page_matches_lruvec.patch mm-memcontrol-simplify-the-logic-of-objcg-pinning-memcg.patch mm-memcontrol-move-obj_cgroup_uncharge_pages-out-of-css_set_lock.patch mm-vmscan-remove-noinline_for_stack.patch mm-memory_hotplug-factor-out-bootmem-core-functions-to-bootmem_infoc.patch mm-hugetlb-introduce-a-new-config-hugetlb_page_free_vmemmap.patch mm-hugetlb-gather-discrete-indexes-of-tail-page.patch mm-hugetlb-free-the-vmemmap-pages-associated-with-each-hugetlb-page.patch mm-hugetlb-defer-freeing-of-hugetlb-pages.patch mm-hugetlb-alloc-the-vmemmap-pages-associated-with-each-hugetlb-page.patch mm-hugetlb-add-a-kernel-parameter-hugetlb_free_vmemmap.patch mm-memory_hotplug-disable-memmap_on_memory-when-hugetlb_free_vmemmap-enabled.patch mm-hugetlb-introduce-nr_free_vmemmap_pages-in-the-struct-hstate.patch mm-sparsemem-split-the-huge-pmd-mapping-of-vmemmap-pages.patch mm-sparsemem-use-huge-pmd-mapping-for-vmemmap-pages.patch mm-hugetlb-introduce-config_hugetlb_page_free_vmemmap_default_on.patch mm-migrate-fix-missing-update-page_private-to-hugetlb_page_subpool.patch mm-migrate-fix-missing-update-page_private-to-hugetlb_page_subpool-v2.patch