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: eliminate is_swap_pte() when softleaf_from_pte() suffices

In cases where we can simply utilise the fact that softleaf_from_pte()
treats present entries as if they were none entries and thus eliminate
spurious uses of is_swap_pte(), do so.

No functional change intended.

Link: https://lkml.kernel.org/r/92ebab9567978155116804c67babc3c64636c403.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
06fb6146 fb888710

+15 -20
+3 -4
mm/internal.h
··· 15 15 #include <linux/pagewalk.h> 16 16 #include <linux/rmap.h> 17 17 #include <linux/swap.h> 18 - #include <linux/swapops.h> 18 + #include <linux/leafops.h> 19 19 #include <linux/swap_cgroup.h> 20 20 #include <linux/tracepoint-defs.h> 21 21 ··· 380 380 { 381 381 pte_t expected_pte = pte_next_swp_offset(pte); 382 382 const pte_t *end_ptep = start_ptep + max_nr; 383 - swp_entry_t entry = pte_to_swp_entry(pte); 383 + const softleaf_t entry = softleaf_from_pte(pte); 384 384 pte_t *ptep = start_ptep + 1; 385 385 unsigned short cgroup_id; 386 386 387 387 VM_WARN_ON(max_nr < 1); 388 - VM_WARN_ON(!is_swap_pte(pte)); 389 - VM_WARN_ON(non_swap_entry(entry)); 388 + VM_WARN_ON(!softleaf_is_swap(entry)); 390 389 391 390 cgroup_id = lookup_swap_cgroup_id(entry); 392 391 while (ptep < end_ptep) {
+3 -5
mm/madvise.c
··· 195 195 196 196 for (addr = start; addr < end; addr += PAGE_SIZE) { 197 197 pte_t pte; 198 - swp_entry_t entry; 198 + softleaf_t entry; 199 199 struct folio *folio; 200 200 201 201 if (!ptep++) { ··· 205 205 } 206 206 207 207 pte = ptep_get(ptep); 208 - if (!is_swap_pte(pte)) 209 - continue; 210 - entry = pte_to_swp_entry(pte); 211 - if (unlikely(non_swap_entry(entry))) 208 + entry = softleaf_from_pte(pte); 209 + if (unlikely(!softleaf_is_swap(entry))) 212 210 continue; 213 211 214 212 pte_unmap_unlock(ptep, ptl);
+5 -6
mm/swap_state.c
··· 12 12 #include <linux/kernel_stat.h> 13 13 #include <linux/mempolicy.h> 14 14 #include <linux/swap.h> 15 - #include <linux/swapops.h> 15 + #include <linux/leafops.h> 16 16 #include <linux/init.h> 17 17 #include <linux/pagemap.h> 18 18 #include <linux/pagevec.h> ··· 736 736 pte_t *pte = NULL, pentry; 737 737 int win; 738 738 unsigned long start, end, addr; 739 - swp_entry_t entry; 740 739 pgoff_t ilx; 741 740 bool page_allocated; 742 741 ··· 748 749 blk_start_plug(&plug); 749 750 for (addr = start; addr < end; ilx++, addr += PAGE_SIZE) { 750 751 struct swap_info_struct *si = NULL; 752 + softleaf_t entry; 751 753 752 754 if (!pte++) { 753 755 pte = pte_offset_map(vmf->pmd, addr); ··· 756 756 break; 757 757 } 758 758 pentry = ptep_get_lockless(pte); 759 - if (!is_swap_pte(pentry)) 760 - continue; 761 - entry = pte_to_swp_entry(pentry); 762 - if (unlikely(non_swap_entry(entry))) 759 + entry = softleaf_from_pte(pentry); 760 + 761 + if (!softleaf_is_swap(entry)) 763 762 continue; 764 763 pte_unmap(pte); 765 764 pte = NULL;
+4 -5
mm/swapfile.c
··· 44 44 #include <linux/plist.h> 45 45 46 46 #include <asm/tlbflush.h> 47 - #include <linux/swapops.h> 47 + #include <linux/leafops.h> 48 48 #include <linux/swap_cgroup.h> 49 49 #include "swap_table.h" 50 50 #include "internal.h" ··· 2257 2257 struct folio *folio; 2258 2258 unsigned long offset; 2259 2259 unsigned char swp_count; 2260 - swp_entry_t entry; 2260 + softleaf_t entry; 2261 2261 int ret; 2262 2262 pte_t ptent; 2263 2263 ··· 2268 2268 } 2269 2269 2270 2270 ptent = ptep_get_lockless(pte); 2271 + entry = softleaf_from_pte(ptent); 2271 2272 2272 - if (!is_swap_pte(ptent)) 2273 + if (!softleaf_is_swap(entry)) 2273 2274 continue; 2274 - 2275 - entry = pte_to_swp_entry(ptent); 2276 2275 if (swp_type(entry) != type) 2277 2276 continue; 2278 2277