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: use leaf entries in debug pgtable + remove is_swap_pte()

Remove invocations of is_swap_pte() in mm/debug_vm_pgtable.c and use
softleaf_from_pte() and softleaf_is_swap() as necessary to replace this
usage.

We update the test code to use a 'true' swap entry throughout so we are
guaranteed this is not a non-swap entry, so all asserts continue to
operate correctly.

With this change in place, we no longer use is_swap_pte() anywhere, so
remove it.

Link: https://lkml.kernel.org/r/222f352e7a99191b4bdfa77e835f2fc0dd83fa72.1762812360.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
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: 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
fb410d8b 06fb6146

+24 -21
-6
include/linux/swapops.h
··· 120 120 return swp_offset(entry) & SWP_PFN_MASK; 121 121 } 122 122 123 - /* check whether a pte points to a swap entry */ 124 - static inline int is_swap_pte(pte_t pte) 125 - { 126 - return !pte_none(pte) && !pte_present(pte); 127 - } 128 - 129 123 /* 130 124 * Convert the arch-dependent pte representation of a swp_entry_t into an 131 125 * arch-independent swp_entry_t.
+24 -15
mm/debug_vm_pgtable.c
··· 25 25 #include <linux/random.h> 26 26 #include <linux/spinlock.h> 27 27 #include <linux/swap.h> 28 - #include <linux/swapops.h> 28 + #include <linux/leafops.h> 29 29 #include <linux/start_kernel.h> 30 30 #include <linux/sched/mm.h> 31 31 #include <linux/io.h> ··· 714 714 static void __init pte_swap_soft_dirty_tests(struct pgtable_debug_args *args) 715 715 { 716 716 pte_t pte; 717 + softleaf_t entry; 717 718 718 719 if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY)) 719 720 return; 720 721 721 722 pr_debug("Validating PTE swap soft dirty\n"); 722 723 pte = swp_entry_to_pte(args->swp_entry); 723 - WARN_ON(!is_swap_pte(pte)); 724 + entry = softleaf_from_pte(pte); 724 725 726 + WARN_ON(!softleaf_is_swap(entry)); 725 727 WARN_ON(!pte_swp_soft_dirty(pte_swp_mksoft_dirty(pte))); 726 728 WARN_ON(pte_swp_soft_dirty(pte_swp_clear_soft_dirty(pte))); 727 729 } ··· 770 768 771 769 static void __init pte_swap_exclusive_tests(struct pgtable_debug_args *args) 772 770 { 773 - swp_entry_t entry, entry2; 771 + swp_entry_t entry; 772 + softleaf_t softleaf; 774 773 pte_t pte; 775 774 776 775 pr_debug("Validating PTE swap exclusive\n"); 777 776 entry = args->swp_entry; 778 777 779 778 pte = swp_entry_to_pte(entry); 779 + softleaf = softleaf_from_pte(pte); 780 + 780 781 WARN_ON(pte_swp_exclusive(pte)); 781 - WARN_ON(!is_swap_pte(pte)); 782 - entry2 = pte_to_swp_entry(pte); 783 - WARN_ON(memcmp(&entry, &entry2, sizeof(entry))); 782 + WARN_ON(!softleaf_is_swap(softleaf)); 783 + WARN_ON(memcmp(&entry, &softleaf, sizeof(entry))); 784 784 785 785 pte = pte_swp_mkexclusive(pte); 786 + softleaf = softleaf_from_pte(pte); 787 + 786 788 WARN_ON(!pte_swp_exclusive(pte)); 787 - WARN_ON(!is_swap_pte(pte)); 789 + WARN_ON(!softleaf_is_swap(softleaf)); 788 790 WARN_ON(pte_swp_soft_dirty(pte)); 789 - entry2 = pte_to_swp_entry(pte); 790 - WARN_ON(memcmp(&entry, &entry2, sizeof(entry))); 791 + WARN_ON(memcmp(&entry, &softleaf, sizeof(entry))); 791 792 792 793 pte = pte_swp_clear_exclusive(pte); 794 + softleaf = softleaf_from_pte(pte); 795 + 793 796 WARN_ON(pte_swp_exclusive(pte)); 794 - WARN_ON(!is_swap_pte(pte)); 795 - entry2 = pte_to_swp_entry(pte); 796 - WARN_ON(memcmp(&entry, &entry2, sizeof(entry))); 797 + WARN_ON(!softleaf_is_swap(softleaf)); 798 + WARN_ON(memcmp(&entry, &softleaf, sizeof(entry))); 797 799 } 798 800 799 801 static void __init pte_swap_tests(struct pgtable_debug_args *args) 800 802 { 801 803 swp_entry_t arch_entry; 804 + softleaf_t entry; 802 805 pte_t pte1, pte2; 803 806 804 807 pr_debug("Validating PTE swap\n"); 805 808 pte1 = swp_entry_to_pte(args->swp_entry); 806 - WARN_ON(!is_swap_pte(pte1)); 809 + entry = softleaf_from_pte(pte1); 810 + 811 + WARN_ON(!softleaf_is_swap(entry)); 807 812 808 813 arch_entry = __pte_to_swp_entry(pte1); 809 814 pte2 = __swp_entry_to_pte(arch_entry); ··· 1227 1218 1228 1219 /* See generic_max_swapfile_size(): probe the maximum offset */ 1229 1220 max_swap_offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0, ~0UL)))); 1230 - /* Create a swp entry with all possible bits set */ 1231 - args->swp_entry = swp_entry((1 << MAX_SWAPFILES_SHIFT) - 1, max_swap_offset); 1221 + /* Create a swp entry with all possible bits set while still being swap. */ 1222 + args->swp_entry = swp_entry(MAX_SWAPFILES - 1, max_swap_offset); 1232 1223 1233 1224 /* 1234 1225 * Allocate (huge) pages because some of the tests need to access