[13/18] mm: memory: use a folio in insert_page_into_pte_locked()

Message ID 20231103140119.2306578-14-wangkefeng.wang@huawei.com
State New
Headers
Series mm: convert to use folio mm counter |

Commit Message

Kefeng Wang Nov. 3, 2023, 2:01 p.m. UTC
  Use mm_counter_file_folio() to save one compound_head() call in
insert_page_into_pte_locked().

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

Patch

diff --git a/mm/memory.c b/mm/memory.c
index 2d90da70a1c8..584fe9a550b9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1845,11 +1845,14 @@  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);
-	inc_mm_counter(vma->vm_mm, mm_counter_file(page));
+	folio_get(folio);
+	inc_mm_counter(vma->vm_mm, mm_counter_file_folio(folio));
 	page_add_file_rmap(page, vma, false);
 	set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot));
 	return 0;