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: replace remaining pte_to_swp_entry() with softleaf_from_pte()

There are straggler invocations of pte_to_swp_entry() lying around,
replace all of these with the software leaf entry equivalent -
softleaf_from_pte().

With those removed, eliminate pte_to_swp_entry() altogether.

No functional change intended.

Link: https://lkml.kernel.org/r/d8ee5ccefe4c42d7c4fe1a2e46f285ac40421cd3.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
a3a3e215 93976a20

+42 -32
+6 -1
include/linux/leafops.h
··· 54 54 */ 55 55 static inline softleaf_t softleaf_from_pte(pte_t pte) 56 56 { 57 + softleaf_t arch_entry; 58 + 57 59 if (pte_present(pte) || pte_none(pte)) 58 60 return softleaf_mk_none(); 59 61 62 + pte = pte_swp_clear_flags(pte); 63 + arch_entry = __pte_to_swp_entry(pte); 64 + 60 65 /* Temporary until swp_entry_t eliminated. */ 61 - return pte_to_swp_entry(pte); 66 + return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); 62 67 } 63 68 64 69 /**
-13
include/linux/swapops.h
··· 108 108 } 109 109 110 110 /* 111 - * Convert the arch-dependent pte representation of a swp_entry_t into an 112 - * arch-independent swp_entry_t. 113 - */ 114 - static inline swp_entry_t pte_to_swp_entry(pte_t pte) 115 - { 116 - swp_entry_t arch_entry; 117 - 118 - pte = pte_swp_clear_flags(pte); 119 - arch_entry = __pte_to_swp_entry(pte); 120 - return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); 121 - } 122 - 123 - /* 124 111 * Convert the arch-independent representation of a swp_entry_t into the 125 112 * arch-dependent pte representation. 126 113 */
+1 -1
mm/debug_vm_pgtable.c
··· 1229 1229 init_fixed_pfns(args); 1230 1230 1231 1231 /* See generic_max_swapfile_size(): probe the maximum offset */ 1232 - max_swap_offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0, ~0UL)))); 1232 + max_swap_offset = swp_offset(softleaf_from_pte(softleaf_to_pte(swp_entry(0, ~0UL)))); 1233 1233 /* Create a swp entry with all possible bits set while still being swap. */ 1234 1234 args->swp_entry = swp_entry(MAX_SWAPFILES - 1, max_swap_offset); 1235 1235 /* Create a non-present migration entry. */
+5 -2
mm/internal.h
··· 334 334 */ 335 335 static inline pte_t pte_move_swp_offset(pte_t pte, long delta) 336 336 { 337 - swp_entry_t entry = pte_to_swp_entry(pte); 337 + const softleaf_t entry = softleaf_from_pte(pte); 338 338 pte_t new = __swp_entry_to_pte(__swp_entry(swp_type(entry), 339 339 (swp_offset(entry) + delta))); 340 340 ··· 389 389 390 390 cgroup_id = lookup_swap_cgroup_id(entry); 391 391 while (ptep < end_ptep) { 392 + softleaf_t entry; 393 + 392 394 pte = ptep_get(ptep); 393 395 394 396 if (!pte_same(pte, expected_pte)) 395 397 break; 396 - if (lookup_swap_cgroup_id(pte_to_swp_entry(pte)) != cgroup_id) 398 + entry = softleaf_from_pte(pte); 399 + if (lookup_swap_cgroup_id(entry) != cgroup_id) 397 400 break; 398 401 expected_pte = pte_next_swp_offset(expected_pte); 399 402 ptep++;
+1 -1
mm/memory-failure.c
··· 51 51 #include <linux/backing-dev.h> 52 52 #include <linux/migrate.h> 53 53 #include <linux/slab.h> 54 - #include <linux/swapops.h> 54 + #include <linux/leafops.h> 55 55 #include <linux/hugetlb.h> 56 56 #include <linux/memory_hotplug.h> 57 57 #include <linux/mm_inline.h>
+8 -8
mm/memory.c
··· 1218 1218 spinlock_t *src_ptl, *dst_ptl; 1219 1219 int progress, max_nr, ret = 0; 1220 1220 int rss[NR_MM_COUNTERS]; 1221 - swp_entry_t entry = (swp_entry_t){0}; 1221 + softleaf_t entry = softleaf_mk_none(); 1222 1222 struct folio *prealloc = NULL; 1223 1223 int nr; 1224 1224 ··· 1282 1282 dst_vma, src_vma, 1283 1283 addr, rss); 1284 1284 if (ret == -EIO) { 1285 - entry = pte_to_swp_entry(ptep_get(src_pte)); 1285 + entry = softleaf_from_pte(ptep_get(src_pte)); 1286 1286 break; 1287 1287 } else if (ret == -EBUSY) { 1288 1288 break; ··· 4446 4446 { 4447 4447 struct vm_area_struct *vma = vmf->vma; 4448 4448 struct folio *folio; 4449 - swp_entry_t entry; 4449 + softleaf_t entry; 4450 4450 4451 4451 folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vmf->address); 4452 4452 if (!folio) 4453 4453 return NULL; 4454 4454 4455 - entry = pte_to_swp_entry(vmf->orig_pte); 4455 + entry = softleaf_from_pte(vmf->orig_pte); 4456 4456 if (mem_cgroup_swapin_charge_folio(folio, vma->vm_mm, 4457 4457 GFP_KERNEL, entry)) { 4458 4458 folio_put(folio); ··· 4470 4470 static bool can_swapin_thp(struct vm_fault *vmf, pte_t *ptep, int nr_pages) 4471 4471 { 4472 4472 unsigned long addr; 4473 - swp_entry_t entry; 4473 + softleaf_t entry; 4474 4474 int idx; 4475 4475 pte_t pte; 4476 4476 ··· 4480 4480 4481 4481 if (!pte_same(pte, pte_move_swp_offset(vmf->orig_pte, -idx))) 4482 4482 return false; 4483 - entry = pte_to_swp_entry(pte); 4483 + entry = softleaf_from_pte(pte); 4484 4484 if (swap_pte_batch(ptep, nr_pages, pte) != nr_pages) 4485 4485 return false; 4486 4486 ··· 4526 4526 unsigned long orders; 4527 4527 struct folio *folio; 4528 4528 unsigned long addr; 4529 - swp_entry_t entry; 4529 + softleaf_t entry; 4530 4530 spinlock_t *ptl; 4531 4531 pte_t *pte; 4532 4532 gfp_t gfp; ··· 4547 4547 if (!zswap_never_enabled()) 4548 4548 goto fallback; 4549 4549 4550 - entry = pte_to_swp_entry(vmf->orig_pte); 4550 + entry = softleaf_from_pte(vmf->orig_pte); 4551 4551 /* 4552 4552 * Get a list of all the (large) orders below PMD_ORDER that are enabled 4553 4553 * and suitable for swapping THP.
+1 -1
mm/migrate.c
··· 534 534 * lock release in migration_entry_wait_on_locked(). 535 535 */ 536 536 hugetlb_vma_unlock_read(vma); 537 - migration_entry_wait_on_locked(pte_to_swp_entry(pte), ptl); 537 + migration_entry_wait_on_locked(entry, ptl); 538 538 return; 539 539 } 540 540
+3 -1
mm/mincore.c
··· 202 202 for (i = 0; i < step; i++) 203 203 vec[i] = 1; 204 204 } else { /* pte is a swap entry */ 205 - *vec = mincore_swap(pte_to_swp_entry(pte), false); 205 + const softleaf_t entry = softleaf_from_pte(pte); 206 + 207 + *vec = mincore_swap(entry, false); 206 208 } 207 209 vec += step; 208 210 }
+6 -2
mm/rmap.c
··· 1969 1969 if (likely(pte_present(pteval))) { 1970 1970 pfn = pte_pfn(pteval); 1971 1971 } else { 1972 - pfn = softleaf_to_pfn(pte_to_swp_entry(pteval)); 1972 + const softleaf_t entry = softleaf_from_pte(pteval); 1973 + 1974 + pfn = softleaf_to_pfn(entry); 1973 1975 VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); 1974 1976 } 1975 1977 ··· 2370 2368 if (likely(pte_present(pteval))) { 2371 2369 pfn = pte_pfn(pteval); 2372 2370 } else { 2373 - pfn = softleaf_to_pfn(pte_to_swp_entry(pteval)); 2371 + const softleaf_t entry = softleaf_from_pte(pteval); 2372 + 2373 + pfn = softleaf_to_pfn(entry); 2374 2374 VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); 2375 2375 } 2376 2376
+11 -2
mm/swapfile.c
··· 3202 3202 */ 3203 3203 unsigned long generic_max_swapfile_size(void) 3204 3204 { 3205 - return swp_offset(pte_to_swp_entry( 3206 - swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1; 3205 + swp_entry_t entry = swp_entry(0, ~0UL); 3206 + const pte_t pte = softleaf_to_pte(entry); 3207 + 3208 + /* 3209 + * Since the PTE can be an invalid softleaf entry (e.g. the none PTE), 3210 + * we need to do this manually. 3211 + */ 3212 + entry = __pte_to_swp_entry(pte); 3213 + entry = swp_entry(__swp_type(entry), __swp_offset(entry)); 3214 + 3215 + return swp_offset(entry) + 1; 3207 3216 } 3208 3217 3209 3218 /* Can be overridden by an architecture for additional checks. */