Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D1054973BE; Thu, 17 Sep 2026 18:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671475; cv=none; b=SWcvDrbzHNiQrNRvRjiJMt1kdZpQVIpVeUzHhVQshra7ju6/dZBgiz25XIAUMuhNQjmNyq8c7t/c2YPiw48A/ynEsxIfJXTB31APpUHr2ClcAVhqzCjYIkFlj8EZC4Oc3zaRMR6tA3sUlhmkUJkmoe2w292Z1nKwW7hXm1ZfhsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671475; c=relaxed/simple; bh=mwico20N+iOI/+6174hilArdzys0su22Tpqa3O5cl3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=chvLTkKDUqkgJ2rmShL7Yax4sQkNyc2J+v+JVTII8RjrzEZjm6sCDKN7+U94NqBnzUqjya3KpXZOjywlxHWC0gvlb9G3D0bLigc25Af2ck+b5eN0h5aJCGMPvGcUuSa9Wu6CJ+R7LE1oS3htZmAxxRn+j+zO1IqSZfoKdk6h8CA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qBNZXlaF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qBNZXlaF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60C991F000FF; Thu, 17 Sep 2026 18:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789671474; bh=ouzS8n0kP40TnEKE61qTM/gA2C3BPn70mwuetuqzSLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qBNZXlaFRkVSYeymRqI+C47tLaaCWZ4YO3upwpGGqOHrF7ONwaoMmMZJOM8j90Q7B zCenObbRiqyP+tOMtzLLbYY1xJ7RG3mUbcsseUcAtnOTUierlJELhfkZslGuW0Tn/Z DzGvqMheaDwXEJpaV9DVj0iVAVsMYi/FklvTVidM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Hildenbrand , Andy Lutomirks^H^Hski , Borislav Betkov , Dave Hansen , Ingo Molnar , Jann Horn , Johannes Weiner , Jonathan Corbet , "Kirill A. Shutemov" , Lance Yang , Liam Howlett , Lorenzo Stoakes , "Matthew Wilcow (Oracle)" , Michal Koutn , Muchun Song , tejun heo , Thomas Gleixner , Vlastimil Babka , Zefan Li , Andrew Morton , Sasha Levin Subject: [PATCH 6.12 0988/1102] mm: move hugetlb specific things in folio to page[3] Date: Thu, 17 Sep 2026 16:15:31 +0100 Message-ID: <20260917151605.513659260@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand [ Upstream commit 4eeec8c89a0c4a8c20fb13a4e7093cc8efce383d ] Let's just move the hugetlb specific stuff to a separate page, and stop letting it overlay other fields for now. This frees up some space in page[2], which we will use on 32bit to free up some space in page[1]. While we could move these things to page[3] instead, it's cleaner to just move the hugetlb specific things out of the way and pack the core-folio stuff as tight as possible. ... and we can minimize the work required in dump_folio. We can now avoid re-initializing &folio->_deferred_list in hugetlb code. Hopefully dynamically allocating "strut folio" in the future will further clean this up. Link: https://lkml.kernel.org/r/20250303163014.1128035-5-david@redhat.com Signed-off-by: David Hildenbrand Cc: Andy Lutomirks^H^Hski Cc: Borislav Betkov Cc: Dave Hansen Cc: Ingo Molnar Cc: Jann Horn Cc: Johannes Weiner Cc: Jonathan Corbet Cc: Kirill A. Shutemov Cc: Lance Yang Cc: Liam Howlett Cc: Lorenzo Stoakes Cc: Matthew Wilcow (Oracle) Cc: Michal Koutn Cc: Muchun Song Cc: tejun heo Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: Zefan Li Signed-off-by: Andrew Morton Stable-dep-of: 078e1a0fc41a ("mm/gup: fix always draining LRU caches in collect_longterm_unpinnable_folios()") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/linux/mm_types.h | 27 +++++++++++++++++---------- mm/hugetlb.c | 1 - mm/page_alloc.c | 5 +++++ 3 files changed, 22 insertions(+), 11 deletions(-) --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -385,20 +385,23 @@ struct folio { unsigned long _flags_2; unsigned long _head_2; /* public: */ - void *_hugetlb_subpool; - void *_hugetlb_cgroup; - void *_hugetlb_cgroup_rsvd; - void *_hugetlb_hwpoison; + struct list_head _deferred_list; /* private: the union with struct page is transitional */ }; + struct page __page_2; + }; + union { struct { - unsigned long _flags_2a; - unsigned long _head_2a; + unsigned long _flags_3; + unsigned long _head_3; /* public: */ - struct list_head _deferred_list; + void *_hugetlb_subpool; + void *_hugetlb_cgroup; + void *_hugetlb_cgroup_rsvd; + void *_hugetlb_hwpoison; /* private: the union with struct page is transitional */ }; - struct page __page_2; + struct page __page_3; }; }; @@ -433,8 +436,12 @@ FOLIO_MATCH(compound_head, _head_1); offsetof(struct page, pg) + 2 * sizeof(struct page)) FOLIO_MATCH(flags, _flags_2); FOLIO_MATCH(compound_head, _head_2); -FOLIO_MATCH(flags, _flags_2a); -FOLIO_MATCH(compound_head, _head_2a); +#undef FOLIO_MATCH +#define FOLIO_MATCH(pg, fl) \ + static_assert(offsetof(struct folio, fl) == \ + offsetof(struct page, pg) + 3 * sizeof(struct page)) +FOLIO_MATCH(flags, _flags_3); +FOLIO_MATCH(compound_head, _head_3); #undef FOLIO_MATCH /** --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1702,7 +1702,6 @@ static void __update_and_free_hugetlb_fo folio_ref_unfreeze(folio, 1); - INIT_LIST_HEAD(&folio->_deferred_list); hugetlb_free_folio(folio); } --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1005,6 +1005,11 @@ static int free_tail_page_prepare(struct goto out; } break; + case 3: + /* the third tail page: hugetlb specifics overlap ->mappings */ + if (IS_ENABLED(CONFIG_HUGETLB_PAGE)) + break; + fallthrough; default: if (page->mapping != TAIL_MAPPING) { bad_page(page, "corrupted mapping in tail page");