[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v3 1/4] mm: hugetlb: disable freeing vmemmap pages when struct page crosses page boundaries
If the size of "struct page" is not the power of two and this
feature is enabled, then the vmemmap pages of HugeTLB will be
corrupted after remapping (panic is about to happen in theory).
But this only exists when !CONFIG_MEMCG && !CONFIG_SLUB on
x86_64. However, it is not a conventional configuration nowadays.
So it is not a real word issue, just the result of a code review.
But we cannot prevent anyone from configuring that combined
configure. This feature should be disable in this case to fix
this issue.

Signed-off-by: Muchun Song <>
mm/hugetlb_vmemmap.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index b3118dba0518..49bc7f845438 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -121,6 +121,18 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
if (!hugetlb_free_vmemmap_enabled())

+ !is_power_of_2(sizeof(struct page))) {
+ /*
+ * The hugetlb_free_vmemmap_enabled_key can be enabled when
+ * be disabled if "struct page" crosses page boundaries.
+ */
+ pr_warn_once("cannot free vmemmap pages because \"struct page\" crosses page boundaries\n");
+ static_branch_disable(&hugetlb_free_vmemmap_enabled_key);
+ return;
+ }
vmemmap_pages = (nr_pages * sizeof(struct page)) >> PAGE_SHIFT;
* The head page is not to be freed to buddy allocator, the other tail
 \ /
  Last update: 2022-03-07 14:13    [W:0.057 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site