mm: remove page idle and young wrapper
Subsystems (7)
cover mm: remove page idle and young wrapper
Convert to use folio idle and young functions instead of page ones, then remove all page idle and young wrapper.
Kefeng Wang (5):
mm: huge_memory: use more folio api in __split_huge_page_tail()
mm: task_mmu: use a folio in smaps_account()
mm: task_mmu: use a folio in clear_refs_pte_range() fs/proc/page: use a folio in stable_page_flags()
page_idle: kill page idle and young wrapper
fs/proc/page.c | 22 +++++++++++----------- fs/proc/task_mmu.c | 28 +++++++++++++++------------- include/linux/page_idle.h | 25 ------------------------- mm/huge_memory.c | 12 ++++++------ 4 files changed, 32 insertions(+), 55 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/5 mm: huge_memory: use more folio api in __split_huge_page_tail()
Use more folio APIs to save six compound_head() calls in __split_huge_page_tail().
--- mm/huge_memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/huge_memory.c +6 -6
@@ -2507,13 +2507,13 @@ static void __split_huge_page_tail(struct folio *folio, int tail,clear_compound_head (page_tail);/* Finally unfreeze refcount. Additional reference from page cache. */ -page_ref_unfreeze (page_tail,1 + (!PageAnon (head) || -PageSwapCache (head))); +page_ref_unfreeze (page_tail,1 + (!folio_test_anon (folio) || +folio_test_swapcache (folio))); -if (page_is_young (head)) -set_page_young (page_tail); -if (page_is_idle (head)) -set_page_idle (page_tail); +if (folio_test_young (folio)) +folio_set_young (new_folio); +if (folio_test_idle (folio)) +folio_set_idle (new_folio);folio_xchg_last_cpupid (new_folio,folio_last_cpupid (folio));
Signature · 1 line
2.27.0
PATCH 2/5 mm: task_mmu: use a folio in smaps_account()
In reply to Kefeng WangReplace seven implicit calls to compound_head() with one page_folio().
--- fs/proc/task_mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/proc/task_mmu.c +7 -5
@@ -445,23 +445,25 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, {int i, nr = compound ?compound_nr (page) :1 ;unsigned long size = nr *PAGE_SIZE ; +struct folio *folio =page_folio (page);/* * First accumulate quantities that depend only on |size| and the type * of the compound page. */ -if (PageAnon (page)) { +if (folio_test_anon (folio)) { mss->anonymous += size; -if (!PageSwapBacked (page) && !dirty && !PageDirty (page)) +if (!folio_test_swapbacked (folio) && !dirty && + !folio_test_dirty (folio)) mss->lazyfree += size; } -if (PageKsm (page)) +if (folio_test_ksm (folio)) mss->ksm += size; mss->resident += size;/* Accumulate the size in pages that have been accessed. */ -if (young ||page_is_young (page) ||PageReferenced (page)) +if (young ||folio_test_young (folio) ||folio_test_referenced (folio)) mss->referenced += size;/*
@@ -479,7 +481,7 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page,* especially for migration entries. Treat regular migration entries * as mapcount == 1. */ -if ((page_count (page) ==1 ) || migration) { +if ((folio_ref_count (folio) ==1 ) || migration) {smaps_page_accumulate (mss, page, size, size <<PSS_SHIFT , dirty, locked, true);return ;
Signature · 1 line
2.27.0
PATCH 3/5 mm: task_mmu: use a folio in clear_refs_pte_range()
In reply to Kefeng WangUse a folio to save two compound_head() calls in clear_refs_pte_range().
--- fs/proc/task_mmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/proc/task_mmu.c +8 -8
@@ -1161,7 +1161,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,struct vm_area_struct *vma = walk->vma;pte_t *pte, ptent;spinlock_t *ptl; -struct page *page; +struct folio *folio; ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) {
@@ -1173,12 +1173,12 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,if (!pmd_present (*pmd)) goto out; - page =pmd_page (*pmd); + folio =page_folio (pmd_page (*pmd));/* Clear accessed and referenced bits. */ pmdp_test_and_clear_young (vma, addr, pmd); -test_and_clear_page_young (page); -ClearPageReferenced (page); +folio_test_clear_young (folio); +folio_clear_referenced (folio); out:spin_unlock (ptl);return 0 ;
@@ -1200,14 +1200,14 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,if (!pte_present (ptent))continue ; - page =vm_normal_page (vma, addr, ptent); -if (!page) + folio =vm_normal_folio (vma, addr, ptent); +if (!folio)continue ;/* Clear accessed and referenced bits. */ ptep_test_and_clear_young (vma, addr, pte); -test_and_clear_page_young (page); -ClearPageReferenced (page); +folio_test_clear_young (folio); +folio_clear_referenced (folio); }pte_unmap_unlock (pte -1 , ptl);cond_resched ();
Signature · 1 line
2.27.0
PATCH 4/5 fs/proc/page: use a folio in stable_page_flags()
In reply to Kefeng WangReplace ten compound_head() calls with one page_folio().
--- fs/proc/page.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
fs/proc/page.c +11 -11
@@ -109,6 +109,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit)u64 stable_page_flags (struct page *page) { +struct folio *folio;u64 k;u64 u;
@@ -119,6 +120,7 @@ u64 stable_page_flags(struct page *page)if (!page)return 1 <<KPF_NOPAGE ; + folio =page_folio (page); k = page->flags; u =0 ;
@@ -128,11 +130,11 @@ u64 stable_page_flags(struct page *page)* Note that page->_mapcount is overloaded in SLAB, so the * simple test in page_mapped() is not enough. */ -if (!PageSlab (page) &&page_mapped (page)) +if (!folio_test_slab (folio) &&folio_mapped (folio)) u |=1 <<KPF_MMAP ; -if (PageAnon (page)) +if (folio_test_anon (folio)) u |=1 <<KPF_ANON ; -if (PageKsm (page)) +if (folio_test_ksm (folio)) u |=1 <<KPF_KSM ;/*
@@ -152,11 +154,9 @@ u64 stable_page_flags(struct page *page)* to make sure a given page is a thp, not a non-huge compound page. */ else if (PageTransCompound(page)) { -struct page *head =compound_head (page); - -if (PageLRU (head) ||PageAnon (head)) +if (folio_test_lru (folio) ||folio_test_anon (folio)) u |=1 <<KPF_THP ; -else if (is_huge_zero_page (head)) { +else if (is_huge_zero_page (&folio->page)) { u |=1 <<KPF_ZERO_PAGE ; u |=1 <<KPF_THP ; }
@@ -170,7 +170,7 @@ u64 stable_page_flags(struct page *page)*/ if (PageBuddy (page)) u |=1 <<KPF_BUDDY ; -else if (page_count (page) ==0 &&is_free_buddy_page (page)) +else if (folio_ref_count (folio) ==0 &&is_free_buddy_page (page)) u |=1 <<KPF_BUDDY ;if (PageOffline (page))
@@ -178,13 +178,13 @@ u64 stable_page_flags(struct page *page)if (PageTable (page)) u |=1 <<KPF_PGTABLE ; -if (page_is_idle (page)) +if (folio_test_idle (folio)) u |=1 <<KPF_IDLE ; u |=kpf_copy_bit (k,KPF_LOCKED , PG_locked); u |=kpf_copy_bit (k,KPF_SLAB , PG_slab); -if (PageTail (page) &&PageSlab (page)) +if (PageTail (page) &&folio_test_slab (folio)) u |=1 <<KPF_SLAB ; u |=kpf_copy_bit (k,KPF_ERROR , PG_error);
@@ -197,7 +197,7 @@ u64 stable_page_flags(struct page *page) u |=kpf_copy_bit (k,KPF_ACTIVE , PG_active); u |=kpf_copy_bit (k,KPF_RECLAIM , PG_reclaim); -if (PageSwapCache (page)) +if (folio_test_swapcache (folio)) u |=1 <<KPF_SWAPCACHE ; u |=kpf_copy_bit (k,KPF_SWAPBACKED , PG_swapbacked);
Signature · 1 line
2.27.0
Re: [PATCH 4/5] fs/proc/page: use a folio in stable_page_flags()
Quoted 1 line · Kefeng Wang
Replace ten
compound_head()calls with onepage_folio().
This is going to conflict with Gregory Price's work:
https://lore.kernel.org/linux-mm/[email protected]/
Perhaps the two of you can collaborate on a patch series?
fs/proc/page.c u64 stable_page_flags(struct page *page) · line 188
Quoted 4 lines
fs/proc/page.c +1
-1u |=kpf_copy_bit (k,KPF_SLAB , PG_slab); -if (PageTail (page) &&PageSlab (page)) +if (PageTail (page) &&folio_test_slab (folio)) u |=1 <<KPF_SLAB ;
This doesn't make sense ...
Re: [PATCH 4/5] fs/proc/page: use a folio in stable_page_flags()
Quoted 8 lines · Matthew Wilcox
Quoted 1 line · Kefeng Wang
Replace ten
compound_head()calls with onepage_folio().This is going to conflict with Gregory Price's work:
https://lore.kernel.org/linux-mm/[email protected]/
Perhaps the two of you can collaborate on a patch series?
Will check this patch.
Quoted 8 lines
fs/proc/page.c u64 stable_page_flags(struct page *page) · line 188
Quoted 5 lines
u |= kpf_copy_bit(k, KPF_SLAB, PG_slab);fs/proc/page.c +1
-1-if (PageTail (page) &&PageSlab (page)) +if (PageTail (page) &&folio_test_slab (folio)) u |=1 <<KPF_SLAB ;This doesn't make sense ...
Yes, after commit dcb351cd095a ("page-flags: define behavior SL*B- related flags on compound pages"), the slab could not be a tail, I will drop this line.
PATCH 5/5 page_idle: kill page idle and young wrapper
In reply to Kefeng WangSince all the calls of page idle and young functions are gone, let's remove all the wrapper.
--- include/linux/page_idle.h | 25 ------------------------- 1 file changed, 25 deletions(-)
include/linux/page_idle.h +0 -25
@@ -119,29 +119,4 @@ static inline void folio_clear_idle(struct folio *folio) }#endif /* CONFIG_PAGE_IDLE_FLAG */ - -static inline bool page_is_young (struct page *page) -{ -return folio_test_young (page_folio (page)); -} - -static inline void set_page_young (struct page *page) -{ -folio_set_young (page_folio (page)); -} - -static inline bool test_and_clear_page_young (struct page *page) -{ -return folio_test_clear_young (page_folio (page)); -} - -static inline bool page_is_idle (struct page *page) -{ -return folio_test_idle (page_folio (page)); -} - -static inline void set_page_idle (struct page *page) -{ -folio_set_idle (page_folio (page)); -}#endif /* _LINUX_MM_PAGE_IDLE_H */
Signature · 1 line
2.27.0