mm/gup: Convert gup_huge_pgd() to use a folio

Use the new folio-based APIs.  This was the last user of
try_grab_compound_head(), so remove it.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarWilliam Kucharski <william.kucharski@oracle.com>
parent 83afb52e
...@@ -133,12 +133,6 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags) ...@@ -133,12 +133,6 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags)
return NULL; return NULL;
} }
static inline struct page *try_grab_compound_head(struct page *page,
int refs, unsigned int flags)
{
return &try_grab_folio(page, refs, flags)->page;
}
static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) static void gup_put_folio(struct folio *folio, int refs, unsigned int flags)
{ {
if (flags & FOLL_PIN) { if (flags & FOLL_PIN) {
...@@ -2560,7 +2554,8 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr, ...@@ -2560,7 +2554,8 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,
struct page **pages, int *nr) struct page **pages, int *nr)
{ {
int refs; int refs;
struct page *head, *page; struct page *page;
struct folio *folio;
if (!pgd_access_permitted(orig, flags & FOLL_WRITE)) if (!pgd_access_permitted(orig, flags & FOLL_WRITE))
return 0; return 0;
...@@ -2570,17 +2565,17 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr, ...@@ -2570,17 +2565,17 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,
page = nth_page(pgd_page(orig), (addr & ~PGDIR_MASK) >> PAGE_SHIFT); page = nth_page(pgd_page(orig), (addr & ~PGDIR_MASK) >> PAGE_SHIFT);
refs = record_subpages(page, addr, end, pages + *nr); refs = record_subpages(page, addr, end, pages + *nr);
head = try_grab_compound_head(pgd_page(orig), refs, flags); folio = try_grab_folio(page, refs, flags);
if (!head) if (!folio)
return 0; return 0;
if (unlikely(pgd_val(orig) != pgd_val(*pgdp))) { if (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {
put_compound_head(head, refs, flags); gup_put_folio(folio, refs, flags);
return 0; return 0;
} }
*nr += refs; *nr += refs;
SetPageReferenced(head); folio_set_referenced(folio);
return 1; return 1;
} }
......
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