[PATCH v2 08/10] mm: memory: use a folio in insert_page_into_pte_locked()

Kefeng Wang
2023-11-04T03:56:02Z

Use a folio in insert_page_into_pte_locked(), which is preparetion
for converting mm counter functions to take a folio.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/memory.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index ac247850919a..a2cf240b1975 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1850,10 +1850,13 @@ static int validate_page_before_insert(struct page *page)
static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
unsigned long addr, struct page *page, pgprot_t prot)
{
+ struct folio *folio;
+
if (!pte_none(ptep_get(pte)))
return -EBUSY;
+ folio = page_folio(page);
/* Ok, finally just insert the thing.. */
- get_page(page);
+ folio_get(folio);
inc_mm_counter(vma->vm_mm, mm_counter_file(page));
page_add_file_rmap(page, vma, false);
set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot));
--
2.27.0