Commit 16540dae authored by Sidhartha Kumar's avatar Sidhartha Kumar Committed by Andrew Morton

mm/hugetlb: mm/memory_hotplug: use a folio in scan_movable_pages()

By using a folio in scan_movable_pages() we convert the last user of the
page-based hugetlb information macro functions to the folio version. 
After this conversion, we can safely remove the page-based definitions
from include/linux/hugetlb.h.

Link: https://lkml.kernel.org/r/20240530171427.242018-1-sidhartha.kumar@oracle.comSigned-off-by: default avatarSidhartha Kumar <sidhartha.kumar@oracle.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 50875896
...@@ -616,9 +616,7 @@ static __always_inline \ ...@@ -616,9 +616,7 @@ static __always_inline \
bool folio_test_hugetlb_##flname(struct folio *folio) \ bool folio_test_hugetlb_##flname(struct folio *folio) \
{ void *private = &folio->private; \ { void *private = &folio->private; \
return test_bit(HPG_##flname, private); \ return test_bit(HPG_##flname, private); \
} \ }
static inline int HPage##uname(struct page *page) \
{ return test_bit(HPG_##flname, &(page->private)); }
#define SETHPAGEFLAG(uname, flname) \ #define SETHPAGEFLAG(uname, flname) \
static __always_inline \ static __always_inline \
...@@ -637,8 +635,6 @@ void folio_clear_hugetlb_##flname(struct folio *folio) \ ...@@ -637,8 +635,6 @@ void folio_clear_hugetlb_##flname(struct folio *folio) \
#define TESTHPAGEFLAG(uname, flname) \ #define TESTHPAGEFLAG(uname, flname) \
static inline bool \ static inline bool \
folio_test_hugetlb_##flname(struct folio *folio) \ folio_test_hugetlb_##flname(struct folio *folio) \
{ return 0; } \
static inline int HPage##uname(struct page *page) \
{ return 0; } { return 0; }
#define SETHPAGEFLAG(uname, flname) \ #define SETHPAGEFLAG(uname, flname) \
......
...@@ -1731,8 +1731,8 @@ static int scan_movable_pages(unsigned long start, unsigned long end, ...@@ -1731,8 +1731,8 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
unsigned long pfn; unsigned long pfn;
for (pfn = start; pfn < end; pfn++) { for (pfn = start; pfn < end; pfn++) {
struct page *page, *head; struct page *page;
unsigned long skip; struct folio *folio;
if (!pfn_valid(pfn)) if (!pfn_valid(pfn))
continue; continue;
...@@ -1753,7 +1753,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end, ...@@ -1753,7 +1753,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
if (!PageHuge(page)) if (!PageHuge(page))
continue; continue;
head = compound_head(page); folio = page_folio(page);
/* /*
* This test is racy as we hold no reference or lock. The * This test is racy as we hold no reference or lock. The
* hugetlb page could have been free'ed and head is no longer * hugetlb page could have been free'ed and head is no longer
...@@ -1761,10 +1761,9 @@ static int scan_movable_pages(unsigned long start, unsigned long end, ...@@ -1761,10 +1761,9 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
* cases false positives and negatives are possible. Calling * cases false positives and negatives are possible. Calling
* code must deal with these scenarios. * code must deal with these scenarios.
*/ */
if (HPageMigratable(head)) if (folio_test_hugetlb_migratable(folio))
goto found; goto found;
skip = compound_nr(head) - (pfn - page_to_pfn(head)); pfn |= folio_nr_pages(folio) - 1;
pfn += skip - 1;
} }
return -ENOENT; return -ENOENT;
found: found:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment