@@ -1551,6 +1551,15 @@
Documentation/admin-guide/mm/hugetlbpage.rst.
Format: size[KMG]
+ hugetlb_free_vmemmap=
+ [KNL] When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set,
+ this controls freeing unused vmemmap pages associated
+ with each HugeTLB page.
+ Format: { on (default) | off }
+
+ on: enable the feature
+ off: disable the feature
+
hung_task_panic=
[KNL] Should the hung task detector generate panics.
Format: 0 | 1
@@ -145,6 +145,9 @@ default_hugepagesz
will all result in 256 2M huge pages being allocated. Valid default
huge page size is architecture dependent.
+hugetlb_free_vmemmap
+ When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, this disables freeing
+ unused vmemmap pages associated each HugeTLB page.
When multiple huge page sizes are supported, ``/proc/sys/vm/nr_hugepages``
indicates the current number of pre-allocated huge pages of the default size.
@@ -118,6 +118,22 @@ static inline bool vmemmap_pmd_huge(pmd_t *pmd)
}
#endif
+static bool hugetlb_free_vmemmap_disabled __initdata;
+
+static int __init early_hugetlb_free_vmemmap_param(char *buf)
+{
+ if (!buf)
+ return -EINVAL;
+
+ if (!strcmp(buf, "off"))
+ hugetlb_free_vmemmap_disabled = true;
+ else if (strcmp(buf, "on"))
+ return -EINVAL;
+
+ return 0;
+}
+early_param("hugetlb_free_vmemmap", early_hugetlb_free_vmemmap_param);
+
static inline unsigned int vmemmap_pages_per_hpage(struct hstate *h)
{
return free_vmemmap_pages_per_hpage(h) + RESERVE_VMEMMAP_NR;
@@ -505,6 +521,12 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
unsigned int order = huge_page_order(h);
unsigned int vmemmap_pages;
+ if (hugetlb_free_vmemmap_disabled) {
+ h->nr_free_vmemmap_pages = 0;
+ pr_info("disable free vmemmap pages for %s\n", h->name);
+ return;
+ }
+
vmemmap_pages = ((1 << order) * sizeof(struct page)) >> PAGE_SHIFT;
/*
* The head page and the first tail page are not to be freed to buddy
Add a kernel parameter hugetlb_free_vmemmap to disable the feature of freeing unused vmemmap pages associated with each hugetlb page on boot. Signed-off-by: Muchun Song <songmuchun@bytedance.com> --- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ Documentation/admin-guide/mm/hugetlbpage.rst | 3 +++ mm/hugetlb_vmemmap.c | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+)