Re: [PATCH 13/17] gup: Convert gup_huge_pgd() to use a folio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/2/22 13:57, Matthew Wilcox (Oracle) wrote:
Use the new folio-based APIs.  Also fix an assumption that memmap is
contiguous.  This was the last user of try_grab_compound_head(),
so remove it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
  mm/gup.c | 19 +++++++------------
  1 file changed, 7 insertions(+), 12 deletions(-)

Reviewed-by: John Hubbard <jhubbard@xxxxxxxxxx>


thanks,
--
John Hubbard
NVIDIA


diff --git a/mm/gup.c b/mm/gup.c
index e7bcee8776e1..7bd1e4a2648a 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -152,12 +152,6 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags)
  	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)
  {
  	if (flags & FOLL_PIN) {
@@ -2588,27 +2582,28 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,
  			struct page **pages, int *nr)
  {
  	int refs;
-	struct page *head, *page;
+	struct page *page;
+	struct folio *folio;
if (!pgd_access_permitted(orig, flags & FOLL_WRITE))
  		return 0;
BUILD_BUG_ON(pgd_devmap(orig)); - 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);
- head = try_grab_compound_head(pgd_page(orig), refs, flags);
-	if (!head)
+	folio = try_grab_folio(page, refs, flags);
+	if (!folio)
  		return 0;
if (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {
-		put_compound_head(head, refs, flags);
+		gup_put_folio(folio, refs, flags);
  		return 0;
  	}
*nr += refs;
-	SetPageReferenced(head);
+	folio_set_referenced(folio);
  	return 1;
  }




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux