Commit a644b0ab authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

mm: convert split_huge_pages_pid() to use a folio

Replaces five calls to compound_head with one.

Link: https://lkml.kernel.org/r/20230816151201.3655946-14-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent b10ff04d
......@@ -584,14 +584,11 @@ void folio_prep_large_rmappable(struct folio *folio)
folio_set_large_rmappable(folio);
}
static inline bool is_transparent_hugepage(struct page *page)
static inline bool is_transparent_hugepage(struct folio *folio)
{
struct folio *folio;
if (!PageCompound(page))
if (!folio_test_large(folio))
return false;
folio = page_folio(page);
return is_huge_zero_page(&folio->page) ||
folio_test_large_rmappable(folio);
}
......@@ -3012,6 +3009,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
for (addr = vaddr_start; addr < vaddr_end; addr += PAGE_SIZE) {
struct vm_area_struct *vma = vma_lookup(mm, addr);
struct page *page;
struct folio *folio;
if (!vma)
break;
......@@ -3028,22 +3026,23 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
if (IS_ERR_OR_NULL(page))
continue;
if (!is_transparent_hugepage(page))
folio = page_folio(page);
if (!is_transparent_hugepage(folio))
goto next;
total++;
if (!can_split_folio(page_folio(page), NULL))
if (!can_split_folio(folio, NULL))
goto next;
if (!trylock_page(page))
if (!folio_trylock(folio))
goto next;
if (!split_huge_page(page))
if (!split_folio(folio))
split++;
unlock_page(page);
folio_unlock(folio);
next:
put_page(page);
folio_put(folio);
cond_resched();
}
mmap_read_unlock(mm);
......
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