hulk inclusion category: cleanup bugzilla: https://gitee.com/openeuler/kernel/issues/IAIHPC
--------------------------------
Commit 6f775463d002 ("mm: shmem: use folio_alloc_mpol() in shmem_alloc_folio()") merge shmem_alloc_hugefolio() with shmem_alloc_folio(). To avoid context conflicts in the subsequent patches, merge them.
Dep-of: 3d95bc21cea5 ("mm: shmem: add THP validation for PMD-mapped THP related statistics") Signed-off-by: Liu Shixin liushixin2@huawei.com --- mm/shmem.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c index 87134ed22968..8b336ab8b716 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1631,27 +1631,14 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) return result; }
-static struct folio *shmem_alloc_hugefolio(gfp_t gfp, +static struct folio *shmem_alloc_folio(gfp_t gfp, int order, struct shmem_inode_info *info, pgoff_t index) { struct vm_area_struct pvma; struct folio *folio;
shmem_pseudo_vma_init(&pvma, info, index); - folio = vma_alloc_folio(gfp, HPAGE_PMD_ORDER, &pvma, 0, true); - shmem_pseudo_vma_destroy(&pvma); - - return folio; -} - -static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) -{ - struct vm_area_struct pvma; - struct folio *folio; - - shmem_pseudo_vma_init(&pvma, info, index); - folio = vma_alloc_folio(gfp, 0, &pvma, 0, false); + folio = vma_alloc_folio(gfp, order, &pvma, 0, order == HPAGE_PMD_ORDER); shmem_pseudo_vma_destroy(&pvma);
return folio; @@ -1689,12 +1676,12 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, index + HPAGE_PMD_NR - 1, XA_PRESENT)) return ERR_PTR(-E2BIG);
- folio = shmem_alloc_hugefolio(gfp, info, index); + folio = shmem_alloc_folio(gfp, HPAGE_PMD_ORDER, info, index); if (!folio) count_vm_event(THP_FILE_FALLBACK); } else { pages = 1; - folio = shmem_alloc_folio(gfp, info, index); + folio = shmem_alloc_folio(gfp, 0, info, index); }
no_mem: @@ -1796,7 +1783,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, */ gfp &= ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new = shmem_alloc_folio(gfp, info, index); + new = shmem_alloc_folio(gfp, 0, info, index); if (!new) return -ENOMEM;
@@ -2618,7 +2605,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd,
if (!*foliop) { ret = -ENOMEM; - folio = shmem_alloc_folio(gfp, info, pgoff); + folio = shmem_alloc_folio(gfp, 0, info, pgoff); if (!folio) goto out_unacct_blocks;