[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231103140119.2306578-14-wangkefeng.wang@huawei.com>
Date: Fri, 3 Nov 2023 22:01:14 +0800
From: Kefeng Wang <wangkefeng.wang@...wei.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
Matthew Wilcox <willy@...radead.org>,
David Hildenbrand <david@...hat.com>,
<linux-s390@...r.kernel.org>,
Kefeng Wang <wangkefeng.wang@...wei.com>
Subject: [PATCH 13/18] mm: memory: use a folio in insert_page_into_pte_locked()
Use mm_counter_file_folio() to save one compound_head() call in
insert_page_into_pte_locked().
Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
---
mm/memory.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
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;
--
2.27.0
Powered by blists - more mailing lists