]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: change to return bool for pmdp_test_and_clear_young()
authorBaolin Wang <baolin.wang@linux.alibaba.com>
Sat, 21 Mar 2026 06:42:51 +0000 (14:42 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:35 +0000 (13:53 -0700)
Callers use pmdp_test_and_clear_young() to clear the young flag and check
whether it was set for this PMD entry.  Change the return type to bool to
make the intention clearer.

Link: https://lkml.kernel.org/r/f1d31307a13365d3d0fed5809727dcc2dd59631b.1774075004.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/arm64/include/asm/pgtable.h
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/mm/book3s64/pgtable.c
arch/riscv/include/asm/pgtable.h
arch/s390/include/asm/pgtable.h
arch/x86/include/asm/pgtable.h
arch/x86/mm/pgtable.c
include/linux/pgtable.h

index 1009f719b15738de0159739f19a7bb0100911d34..52bafe79c10a9b6d5107cc6ac35a35585577ff1f 100644 (file)
@@ -1320,9 +1320,8 @@ static inline bool __ptep_clear_flush_young(struct vm_area_struct *vma,
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG)
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
-static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                           unsigned long address,
-                                           pmd_t *pmdp)
+static inline bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp)
 {
        /* Operation applies to PMD table entry only if FEAT_HAFT is enabled */
        VM_WARN_ON(pmd_table(READ_ONCE(*pmdp)) && !system_supports_haft());
index c049a2e26e2572561c43d5ba8156b4fa30f5aeaa..8b354e81ab220f358d40c7d6b012f29388bfcace 100644 (file)
@@ -1161,13 +1161,13 @@ pud_hugepage_update(struct mm_struct *mm, unsigned long addr, pud_t *pudp,
  * For radix we should always find H_PAGE_HASHPTE zero. Hence
  * the below will work for radix too
  */
-static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
-                                             unsigned long addr, pmd_t *pmdp)
+static inline bool __pmdp_test_and_clear_young(struct mm_struct *mm,
+               unsigned long addr, pmd_t *pmdp)
 {
        unsigned long old;
 
        if ((pmd_raw(*pmdp) & cpu_to_be64(_PAGE_ACCESSED | H_PAGE_HASHPTE)) == 0)
-               return 0;
+               return false;
        old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED, 0);
        return ((old & _PAGE_ACCESSED) != 0);
 }
@@ -1300,8 +1300,8 @@ extern int pudp_set_access_flags(struct vm_area_struct *vma,
                                 pud_t entry, int dirty);
 
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
-extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                    unsigned long address, pmd_t *pmdp);
+bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp);
 #define __HAVE_ARCH_PUDP_TEST_AND_CLEAR_YOUNG
 extern int pudp_test_and_clear_young(struct vm_area_struct *vma,
                                     unsigned long address, pud_t *pudp);
index 4b09c04654a8f26e84f811df61461d83ae71f299..c584321e3d41b60a083a500a1268cbe39f5f7500 100644 (file)
@@ -98,8 +98,8 @@ int pudp_set_access_flags(struct vm_area_struct *vma, unsigned long address,
 }
 
 
-int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                             unsigned long address, pmd_t *pmdp)
+bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp)
 {
        return __pmdp_test_and_clear_young(vma->vm_mm, address, pmdp);
 }
index b9dacfc280b1be72ab6d7da8d91904008c44f857..67e7746e3fbead9ba2697f69b0b662bbd5ea139d 100644 (file)
@@ -1015,8 +1015,8 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
 }
 
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
-static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                       unsigned long address, pmd_t *pmdp)
+static inline bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp)
 {
        return ptep_test_and_clear_young(vma, address, (pte_t *)pmdp);
 }
index ac74b5076d8f0f3a71be6cf8f693b8e66cd8b7b2..87a5082da28e45375071f72bda625a6672195d15 100644 (file)
@@ -1683,8 +1683,8 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
 }
 
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
-static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                           unsigned long addr, pmd_t *pmdp)
+static inline bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long addr, pmd_t *pmdp)
 {
        pmd_t pmd = *pmdp;
 
index 3993657e0a3518c1772c35c9c8281c5b3f6c006c..ba867bac6096cb8b83063410d7920b3e9362eb1d 100644 (file)
@@ -1295,8 +1295,8 @@ extern int pudp_set_access_flags(struct vm_area_struct *vma,
                                 pud_t entry, int dirty);
 
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
-extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                    unsigned long addr, pmd_t *pmdp);
+bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long addr, pmd_t *pmdp);
 extern int pudp_test_and_clear_young(struct vm_area_struct *vma,
                                     unsigned long addr, pud_t *pudp);
 
index 1348384a3bb9c77e6ec3b1a080195af837cfa592..b09e8c5dadf93370f465f0408fd5d2bf4ae1d7bc 100644 (file)
@@ -456,10 +456,10 @@ bool ptep_test_and_clear_young(struct vm_area_struct *vma,
 }
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG)
-int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                             unsigned long addr, pmd_t *pmdp)
+bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long addr, pmd_t *pmdp)
 {
-       int ret = 0;
+       bool ret = false;
 
        if (pmd_young(*pmdp))
                ret = test_and_clear_bit(_PAGE_BIT_ACCESSED,
index 99450a3b070534f292d7c78c914ee30160f9832d..6db900a5d38b4d1f610e80723c36b3e7483c4cff 100644 (file)
@@ -507,25 +507,24 @@ static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma,
 
 #ifndef __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG)
-static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                           unsigned long address,
-                                           pmd_t *pmdp)
+static inline bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp)
 {
        pmd_t pmd = *pmdp;
-       int r = 1;
+       bool young = true;
+
        if (!pmd_young(pmd))
-               r = 0;
+               young = false;
        else
                set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
-       return r;
+       return young;
 }
 #else
-static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-                                           unsigned long address,
-                                           pmd_t *pmdp)
+static inline bool pmdp_test_and_clear_young(struct vm_area_struct *vma,
+               unsigned long address, pmd_t *pmdp)
 {
        BUILD_BUG();
-       return 0;
+       return false;
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG */
 #endif