Skip to content

Commit 47d7e72

Browse files
sidkumar99Sasha Levin
authored andcommitted
mm/hugetlb: add hugetlb_folio_subpool() helpers
[ Upstream commit 149562f ] Allow hugetlbfs_migrate_folio to check and read subpool information by passing in a folio. Link: https://lkml.kernel.org/r/20220922154207.1575343-4-sidhartha.kumar@oracle.com Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Reviewed-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 a0d1e02 commit 47d7e72

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

fs/hugetlbfs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
11081108
if (rc != MIGRATEPAGE_SUCCESS)
11091109
return rc;
11101110

1111-
if (hugetlb_page_subpool(&src->page)) {
1112-
hugetlb_set_page_subpool(&dst->page,
1113-
hugetlb_page_subpool(&src->page));
1114-
hugetlb_set_page_subpool(&src->page, NULL);
1111+
if (hugetlb_folio_subpool(src)) {
1112+
hugetlb_set_folio_subpool(dst,
1113+
hugetlb_folio_subpool(src));
1114+
hugetlb_set_folio_subpool(src, NULL);
11151115
}
11161116

11171117
if (mode != MIGRATE_SYNC_NO_COPY)

include/linux/hugetlb.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,18 +754,29 @@ extern unsigned int default_hstate_idx;
754754

755755
#define default_hstate (hstates[default_hstate_idx])
756756

757+
static inline struct hugepage_subpool *hugetlb_folio_subpool(struct folio *folio)
758+
{
759+
return (void *)folio_get_private_1(folio);
760+
}
761+
757762
/*
758763
* hugetlb page subpool pointer located in hpage[1].private
759764
*/
760765
static inline struct hugepage_subpool *hugetlb_page_subpool(struct page *hpage)
761766
{
762-
return (void *)page_private(hpage + SUBPAGE_INDEX_SUBPOOL);
767+
return hugetlb_folio_subpool(page_folio(hpage));
768+
}
769+
770+
static inline void hugetlb_set_folio_subpool(struct folio *folio,
771+
struct hugepage_subpool *subpool)
772+
{
773+
folio_set_private_1(folio, (unsigned long)subpool);
763774
}
764775

765776
static inline void hugetlb_set_page_subpool(struct page *hpage,
766777
struct hugepage_subpool *subpool)
767778
{
768-
set_page_private(hpage + SUBPAGE_INDEX_SUBPOOL, (unsigned long)subpool);
779+
hugetlb_set_folio_subpool(page_folio(hpage), subpool);
769780
}
770781

771782
static inline struct hstate *hstate_file(struct file *f)

0 commit comments

Comments
 (0)