mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
mm,hugetlb: use folio fields in second tail page
Patch series "mm,huge,rmap: unify and speed up compound mapcounts".
This patch (of 3):
We want to declare one more int in the first tail of a compound page: that
first tail page being valuable property, since every compound page has a
first tail, but perhaps no more than that.
No problem on 64-bit: there is already space for it. No problem with
32-bit THPs: 5.18 commit 5232c63f46
("mm: Make compound_pincount always
available") kindly cleared the space for it, apparently not realizing that
only 64-bit architectures enable CONFIG_THP_SWAP (whose use of tail
page->private might conflict) - but make sure of that in its Kconfig.
But hugetlb pages use tail page->private of the first tail page for a
subpool pointer, which will conflict; and they also use page->private of
the 2nd, 3rd and 4th tails.
Undo "mm: add private field of first tail to struct page and struct
folio"'s recent addition of private_1 to the folio tail: instead add
hugetlb_subpool, hugetlb_cgroup, hugetlb_cgroup_rsvd, hugetlb_hwpoison to
a second tail page of the folio: THP has long been using several fields of
that tail, so make better use of it for hugetlb too. This is not how a
generic folio should be declared in future, but it is an effective
transitional way to make use of it.
Delete the SUBPAGE_INDEX stuff, but keep __NR_USED_SUBPAGE: now 3.
[hughd@google.com: prefix folio's page_1 and page_2 with double underscore,
give folio's _flags_2 and _head_2 a line documentation each]
Link: https://lkml.kernel.org/r/9e2cb6b-5b58-d3f2-b5ee-5f8a14e8f10@google.com
Link: https://lkml.kernel.org/r/5f52de70-975-e94f-f141-543765736181@google.com
Link: https://lkml.kernel.org/r/3818cc9a-9999-d064-d778-9c94c5911e6@google.com
Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: James Houghton <jthoughton@google.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>
Cc: Peter Xu <peterx@redhat.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
634ba645f9
commit
dad6a5eb55
5 changed files with 67 additions and 68 deletions
|
@ -33,22 +33,9 @@ typedef struct { unsigned long pd; } hugepd_t;
|
|||
/*
|
||||
* For HugeTLB page, there are more metadata to save in the struct page. But
|
||||
* the head struct page cannot meet our needs, so we have to abuse other tail
|
||||
* struct page to store the metadata. In order to avoid conflicts caused by
|
||||
* subsequent use of more tail struct pages, we gather these discrete indexes
|
||||
* of tail struct page here.
|
||||
* struct page to store the metadata.
|
||||
*/
|
||||
enum {
|
||||
SUBPAGE_INDEX_SUBPOOL = 1, /* reuse page->private */
|
||||
#ifdef CONFIG_CGROUP_HUGETLB
|
||||
SUBPAGE_INDEX_CGROUP, /* reuse page->private */
|
||||
SUBPAGE_INDEX_CGROUP_RSVD, /* reuse page->private */
|
||||
__MAX_CGROUP_SUBPAGE_INDEX = SUBPAGE_INDEX_CGROUP_RSVD,
|
||||
#endif
|
||||
#ifdef CONFIG_MEMORY_FAILURE
|
||||
SUBPAGE_INDEX_HWPOISON,
|
||||
#endif
|
||||
__NR_USED_SUBPAGE,
|
||||
};
|
||||
#define __NR_USED_SUBPAGE 3
|
||||
|
||||
struct hugepage_subpool {
|
||||
spinlock_t lock;
|
||||
|
@ -722,11 +709,11 @@ extern unsigned int default_hstate_idx;
|
|||
|
||||
static inline struct hugepage_subpool *hugetlb_folio_subpool(struct folio *folio)
|
||||
{
|
||||
return (void *)folio_get_private_1(folio);
|
||||
return folio->_hugetlb_subpool;
|
||||
}
|
||||
|
||||
/*
|
||||
* hugetlb page subpool pointer located in hpage[1].private
|
||||
* hugetlb page subpool pointer located in hpage[2].hugetlb_subpool
|
||||
*/
|
||||
static inline struct hugepage_subpool *hugetlb_page_subpool(struct page *hpage)
|
||||
{
|
||||
|
@ -736,7 +723,7 @@ static inline struct hugepage_subpool *hugetlb_page_subpool(struct page *hpage)
|
|||
static inline void hugetlb_set_folio_subpool(struct folio *folio,
|
||||
struct hugepage_subpool *subpool)
|
||||
{
|
||||
folio_set_private_1(folio, (unsigned long)subpool);
|
||||
folio->_hugetlb_subpool = subpool;
|
||||
}
|
||||
|
||||
static inline void hugetlb_set_page_subpool(struct page *hpage,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue