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 the MMU notifier's young flag check

The MMU notifier young flag check related functions only return whether
the young flag was set. Change the return type to bool to make the
intention clearer.

Link: https://lkml.kernel.org/r/a9ad3fe938002d87358e7bfca264f753ab602561.1774075004.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.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: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baolin Wang and committed by
Andrew Morton
1fc7dc67 fb87c882

+66 -80
+35 -41
include/linux/mmu_notifier.h
··· 97 97 * Start-end is necessary in case the secondary MMU is mapping the page 98 98 * at a smaller granularity than the primary MMU. 99 99 */ 100 - int (*clear_flush_young)(struct mmu_notifier *subscription, 101 - struct mm_struct *mm, 102 - unsigned long start, 103 - unsigned long end); 100 + bool (*clear_flush_young)(struct mmu_notifier *subscription, 101 + struct mm_struct *mm, 102 + unsigned long start, 103 + unsigned long end); 104 104 105 105 /* 106 106 * clear_young is a lightweight version of clear_flush_young. Like the 107 107 * latter, it is supposed to test-and-clear the young/accessed bitflag 108 108 * in the secondary pte, but it may omit flushing the secondary tlb. 109 109 */ 110 - int (*clear_young)(struct mmu_notifier *subscription, 111 - struct mm_struct *mm, 112 - unsigned long start, 113 - unsigned long end); 110 + bool (*clear_young)(struct mmu_notifier *subscription, 111 + struct mm_struct *mm, 112 + unsigned long start, 113 + unsigned long end); 114 114 115 115 /* 116 116 * test_young is called to check the young/accessed bitflag in ··· 118 118 * frequently used without actually clearing the flag or tearing 119 119 * down the secondary mapping on the page. 120 120 */ 121 - int (*test_young)(struct mmu_notifier *subscription, 122 - struct mm_struct *mm, 123 - unsigned long address); 121 + bool (*test_young)(struct mmu_notifier *subscription, 122 + struct mm_struct *mm, 123 + unsigned long address); 124 124 125 125 /* 126 126 * invalidate_range_start() and invalidate_range_end() must be ··· 376 376 377 377 extern void __mmu_notifier_subscriptions_destroy(struct mm_struct *mm); 378 378 extern void __mmu_notifier_release(struct mm_struct *mm); 379 - extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm, 380 - unsigned long start, 381 - unsigned long end); 382 - extern int __mmu_notifier_clear_young(struct mm_struct *mm, 383 - unsigned long start, 384 - unsigned long end); 385 - extern int __mmu_notifier_test_young(struct mm_struct *mm, 386 - unsigned long address); 379 + bool __mmu_notifier_clear_flush_young(struct mm_struct *mm, 380 + unsigned long start, unsigned long end); 381 + bool __mmu_notifier_clear_young(struct mm_struct *mm, 382 + unsigned long start, unsigned long end); 383 + bool __mmu_notifier_test_young(struct mm_struct *mm, 384 + unsigned long address); 387 385 extern int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *r); 388 386 extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r); 389 387 extern void __mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm, ··· 401 403 __mmu_notifier_release(mm); 402 404 } 403 405 404 - static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm, 405 - unsigned long start, 406 - unsigned long end) 406 + static inline bool mmu_notifier_clear_flush_young(struct mm_struct *mm, 407 + unsigned long start, unsigned long end) 407 408 { 408 409 if (mm_has_notifiers(mm)) 409 410 return __mmu_notifier_clear_flush_young(mm, start, end); 410 - return 0; 411 + return false; 411 412 } 412 413 413 - static inline int mmu_notifier_clear_young(struct mm_struct *mm, 414 - unsigned long start, 415 - unsigned long end) 414 + static inline bool mmu_notifier_clear_young(struct mm_struct *mm, 415 + unsigned long start, unsigned long end) 416 416 { 417 417 if (mm_has_notifiers(mm)) 418 418 return __mmu_notifier_clear_young(mm, start, end); 419 - return 0; 419 + return false; 420 420 } 421 421 422 - static inline int mmu_notifier_test_young(struct mm_struct *mm, 423 - unsigned long address) 422 + static inline bool mmu_notifier_test_young(struct mm_struct *mm, 423 + unsigned long address) 424 424 { 425 425 if (mm_has_notifiers(mm)) 426 426 return __mmu_notifier_test_young(mm, address); 427 - return 0; 427 + return false; 428 428 } 429 429 430 430 static inline void ··· 548 552 { 549 553 } 550 554 551 - static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm, 552 - unsigned long start, 553 - unsigned long end) 555 + static inline bool mmu_notifier_clear_flush_young(struct mm_struct *mm, 556 + unsigned long start, unsigned long end) 554 557 { 555 - return 0; 558 + return false; 556 559 } 557 560 558 - static inline int mmu_notifier_clear_young(struct mm_struct *mm, 559 - unsigned long start, 560 - unsigned long end) 561 + static inline bool mmu_notifier_clear_young(struct mm_struct *mm, 562 + unsigned long start, unsigned long end) 561 563 { 562 - return 0; 564 + return false; 563 565 } 564 566 565 - static inline int mmu_notifier_test_young(struct mm_struct *mm, 566 - unsigned long address) 567 + static inline bool mmu_notifier_test_young(struct mm_struct *mm, 568 + unsigned long address) 567 569 { 568 - return 0; 570 + return false; 569 571 } 570 572 571 573 static inline void
+8 -8
mm/internal.h
··· 1860 1860 } 1861 1861 1862 1862 #ifdef CONFIG_MMU_NOTIFIER 1863 - static inline int clear_flush_young_ptes_notify(struct vm_area_struct *vma, 1863 + static inline bool clear_flush_young_ptes_notify(struct vm_area_struct *vma, 1864 1864 unsigned long addr, pte_t *ptep, unsigned int nr) 1865 1865 { 1866 - int young; 1866 + bool young; 1867 1867 1868 1868 young = clear_flush_young_ptes(vma, addr, ptep, nr); 1869 1869 young |= mmu_notifier_clear_flush_young(vma->vm_mm, addr, ··· 1871 1871 return young; 1872 1872 } 1873 1873 1874 - static inline int pmdp_clear_flush_young_notify(struct vm_area_struct *vma, 1874 + static inline bool pmdp_clear_flush_young_notify(struct vm_area_struct *vma, 1875 1875 unsigned long addr, pmd_t *pmdp) 1876 1876 { 1877 - int young; 1877 + bool young; 1878 1878 1879 1879 young = pmdp_clear_flush_young(vma, addr, pmdp); 1880 1880 young |= mmu_notifier_clear_flush_young(vma->vm_mm, addr, addr + PMD_SIZE); 1881 1881 return young; 1882 1882 } 1883 1883 1884 - static inline int test_and_clear_young_ptes_notify(struct vm_area_struct *vma, 1884 + static inline bool test_and_clear_young_ptes_notify(struct vm_area_struct *vma, 1885 1885 unsigned long addr, pte_t *ptep, unsigned int nr) 1886 1886 { 1887 - int young; 1887 + bool young; 1888 1888 1889 1889 young = test_and_clear_young_ptes(vma, addr, ptep, nr); 1890 1890 young |= mmu_notifier_clear_young(vma->vm_mm, addr, addr + nr * PAGE_SIZE); 1891 1891 return young; 1892 1892 } 1893 1893 1894 - static inline int pmdp_test_and_clear_young_notify(struct vm_area_struct *vma, 1894 + static inline bool pmdp_test_and_clear_young_notify(struct vm_area_struct *vma, 1895 1895 unsigned long addr, pmd_t *pmdp) 1896 1896 { 1897 - int young; 1897 + bool young; 1898 1898 1899 1899 young = pmdp_test_and_clear_young(vma, addr, pmdp); 1900 1900 young |= mmu_notifier_clear_young(vma->vm_mm, addr, addr + PMD_SIZE);
+12 -11
mm/mmu_notifier.c
··· 364 364 * unmap the address and return 1 or 0 depending if the mapping previously 365 365 * existed or not. 366 366 */ 367 - int __mmu_notifier_clear_flush_young(struct mm_struct *mm, 368 - unsigned long start, 369 - unsigned long end) 367 + bool __mmu_notifier_clear_flush_young(struct mm_struct *mm, 368 + unsigned long start, unsigned long end) 370 369 { 371 370 struct mmu_notifier *subscription; 372 - int young = 0, id; 371 + bool young = false; 372 + int id; 373 373 374 374 id = srcu_read_lock(&srcu); 375 375 hlist_for_each_entry_srcu(subscription, ··· 384 384 return young; 385 385 } 386 386 387 - int __mmu_notifier_clear_young(struct mm_struct *mm, 388 - unsigned long start, 389 - unsigned long end) 387 + bool __mmu_notifier_clear_young(struct mm_struct *mm, 388 + unsigned long start, unsigned long end) 390 389 { 391 390 struct mmu_notifier *subscription; 392 - int young = 0, id; 391 + bool young = false; 392 + int id; 393 393 394 394 id = srcu_read_lock(&srcu); 395 395 hlist_for_each_entry_srcu(subscription, ··· 404 404 return young; 405 405 } 406 406 407 - int __mmu_notifier_test_young(struct mm_struct *mm, 408 - unsigned long address) 407 + bool __mmu_notifier_test_young(struct mm_struct *mm, 408 + unsigned long address) 409 409 { 410 410 struct mmu_notifier *subscription; 411 - int young = 0, id; 411 + bool young = false; 412 + int id; 412 413 413 414 id = srcu_read_lock(&srcu); 414 415 hlist_for_each_entry_srcu(subscription,
+11 -20
virt/kvm/kvm_main.c
··· 646 646 return r; 647 647 } 648 648 649 - static __always_inline int kvm_age_hva_range(struct mmu_notifier *mn, 650 - unsigned long start, 651 - unsigned long end, 652 - gfn_handler_t handler, 653 - bool flush_on_ret) 649 + static __always_inline bool kvm_age_hva_range(struct mmu_notifier *mn, 650 + unsigned long start, unsigned long end, gfn_handler_t handler, 651 + bool flush_on_ret) 654 652 { 655 653 struct kvm *kvm = mmu_notifier_to_kvm(mn); 656 654 const struct kvm_mmu_notifier_range range = { ··· 664 666 return kvm_handle_hva_range(kvm, &range).ret; 665 667 } 666 668 667 - static __always_inline int kvm_age_hva_range_no_flush(struct mmu_notifier *mn, 668 - unsigned long start, 669 - unsigned long end, 670 - gfn_handler_t handler) 669 + static __always_inline bool kvm_age_hva_range_no_flush(struct mmu_notifier *mn, 670 + unsigned long start, unsigned long end, gfn_handler_t handler) 671 671 { 672 672 return kvm_age_hva_range(mn, start, end, handler, false); 673 673 } ··· 825 829 rcuwait_wake_up(&kvm->mn_memslots_update_rcuwait); 826 830 } 827 831 828 - static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn, 829 - struct mm_struct *mm, 830 - unsigned long start, 831 - unsigned long end) 832 + static bool kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn, 833 + struct mm_struct *mm, unsigned long start, unsigned long end) 832 834 { 833 835 trace_kvm_age_hva(start, end); 834 836 ··· 834 840 !IS_ENABLED(CONFIG_KVM_ELIDE_TLB_FLUSH_IF_YOUNG)); 835 841 } 836 842 837 - static int kvm_mmu_notifier_clear_young(struct mmu_notifier *mn, 838 - struct mm_struct *mm, 839 - unsigned long start, 840 - unsigned long end) 843 + static bool kvm_mmu_notifier_clear_young(struct mmu_notifier *mn, 844 + struct mm_struct *mm, unsigned long start, unsigned long end) 841 845 { 842 846 trace_kvm_age_hva(start, end); 843 847 ··· 855 863 return kvm_age_hva_range_no_flush(mn, start, end, kvm_age_gfn); 856 864 } 857 865 858 - static int kvm_mmu_notifier_test_young(struct mmu_notifier *mn, 859 - struct mm_struct *mm, 860 - unsigned long address) 866 + static bool kvm_mmu_notifier_test_young(struct mmu_notifier *mn, 867 + struct mm_struct *mm, unsigned long address) 861 868 { 862 869 trace_kvm_test_age_hva(address); 863 870