[4/5] khugepage: Replace lru_cache_add() with folio_add_lru()

Message ID 20221101175326.13265-5-vishal.moola@gmail.com
State New
Headers
Series Removing the lru_cache_add() wrapper |

Commit Message

Vishal Moola Nov. 1, 2022, 5:53 p.m. UTC
  Replaces some calls with their folio equivalents. This is in preparation
for the removal of lru_cache_add(). This replaces 3 calls to
compound_head() with 1.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
 mm/khugepaged.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
  

Comments

Matthew Wilcox Nov. 1, 2022, 6:32 p.m. UTC | #1
On Tue, Nov 01, 2022 at 10:53:25AM -0700, Vishal Moola (Oracle) wrote:
> Replaces some calls with their folio equivalents. This is in preparation
> for the removal of lru_cache_add(). This replaces 3 calls to
> compound_head() with 1.
> 
> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
  

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 4734315f7940..e432d5279043 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1970,6 +1970,7 @@  static int collapse_file(struct mm_struct *mm, unsigned long addr,
 
 	if (result == SCAN_SUCCEED) {
 		struct page *page, *tmp;
+		struct folio *folio;
 
 		/*
 		 * Replacing old pages with new one has succeeded, now we
@@ -1997,11 +1998,13 @@  static int collapse_file(struct mm_struct *mm, unsigned long addr,
 			index++;
 		}
 
-		SetPageUptodate(hpage);
-		page_ref_add(hpage, HPAGE_PMD_NR - 1);
+		folio = page_folio(hpage);
+		folio_mark_uptodate(folio);
+		folio_ref_add(folio, HPAGE_PMD_NR - 1);
+
 		if (is_shmem)
-			set_page_dirty(hpage);
-		lru_cache_add(hpage);
+			folio_mark_dirty(folio);
+		folio_add_lru(folio);
 
 		/*
 		 * Remove pte page tables, so we can re-fault the page as huge.