diff mbox series

[v2,01/26] shmem: Convert shmem_alloc_hugepage() to use vma_alloc_folio()

Message ID 20220504182857.4013401-2-willy@infradead.org (mailing list archive)
State New
Headers show
Series Folio patches for 5.19 | expand

Commit Message

Matthew Wilcox May 4, 2022, 6:28 p.m. UTC
For now, return the head page of the folio, but remove use of the
old alloc_pages_vma() API.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/shmem.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Christoph Hellwig May 5, 2022, 3:30 p.m. UTC | #1
On Wed, May 04, 2022 at 07:28:32PM +0100, Matthew Wilcox (Oracle) wrote:
> For now, return the head page of the folio, but remove use of the
> old alloc_pages_vma() API.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Zi Yan May 5, 2022, 5:29 p.m. UTC | #2
On 4 May 2022, at 14:28, Matthew Wilcox (Oracle) wrote:

> For now, return the head page of the folio, but remove use of the
> old alloc_pages_vma() API.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/shmem.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

--
Best Regards,
Yan, Zi
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 4b2fea33158e..c89394221a7e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1527,7 +1527,7 @@  static struct page *shmem_alloc_hugepage(gfp_t gfp,
 	struct vm_area_struct pvma;
 	struct address_space *mapping = info->vfs_inode.i_mapping;
 	pgoff_t hindex;
-	struct page *page;
+	struct folio *folio;
 
 	hindex = round_down(index, HPAGE_PMD_NR);
 	if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1,
@@ -1535,13 +1535,11 @@  static struct page *shmem_alloc_hugepage(gfp_t gfp,
 		return NULL;
 
 	shmem_pseudo_vma_init(&pvma, info, hindex);
-	page = alloc_pages_vma(gfp, HPAGE_PMD_ORDER, &pvma, 0, true);
+	folio = vma_alloc_folio(gfp, HPAGE_PMD_ORDER, &pvma, 0, true);
 	shmem_pseudo_vma_destroy(&pvma);
-	if (page)
-		prep_transhuge_page(page);
-	else
+	if (!folio)
 		count_vm_event(THP_FILE_FALLBACK);
-	return page;
+	return &folio->page;
 }
 
 static struct page *shmem_alloc_page(gfp_t gfp,