Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: change to return bool for ptep_clear_flush_young()/clear_flush_young_ptes()

The ptep_clear_flush_young() and clear_flush_young_ptes() are used to
clear the young flag and flush the TLB, returning whether the young flag
was set. Change the return type to bool to make the intention clearer.

Link: https://lkml.kernel.org/r/24af5144b96103631594501f77d4525f2475c1be.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>

authored by

Baolin Wang and committed by
Andrew Morton
06c4dfa3 a62ca3f4

+33 -34
+8 -9
arch/arm64/include/asm/pgtable.h
··· 1298 1298 return pte_young(pte); 1299 1299 } 1300 1300 1301 - static inline int __ptep_clear_flush_young(struct vm_area_struct *vma, 1302 - unsigned long address, pte_t *ptep) 1301 + static inline bool __ptep_clear_flush_young(struct vm_area_struct *vma, 1302 + unsigned long address, pte_t *ptep) 1303 1303 { 1304 - int young = __ptep_test_and_clear_young(vma, address, ptep); 1304 + bool young = __ptep_test_and_clear_young(vma, address, ptep); 1305 1305 1306 1306 if (young) { 1307 1307 /* ··· 1647 1647 unsigned int nr, int full); 1648 1648 bool contpte_test_and_clear_young_ptes(struct vm_area_struct *vma, 1649 1649 unsigned long addr, pte_t *ptep, unsigned int nr); 1650 - int contpte_clear_flush_young_ptes(struct vm_area_struct *vma, 1650 + bool contpte_clear_flush_young_ptes(struct vm_area_struct *vma, 1651 1651 unsigned long addr, pte_t *ptep, unsigned int nr); 1652 1652 extern void contpte_wrprotect_ptes(struct mm_struct *mm, unsigned long addr, 1653 1653 pte_t *ptep, unsigned int nr); ··· 1829 1829 } 1830 1830 1831 1831 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 1832 - static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 1833 - unsigned long addr, pte_t *ptep) 1832 + static inline bool ptep_clear_flush_young(struct vm_area_struct *vma, 1833 + unsigned long addr, pte_t *ptep) 1834 1834 { 1835 1835 pte_t orig_pte = __ptep_get(ptep); 1836 1836 ··· 1841 1841 } 1842 1842 1843 1843 #define clear_flush_young_ptes clear_flush_young_ptes 1844 - static inline int clear_flush_young_ptes(struct vm_area_struct *vma, 1845 - unsigned long addr, pte_t *ptep, 1846 - unsigned int nr) 1844 + static inline bool clear_flush_young_ptes(struct vm_area_struct *vma, 1845 + unsigned long addr, pte_t *ptep, unsigned int nr) 1847 1846 { 1848 1847 if (likely(nr == 1 && !pte_cont(__ptep_get(ptep)))) 1849 1848 return __ptep_clear_flush_young(vma, addr, ptep);
+3 -4
arch/arm64/mm/contpte.c
··· 534 534 } 535 535 EXPORT_SYMBOL_GPL(contpte_test_and_clear_young_ptes); 536 536 537 - int contpte_clear_flush_young_ptes(struct vm_area_struct *vma, 538 - unsigned long addr, pte_t *ptep, 539 - unsigned int nr) 537 + bool contpte_clear_flush_young_ptes(struct vm_area_struct *vma, 538 + unsigned long addr, pte_t *ptep, unsigned int nr) 540 539 { 541 - int young; 540 + bool young; 542 541 543 542 young = contpte_test_and_clear_young_ptes(vma, addr, ptep, nr); 544 543
+1 -1
arch/parisc/include/asm/pgtable.h
··· 451 451 return true; 452 452 } 453 453 454 - int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep); 454 + bool ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep); 455 455 pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep); 456 456 457 457 struct mm_struct;
+4 -4
arch/parisc/kernel/cache.c
··· 781 781 __flush_cache_page(vma, vmaddr, PFN_PHYS(page_to_pfn(page))); 782 782 } 783 783 784 - int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, 785 - pte_t *ptep) 784 + bool ptep_clear_flush_young(struct vm_area_struct *vma, 785 + unsigned long addr, pte_t *ptep) 786 786 { 787 787 pte_t pte = ptep_get(ptep); 788 788 789 789 if (!pte_young(pte)) 790 - return 0; 790 + return false; 791 791 set_pte(ptep, pte_mkold(pte)); 792 792 #if CONFIG_FLUSH_PAGE_ACCESSED 793 793 __flush_cache_page(vma, addr, PFN_PHYS(pte_pfn(pte))); 794 794 #endif 795 - return 1; 795 + return true; 796 796 } 797 797 798 798 /*
+1 -1
arch/powerpc/include/asm/nohash/64/pgtable.h
··· 155 155 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 156 156 #define ptep_clear_flush_young(__vma, __address, __ptep) \ 157 157 ({ \ 158 - int __young = ptep_test_and_clear_young(__vma, __address, __ptep);\ 158 + bool __young = ptep_test_and_clear_young(__vma, __address, __ptep);\ 159 159 __young; \ 160 160 }) 161 161
+2 -2
arch/riscv/include/asm/pgtable.h
··· 695 695 } 696 696 697 697 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 698 - static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 699 - unsigned long address, pte_t *ptep) 698 + static inline bool ptep_clear_flush_young(struct vm_area_struct *vma, 699 + unsigned long address, pte_t *ptep) 700 700 { 701 701 /* 702 702 * This comment is borrowed from x86, but applies equally to RISC-V:
+2 -2
arch/s390/include/asm/pgtable.h
··· 1174 1174 } 1175 1175 1176 1176 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 1177 - static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 1178 - unsigned long address, pte_t *ptep) 1177 + static inline bool ptep_clear_flush_young(struct vm_area_struct *vma, 1178 + unsigned long address, pte_t *ptep) 1179 1179 { 1180 1180 return ptep_test_and_clear_young(vma, address, ptep); 1181 1181 }
+2 -2
arch/x86/include/asm/pgtable.h
··· 1236 1236 unsigned long addr, pte_t *ptep); 1237 1237 1238 1238 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 1239 - extern int ptep_clear_flush_young(struct vm_area_struct *vma, 1240 - unsigned long address, pte_t *ptep); 1239 + bool ptep_clear_flush_young(struct vm_area_struct *vma, 1240 + unsigned long address, pte_t *ptep); 1241 1241 1242 1242 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR 1243 1243 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+2 -2
arch/x86/mm/pgtable.c
··· 483 483 } 484 484 #endif 485 485 486 - int ptep_clear_flush_young(struct vm_area_struct *vma, 487 - unsigned long address, pte_t *ptep) 486 + bool ptep_clear_flush_young(struct vm_area_struct *vma, 487 + unsigned long address, pte_t *ptep) 488 488 { 489 489 /* 490 490 * On x86 CPUs, clearing the accessed bit without a TLB flush
+4 -4
include/linux/pgtable.h
··· 531 531 #endif 532 532 533 533 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 534 - int ptep_clear_flush_young(struct vm_area_struct *vma, 535 - unsigned long address, pte_t *ptep); 534 + bool ptep_clear_flush_young(struct vm_area_struct *vma, 535 + unsigned long address, pte_t *ptep); 536 536 #endif 537 537 538 538 #ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH ··· 1086 1086 * Context: The caller holds the page table lock. The PTEs map consecutive 1087 1087 * pages that belong to the same folio. The PTEs are all in the same PMD. 1088 1088 */ 1089 - static inline int clear_flush_young_ptes(struct vm_area_struct *vma, 1089 + static inline bool clear_flush_young_ptes(struct vm_area_struct *vma, 1090 1090 unsigned long addr, pte_t *ptep, unsigned int nr) 1091 1091 { 1092 - int young = 0; 1092 + bool young = false; 1093 1093 1094 1094 for (;;) { 1095 1095 young |= ptep_clear_flush_young(vma, addr, ptep);
+4 -3
mm/pgtable-generic.c
··· 81 81 #endif 82 82 83 83 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 84 - int ptep_clear_flush_young(struct vm_area_struct *vma, 85 - unsigned long address, pte_t *ptep) 84 + bool ptep_clear_flush_young(struct vm_area_struct *vma, 85 + unsigned long address, pte_t *ptep) 86 86 { 87 - int young; 87 + bool young; 88 + 88 89 young = ptep_test_and_clear_young(vma, address, ptep); 89 90 if (young) 90 91 flush_tlb_page(vma, address);