Skip to content

Commit d251562

Browse files
sidkumar99Sasha Levin
authored andcommitted
mm: add private field of first tail to struct page and struct folio
[ Upstream commit d340625 ] Allow struct folio to store hugetlb metadata that is contained in the private field of the first tail page. On 32-bit, _private_1 aligns with page[1].private. Link: https://lkml.kernel.org/r/20220922154207.1575343-3-sidhartha.kumar@oracle.com Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Acked-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Colin Cross <ccross@google.com> Cc: David Howells <dhowells@redhat.com> Cc: "Eric W . Biederman" <ebiederm@xmission.com> Cc: Hugh Dickins <hughd@google.com> Cc: kernel test robot <lkp@intel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Muchun Song <songmuchun@bytedance.com> Cc: Peter Xu <peterx@redhat.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Stable-dep-of: b76b469 ("mm/hugetlb: fix missing hugetlb_lock for resv uncharge") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b58323c commit d251562

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/linux/mm_types.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct page {
144144
atomic_t compound_pincount;
145145
#ifdef CONFIG_64BIT
146146
unsigned int compound_nr; /* 1 << compound_order */
147+
unsigned long _private_1;
147148
#endif
148149
};
149150
struct { /* Second tail page of compound page */
@@ -264,6 +265,7 @@ struct page {
264265
* @_total_mapcount: Do not use directly, call folio_entire_mapcount().
265266
* @_pincount: Do not use directly, call folio_maybe_dma_pinned().
266267
* @_folio_nr_pages: Do not use directly, call folio_nr_pages().
268+
* @_private_1: Do not use directly, call folio_get_private_1().
267269
*
268270
* A folio is a physically, virtually and logically contiguous set
269271
* of bytes. It is a power-of-two in size, and it is aligned to that
@@ -311,6 +313,7 @@ struct folio {
311313
#ifdef CONFIG_64BIT
312314
unsigned int _folio_nr_pages;
313315
#endif
316+
unsigned long _private_1;
314317
};
315318

316319
#define FOLIO_MATCH(pg, fl) \
@@ -338,6 +341,7 @@ FOLIO_MATCH(compound_mapcount, _total_mapcount);
338341
FOLIO_MATCH(compound_pincount, _pincount);
339342
#ifdef CONFIG_64BIT
340343
FOLIO_MATCH(compound_nr, _folio_nr_pages);
344+
FOLIO_MATCH(_private_1, _private_1);
341345
#endif
342346
#undef FOLIO_MATCH
343347

@@ -383,6 +387,16 @@ static inline void *folio_get_private(struct folio *folio)
383387
return folio->private;
384388
}
385389

390+
static inline void folio_set_private_1(struct folio *folio, unsigned long private)
391+
{
392+
folio->_private_1 = private;
393+
}
394+
395+
static inline unsigned long folio_get_private_1(struct folio *folio)
396+
{
397+
return folio->_private_1;
398+
}
399+
386400
struct page_frag_cache {
387401
void * va;
388402
#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)

0 commit comments

Comments
 (0)