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: remove remaining is_swap_pmd() users and is_swap_pmd()

Update copy_huge_pmd() and change_huge_pmd() to use
pmd_is_valid_softleaf() - as this checks for the only valid non-present
huge PMD states.

Also update mm/debug_vm_pgtable.c to explicitly test for a valid leaf PMD
entry (which it was not before, which was incorrect), and have it test
against pmd_is_huge() and pmd_is_valid_softleaf() rather than
is_swap_pmd().

With these changes done there are no further users of is_swap_pmd(), so
remove it.

Link: https://lkml.kernel.org/r/1628b00b00c8498bbd2c20b82117ee87845fb738.1762812360.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Chris Li <chrisl@kernel.org>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Janosch Frank <frankja@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Xu <weixugc@google.com>
Cc: xu xin <xu.xin16@zte.com.cn>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
c0a80c2c 15eabc89

+18 -21
-9
include/linux/huge_mm.h
··· 486 486 spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma); 487 487 spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma); 488 488 489 - static inline int is_swap_pmd(pmd_t pmd) 490 - { 491 - return !pmd_none(pmd) && !pmd_present(pmd); 492 - } 493 - 494 489 /* mmap_lock must be held on entry */ 495 490 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, 496 491 struct vm_area_struct *vma) ··· 686 691 unsigned long end, 687 692 struct vm_area_struct *next) 688 693 { 689 - } 690 - static inline int is_swap_pmd(pmd_t pmd) 691 - { 692 - return 0; 693 694 } 694 695 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, 695 696 struct vm_area_struct *vma)
+15 -10
mm/debug_vm_pgtable.c
··· 74 74 unsigned long fixed_pte_pfn; 75 75 76 76 swp_entry_t swp_entry; 77 + swp_entry_t leaf_entry; 77 78 }; 78 79 79 80 static void __init pte_basic_tests(struct pgtable_debug_args *args, int idx) ··· 746 745 WARN_ON(pmd_soft_dirty(pmd_clear_soft_dirty(pmd))); 747 746 } 748 747 749 - static void __init pmd_swap_soft_dirty_tests(struct pgtable_debug_args *args) 748 + static void __init pmd_leaf_soft_dirty_tests(struct pgtable_debug_args *args) 750 749 { 751 750 pmd_t pmd; 752 751 ··· 758 757 return; 759 758 760 759 pr_debug("Validating PMD swap soft dirty\n"); 761 - pmd = swp_entry_to_pmd(args->swp_entry); 762 - WARN_ON(!is_swap_pmd(pmd)); 760 + pmd = swp_entry_to_pmd(args->leaf_entry); 761 + WARN_ON(!pmd_is_huge(pmd)); 762 + WARN_ON(!pmd_is_valid_softleaf(pmd)); 763 763 764 764 WARN_ON(!pmd_swp_soft_dirty(pmd_swp_mksoft_dirty(pmd))); 765 765 WARN_ON(pmd_swp_soft_dirty(pmd_swp_clear_soft_dirty(pmd))); 766 766 } 767 767 #else /* !CONFIG_TRANSPARENT_HUGEPAGE */ 768 768 static void __init pmd_soft_dirty_tests(struct pgtable_debug_args *args) { } 769 - static void __init pmd_swap_soft_dirty_tests(struct pgtable_debug_args *args) { } 769 + static void __init pmd_leaf_soft_dirty_tests(struct pgtable_debug_args *args) { } 770 770 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 771 771 772 772 static void __init pte_swap_exclusive_tests(struct pgtable_debug_args *args) ··· 820 818 } 821 819 822 820 #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION 823 - static void __init pmd_swap_tests(struct pgtable_debug_args *args) 821 + static void __init pmd_softleaf_tests(struct pgtable_debug_args *args) 824 822 { 825 823 swp_entry_t arch_entry; 826 824 pmd_t pmd1, pmd2; ··· 829 827 return; 830 828 831 829 pr_debug("Validating PMD swap\n"); 832 - pmd1 = swp_entry_to_pmd(args->swp_entry); 833 - WARN_ON(!is_swap_pmd(pmd1)); 830 + pmd1 = swp_entry_to_pmd(args->leaf_entry); 831 + WARN_ON(!pmd_is_huge(pmd1)); 832 + WARN_ON(!pmd_is_valid_softleaf(pmd1)); 834 833 835 834 arch_entry = __pmd_to_swp_entry(pmd1); 836 835 pmd2 = __swp_entry_to_pmd(arch_entry); 837 836 WARN_ON(memcmp(&pmd1, &pmd2, sizeof(pmd1))); 838 837 } 839 838 #else /* !CONFIG_ARCH_ENABLE_THP_MIGRATION */ 840 - static void __init pmd_swap_tests(struct pgtable_debug_args *args) { } 839 + static void __init pmd_softleaf_tests(struct pgtable_debug_args *args) { } 841 840 #endif /* CONFIG_ARCH_ENABLE_THP_MIGRATION */ 842 841 843 842 static void __init swap_migration_tests(struct pgtable_debug_args *args) ··· 1232 1229 max_swap_offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0, ~0UL)))); 1233 1230 /* Create a swp entry with all possible bits set while still being swap. */ 1234 1231 args->swp_entry = swp_entry(MAX_SWAPFILES - 1, max_swap_offset); 1232 + /* Create a non-present migration entry. */ 1233 + args->leaf_entry = make_writable_migration_entry(~0UL); 1235 1234 1236 1235 /* 1237 1236 * Allocate (huge) pages because some of the tests need to access ··· 1323 1318 pte_soft_dirty_tests(&args); 1324 1319 pmd_soft_dirty_tests(&args); 1325 1320 pte_swap_soft_dirty_tests(&args); 1326 - pmd_swap_soft_dirty_tests(&args); 1321 + pmd_leaf_soft_dirty_tests(&args); 1327 1322 1328 1323 pte_swap_exclusive_tests(&args); 1329 1324 1330 1325 pte_swap_tests(&args); 1331 - pmd_swap_tests(&args); 1326 + pmd_softleaf_tests(&args); 1332 1327 1333 1328 swap_migration_tests(&args); 1334 1329
+3 -2
mm/huge_memory.c
··· 1800 1800 ret = -EAGAIN; 1801 1801 pmd = *src_pmd; 1802 1802 1803 - if (unlikely(thp_migration_supported() && is_swap_pmd(pmd))) { 1803 + if (unlikely(thp_migration_supported() && 1804 + pmd_is_valid_softleaf(pmd))) { 1804 1805 copy_huge_non_present_pmd(dst_mm, src_mm, dst_pmd, src_pmd, addr, 1805 1806 dst_vma, src_vma, pmd, pgtable); 1806 1807 ret = 0; ··· 2488 2487 if (!ptl) 2489 2488 return 0; 2490 2489 2491 - if (thp_migration_supported() && is_swap_pmd(*pmd)) { 2490 + if (thp_migration_supported() && pmd_is_valid_softleaf(*pmd)) { 2492 2491 change_non_present_huge_pmd(mm, addr, pmd, uffd_wp, 2493 2492 uffd_wp_resolve); 2494 2493 goto unlock;