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/[email protected] Signed-off-by: Sidhartha Kumar <[email protected]> Acked-by: Mike Kravetz <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Colin Cross <[email protected]> Cc: David Howells <[email protected]> Cc: "Eric W . Biederman" <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: kernel test robot <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Muchun Song <[email protected]> Cc: Peter Xu <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: William Kucharski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Stable-dep-of: b76b469 ("mm/hugetlb: fix missing hugetlb_lock for resv uncharge") Signed-off-by: Sasha Levin <[email protected]>
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)