linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: huge_memory: Convert madvise_free_huge_pmd to use a folio
@ 2022-12-07  2:34 Kefeng Wang
  2022-12-07  2:34 ` [PATCH 2/2] mm: swap: Convert mark_page_lazyfree() to mark_folio_lazyfree() Kefeng Wang
  2022-12-12 20:00 ` [PATCH 1/2] mm: huge_memory: Convert madvise_free_huge_pmd to use a folio Vishal Moola
  0 siblings, 2 replies; 7+ messages in thread
From: Kefeng Wang @ 2022-12-07  2:34 UTC (permalink / raw)
  To: linux-mm, Andrew Morton
  Cc: Matthew Wilcox (Oracle), linux-kernel, Kefeng Wang

Using folios instead of pages removes several calls to compound_head(),

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

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index abe6cfd92ffa..6e76c770529b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1603,7 +1603,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 {
 	spinlock_t *ptl;
 	pmd_t orig_pmd;
-	struct page *page;
+	struct folio *folio;
 	struct mm_struct *mm = tlb->mm;
 	bool ret = false;
 
@@ -1623,15 +1623,15 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 		goto out;
 	}
 
-	page = pmd_page(orig_pmd);
+	folio = pfn_folio(pmd_pfn(orig_pmd));
 	/*
-	 * If other processes are mapping this page, we couldn't discard
-	 * the page unless they all do MADV_FREE so let's skip the page.
+	 * If other processes are mapping this folio, we couldn't discard
+	 * the folio unless they all do MADV_FREE so let's skip the folio.
 	 */
-	if (total_mapcount(page) != 1)
+	if (folio_mapcount(folio) != 1)
 		goto out;
 
-	if (!trylock_page(page))
+	if (!folio_trylock(folio))
 		goto out;
 
 	/*
@@ -1639,17 +1639,17 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 	 * will deactivate only them.
 	 */
 	if (next - addr != HPAGE_PMD_SIZE) {
-		get_page(page);
+		folio_get(folio);
 		spin_unlock(ptl);
-		split_huge_page(page);
-		unlock_page(page);
-		put_page(page);
+		split_folio(folio);
+		folio_unlock(folio);
+		folio_put(folio);
 		goto out_unlocked;
 	}
 
-	if (PageDirty(page))
-		ClearPageDirty(page);
-	unlock_page(page);
+	if (folio_test_dirty(folio))
+		folio_clear_dirty(folio);
+	folio_unlock(folio);
 
 	if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) {
 		pmdp_invalidate(vma, addr, pmd);
@@ -1660,7 +1660,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 		tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
 	}
 
-	mark_page_lazyfree(page);
+	mark_page_lazyfree(&folio->page);
 	ret = true;
 out:
 	spin_unlock(ptl);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-12 20:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07  2:34 [PATCH 1/2] mm: huge_memory: Convert madvise_free_huge_pmd to use a folio Kefeng Wang
2022-12-07  2:34 ` [PATCH 2/2] mm: swap: Convert mark_page_lazyfree() to mark_folio_lazyfree() Kefeng Wang
2022-12-08 21:32   ` Vishal Moola
2022-12-09  1:15     ` Kefeng Wang
2022-12-09  2:06   ` [PATCH v2] mm: swap: Convert mark_page_lazyfree() to folio_mark_lazyfree() Kefeng Wang
2022-12-12 20:01     ` Vishal Moola
2022-12-12 20:00 ` [PATCH 1/2] mm: huge_memory: Convert madvise_free_huge_pmd to use a folio Vishal Moola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).