mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	mm: move hugetlb specific things in folio to page[3]
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 <david@redhat.com> Cc: Andy Lutomirks^H^Hski <luto@kernel.org> Cc: Borislav Betkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jann Horn <jannh@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Lance Yang <ioworker0@gmail.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Matthew Wilcow (Oracle) <willy@infradead.org> Cc: Michal Koutn <mkoutny@suse.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: tejun heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Zefan Li <lizefan.x@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									4996fc547f
								
							
						
					
					
						commit
						4eeec8c89a
					
				
					 3 changed files with 22 additions and 11 deletions
				
			
		| 
						 | 
					@ -406,6 +406,16 @@ struct folio {
 | 
				
			||||||
		struct {
 | 
							struct {
 | 
				
			||||||
			unsigned long _flags_2;
 | 
								unsigned long _flags_2;
 | 
				
			||||||
			unsigned long _head_2;
 | 
								unsigned long _head_2;
 | 
				
			||||||
 | 
						/* public: */
 | 
				
			||||||
 | 
								struct list_head _deferred_list;
 | 
				
			||||||
 | 
						/* private: the union with struct page is transitional */
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							struct page __page_2;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						union {
 | 
				
			||||||
 | 
							struct {
 | 
				
			||||||
 | 
								unsigned long _flags_3;
 | 
				
			||||||
 | 
								unsigned long _head_3;
 | 
				
			||||||
	/* public: */
 | 
						/* public: */
 | 
				
			||||||
			void *_hugetlb_subpool;
 | 
								void *_hugetlb_subpool;
 | 
				
			||||||
			void *_hugetlb_cgroup;
 | 
								void *_hugetlb_cgroup;
 | 
				
			||||||
| 
						 | 
					@ -413,14 +423,7 @@ struct folio {
 | 
				
			||||||
			void *_hugetlb_hwpoison;
 | 
								void *_hugetlb_hwpoison;
 | 
				
			||||||
	/* private: the union with struct page is transitional */
 | 
						/* private: the union with struct page is transitional */
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		struct {
 | 
							struct page __page_3;
 | 
				
			||||||
			unsigned long _flags_2a;
 | 
					 | 
				
			||||||
			unsigned long _head_2a;
 | 
					 | 
				
			||||||
	/* public: */
 | 
					 | 
				
			||||||
			struct list_head _deferred_list;
 | 
					 | 
				
			||||||
	/* private: the union with struct page is transitional */
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		struct page __page_2;
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -457,8 +460,12 @@ FOLIO_MATCH(_refcount, _refcount_1);
 | 
				
			||||||
			offsetof(struct page, pg) + 2 * sizeof(struct page))
 | 
								offsetof(struct page, pg) + 2 * sizeof(struct page))
 | 
				
			||||||
FOLIO_MATCH(flags, _flags_2);
 | 
					FOLIO_MATCH(flags, _flags_2);
 | 
				
			||||||
FOLIO_MATCH(compound_head, _head_2);
 | 
					FOLIO_MATCH(compound_head, _head_2);
 | 
				
			||||||
FOLIO_MATCH(flags, _flags_2a);
 | 
					#undef FOLIO_MATCH
 | 
				
			||||||
FOLIO_MATCH(compound_head, _head_2a);
 | 
					#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
 | 
					#undef FOLIO_MATCH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1649,7 +1649,6 @@ static void __update_and_free_hugetlb_folio(struct hstate *h,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	folio_ref_unfreeze(folio, 1);
 | 
						folio_ref_unfreeze(folio, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INIT_LIST_HEAD(&folio->_deferred_list);
 | 
					 | 
				
			||||||
	hugetlb_free_folio(folio);
 | 
						hugetlb_free_folio(folio);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -971,6 +971,11 @@ static int free_tail_page_prepare(struct page *head_page, struct page *page)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case 3:
 | 
				
			||||||
 | 
							/* the third tail page: hugetlb specifics overlap ->mappings */
 | 
				
			||||||
 | 
							if (IS_ENABLED(CONFIG_HUGETLB_PAGE))
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							fallthrough;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		if (page->mapping != TAIL_MAPPING) {
 | 
							if (page->mapping != TAIL_MAPPING) {
 | 
				
			||||||
			bad_page(page, "corrupted mapping in tail page");
 | 
								bad_page(page, "corrupted mapping in tail page");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue