Remove page_idle and page_young wrappers
Subsystems (6)
cover Remove page_idle and page_young wrappers
There are only a couple of places left using the page wrappers for idle & young tracking. Convert the two users in proc and then we can remove the wrappers. That enables the further simplification of autogenerating the definitions when CONFIG_PAGE_IDLE_FLAG is disabled.
Matthew Wilcox (Oracle) (4):
proc: Convert clear_refs_pte_range to use a folio
proc: Convert smaps_account() to use a folio
mm: Remove page_idle and page_young wrappers
mm: Generate PAGE_IDLE_FLAG definitions
fs/proc/task_mmu.c | 32 +++++++++++--------- include/linux/page-flags.h | 9 +++++- include/linux/page_idle.h | 62 ++------------------------------------ 3 files changed, 27 insertions(+), 76 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 proc: Convert clear_refs_pte_range to use a folio
Replaces four calls to compound_head() with two.
--- 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 =pmd_folio (*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.43.0
Re: [PATCH 1/4] proc: Convert clear_refs_pte_range to use a folio
Quoted 4 lines · Matthew Wilcox (Oracle)
Replaces four calls to
compound_head()with two.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>---
Signature · 3 lines
Cheers, David / dhildenb
PATCH 2/4 proc: Convert smaps_account() to use a folio
In reply to Matthew Wilcox (Oracle)Replace seven calls to compound_head() with one.
--- fs/proc/task_mmu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
fs/proc/task_mmu.c +9 -7
@@ -444,6 +444,7 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, bool compound, bool young, bool dirty, bool locked, bool migration) { + struct folio *folio = page_folio(page);int i, nr = compound ?compound_nr (page) :1 ;unsigned long size = nr *PAGE_SIZE ;
@@ -451,27 +452,28 @@ static void smaps_account(struct mem_size_stats *mss, struct page *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;/* * Then accumulate quantities that may depend on sharing, or that may * differ page-by-page. * -* page_count(page) == 1 guarantees the page is mapped exactly once. +* refcount == 1 guarantees the page is mapped exactly once. * If any subpage of the compound page mapped with PTE it would elevate -* page_count(). +* the refcount. * * The page_mapcount() is called to get a snapshot of the mapcount. * Without holding the page lock this snapshot can be slightly wrong as
@@ -480,7 +482,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.43.0
Re: [PATCH 2/4] proc: Convert smaps_account() to use a folio
Quoted 4 lines · Matthew Wilcox (Oracle)
Replace seven calls to
compound_head()with one.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>---
Signature · 3 lines
Cheers, David / dhildenb
PATCH 3/4 mm: Remove page_idle and page_young wrappers
In reply to Matthew Wilcox (Oracle)All users have now been converted to the folio equivalents, so remove the page wrappers.
--- 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.43.0
Re: [PATCH 3/4] mm: Remove page_idle and page_young wrappers
Quoted 5 lines · Matthew Wilcox (Oracle)
All users have now been converted to the folio equivalents, so remove the page wrappers.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>---
Signature · 3 lines
Cheers, David / dhildenb
PATCH 4/4 mm: Generate PAGE_IDLE_FLAG definitions
In reply to Matthew Wilcox (Oracle)If CONFIG_PAGE_IDLE_FLAG is not set, we can use FOLIO_FLAG_FALSE() to generate these definitions.
--- include/linux/page-flags.h | 9 ++++++++- include/linux/page_idle.h | 37 ++----------------------------------- 2 files changed, 10 insertions(+), 36 deletions(-)
include/linux/page-flags.h +8 -1
@@ -626,12 +626,19 @@ PAGEFLAG_FALSE(HWPoison, hwpoison)#define __PG_HWPOISON 0#endif -#if defined(CONFIG_PAGE_IDLE_FLAG ) && defined(CONFIG_64BIT ) +#ifdef CONFIG_PAGE_IDLE_FLAG +#ifdef CONFIG_64BIT FOLIO_TEST_FLAG(young, FOLIO_HEAD_PAGE) FOLIO_SET_FLAG(young, FOLIO_HEAD_PAGE) FOLIO_TEST_CLEAR_FLAG(young, FOLIO_HEAD_PAGE) FOLIO_FLAG(idle, FOLIO_HEAD_PAGE)#endif +/* See page_idle.h for !64BIT workaround */ +#else /* !CONFIG_PAGE_IDLE_FLAG */ +FOLIO_FLAG_FALSE(young) +FOLIO_TEST_CLEAR_FLAG_FALSE(young) +FOLIO_FLAG_FALSE(idle) +#endif /* * PageReported() is used to track reported free pages within the Buddy
include/linux/page_idle.h +2 -35
@@ -6,9 +6,7 @@#include <linux/page-flags.h> #include <linux/page_ext.h> -#ifdef CONFIG_PAGE_IDLE_FLAG - -#ifndef CONFIG_64BIT +#if defined(CONFIG_PAGE_IDLE_FLAG ) && !defined(CONFIG_64BIT )/* * If there is not enough space to store Idle and Young bits in page flags, use * page ext flags instead.
@@ -87,36 +85,5 @@ static inline void folio_clear_idle(struct folio *folio)clear_bit (PAGE_EXT_IDLE , &page_ext->flags);page_ext_put (page_ext); } -#endif /* !CONFIG_64BIT */ - -#else /* !CONFIG_PAGE_IDLE_FLAG */ - -static inline bool folio_test_young (const struct folio *folio) -{ -return false; -} - -static inline void folio_set_young (struct folio *folio) -{ -} - -static inline bool folio_test_clear_young (struct folio *folio) -{ -return false; -} - -static inline bool folio_test_idle (const struct folio *folio) -{ -return false; -} - -static inline void folio_set_idle (struct folio *folio) -{ -} - -static inline void folio_clear_idle (struct folio *folio) -{ -} - -#endif /* CONFIG_PAGE_IDLE_FLAG */ +#endif /* CONFIG_PAGE_IDLE_FLAG && !64BIT */ #endif /* _LINUX_MM_PAGE_IDLE_H */
Signature · 1 line
2.43.0
Re: [PATCH 4/4] mm: Generate PAGE_IDLE_FLAG definitions
Quoted 5 lines · Matthew Wilcox (Oracle)
If
CONFIG_PAGE_IDLE_FLAGis not set, we can useFOLIO_FLAG_FALSE()to generate these definitions.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>---
Signature · 3 lines
Cheers, David / dhildenb