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 redundant pXd_devmap calls

DAX was the only thing that created pmd_devmap and pud_devmap entries
however it no longer does as DAX pages are now refcounted normally and
pXd_trans_huge() returns true for those. Therefore checking both
pXd_devmap and pXd_trans_huge() is redundant and the former can be removed
without changing behaviour as it will always be false.

Link: https://lkml.kernel.org/r/d58f089dc16b7feb7c6728164f37dea65d64a0d3.1750323463.git-series.apopple@nvidia.com
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Cc: Balbir Singh <balbirs@nvidia.com>
Cc: Björn Töpel <bjorn@kernel.org>
Cc: Björn Töpel <bjorn@rivosinc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Deepak Gupta <debug@rivosinc.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Inki Dae <m.szyprowski@samsung.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Groves <john@groves.net>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Alistair Popple and committed by
Andrew Morton
8a6a984c 7b2ae3c4

+40 -59
+2 -3
fs/dax.c
··· 1937 1937 * the PTE we need to set up. If so just return and the fault will be 1938 1938 * retried. 1939 1939 */ 1940 - if (pmd_trans_huge(*vmf->pmd) || pmd_devmap(*vmf->pmd)) { 1940 + if (pmd_trans_huge(*vmf->pmd)) { 1941 1941 ret = VM_FAULT_NOPAGE; 1942 1942 goto unlock_entry; 1943 1943 } ··· 2060 2060 * the PMD we need to set up. If so just return and the fault will be 2061 2061 * retried. 2062 2062 */ 2063 - if (!pmd_none(*vmf->pmd) && !pmd_trans_huge(*vmf->pmd) && 2064 - !pmd_devmap(*vmf->pmd)) { 2063 + if (!pmd_none(*vmf->pmd) && !pmd_trans_huge(*vmf->pmd)) { 2065 2064 ret = 0; 2066 2065 goto unlock_entry; 2067 2066 }
+4 -6
include/linux/huge_mm.h
··· 400 400 #define split_huge_pmd(__vma, __pmd, __address) \ 401 401 do { \ 402 402 pmd_t *____pmd = (__pmd); \ 403 - if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd) \ 404 - || pmd_devmap(*____pmd)) \ 403 + if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd)) \ 405 404 __split_huge_pmd(__vma, __pmd, __address, \ 406 405 false); \ 407 406 } while (0) ··· 425 426 #define split_huge_pud(__vma, __pud, __address) \ 426 427 do { \ 427 428 pud_t *____pud = (__pud); \ 428 - if (pud_trans_huge(*____pud) \ 429 - || pud_devmap(*____pud)) \ 429 + if (pud_trans_huge(*____pud)) \ 430 430 __split_huge_pud(__vma, __pud, __address); \ 431 431 } while (0) 432 432 ··· 448 450 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, 449 451 struct vm_area_struct *vma) 450 452 { 451 - if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) 453 + if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd)) 452 454 return __pmd_trans_huge_lock(pmd, vma); 453 455 else 454 456 return NULL; ··· 456 458 static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, 457 459 struct vm_area_struct *vma) 458 460 { 459 - if (pud_trans_huge(*pud) || pud_devmap(*pud)) 461 + if (pud_trans_huge(*pud)) 460 462 return __pud_trans_huge_lock(pud, vma); 461 463 else 462 464 return NULL;
+1 -1
include/linux/pgtable.h
··· 1672 1672 defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) 1673 1673 pud_t pudval = READ_ONCE(*pud); 1674 1674 1675 - if (pud_none(pudval) || pud_trans_huge(pudval) || pud_devmap(pudval)) 1675 + if (pud_none(pudval) || pud_trans_huge(pudval)) 1676 1676 return 1; 1677 1677 if (unlikely(pud_bad(pudval))) { 1678 1678 pud_clear_bad(pud);
+2 -2
mm/hmm.c
··· 360 360 return hmm_pfns_fill(start, end, range, HMM_PFN_ERROR); 361 361 } 362 362 363 - if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) { 363 + if (pmd_trans_huge(pmd)) { 364 364 /* 365 365 * No need to take pmd_lock here, even if some other thread 366 366 * is splitting the huge pmd we will get that event through ··· 371 371 * values. 372 372 */ 373 373 pmd = pmdp_get_lockless(pmdp); 374 - if (!pmd_devmap(pmd) && !pmd_trans_huge(pmd)) 374 + if (!pmd_trans_huge(pmd)) 375 375 goto again; 376 376 377 377 return hmm_vma_handle_pmd(walk, addr, end, hmm_pfns, pmd);
+9 -14
mm/huge_memory.c
··· 1459 1459 * but we need to be consistent with PTEs and architectures that 1460 1460 * can't support a 'special' bit. 1461 1461 */ 1462 - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && 1463 - !pfn_t_devmap(pfn)); 1462 + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); 1464 1463 BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == 1465 1464 (VM_PFNMAP|VM_MIXEDMAP)); 1466 1465 BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); ··· 1595 1596 * but we need to be consistent with PTEs and architectures that 1596 1597 * can't support a 'special' bit. 1597 1598 */ 1598 - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && 1599 - !pfn_t_devmap(pfn)); 1599 + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); 1600 1600 BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == 1601 1601 (VM_PFNMAP|VM_MIXEDMAP)); 1602 1602 BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); ··· 1813 1815 1814 1816 ret = -EAGAIN; 1815 1817 pud = *src_pud; 1816 - if (unlikely(!pud_trans_huge(pud) && !pud_devmap(pud))) 1818 + if (unlikely(!pud_trans_huge(pud))) 1817 1819 goto out_unlock; 1818 1820 1819 1821 /* ··· 2675 2677 { 2676 2678 spinlock_t *ptl; 2677 2679 ptl = pmd_lock(vma->vm_mm, pmd); 2678 - if (likely(is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || 2679 - pmd_devmap(*pmd))) 2680 + if (likely(is_swap_pmd(*pmd) || pmd_trans_huge(*pmd))) 2680 2681 return ptl; 2681 2682 spin_unlock(ptl); 2682 2683 return NULL; ··· 2692 2695 spinlock_t *ptl; 2693 2696 2694 2697 ptl = pud_lock(vma->vm_mm, pud); 2695 - if (likely(pud_trans_huge(*pud) || pud_devmap(*pud))) 2698 + if (likely(pud_trans_huge(*pud))) 2696 2699 return ptl; 2697 2700 spin_unlock(ptl); 2698 2701 return NULL; ··· 2744 2747 VM_BUG_ON(haddr & ~HPAGE_PUD_MASK); 2745 2748 VM_BUG_ON_VMA(vma->vm_start > haddr, vma); 2746 2749 VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PUD_SIZE, vma); 2747 - VM_BUG_ON(!pud_trans_huge(*pud) && !pud_devmap(*pud)); 2750 + VM_BUG_ON(!pud_trans_huge(*pud)); 2748 2751 2749 2752 count_vm_event(THP_SPLIT_PUD); 2750 2753 ··· 2777 2780 (address & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE); 2778 2781 mmu_notifier_invalidate_range_start(&range); 2779 2782 ptl = pud_lock(vma->vm_mm, pud); 2780 - if (unlikely(!pud_trans_huge(*pud) && !pud_devmap(*pud))) 2783 + if (unlikely(!pud_trans_huge(*pud))) 2781 2784 goto out; 2782 2785 __split_huge_pud_locked(vma, pud, range.start); 2783 2786 ··· 2850 2853 VM_BUG_ON(haddr & ~HPAGE_PMD_MASK); 2851 2854 VM_BUG_ON_VMA(vma->vm_start > haddr, vma); 2852 2855 VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PMD_SIZE, vma); 2853 - VM_BUG_ON(!is_pmd_migration_entry(*pmd) && !pmd_trans_huge(*pmd) 2854 - && !pmd_devmap(*pmd)); 2856 + VM_BUG_ON(!is_pmd_migration_entry(*pmd) && !pmd_trans_huge(*pmd)); 2855 2857 2856 2858 count_vm_event(THP_SPLIT_PMD); 2857 2859 ··· 3058 3062 pmd_t *pmd, bool freeze) 3059 3063 { 3060 3064 VM_WARN_ON_ONCE(!IS_ALIGNED(address, HPAGE_PMD_SIZE)); 3061 - if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) || 3062 - is_pmd_migration_entry(*pmd)) 3065 + if (pmd_trans_huge(*pmd) || is_pmd_migration_entry(*pmd)) 3063 3066 __split_huge_pmd_locked(vma, pmd, address, freeze); 3064 3067 } 3065 3068
+2 -2
mm/mapping_dirty_helpers.c
··· 129 129 pmd_t pmdval = pmdp_get_lockless(pmd); 130 130 131 131 /* Do not split a huge pmd, present or migrated */ 132 - if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) { 132 + if (pmd_trans_huge(pmdval)) { 133 133 WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval)); 134 134 walk->action = ACTION_CONTINUE; 135 135 } ··· 152 152 pud_t pudval = READ_ONCE(*pud); 153 153 154 154 /* Do not split a huge pud */ 155 - if (pud_trans_huge(pudval) || pud_devmap(pudval)) { 155 + if (pud_trans_huge(pudval)) { 156 156 WARN_ON(pud_write(pudval) || pud_dirty(pudval)); 157 157 walk->action = ACTION_CONTINUE; 158 158 }
+6 -9
mm/memory.c
··· 675 675 } 676 676 } 677 677 678 - if (pmd_devmap(pmd)) 679 - return NULL; 680 678 if (is_huge_zero_pmd(pmd)) 681 679 return NULL; 682 680 if (unlikely(pfn > highest_memmap_pfn)) ··· 1238 1240 src_pmd = pmd_offset(src_pud, addr); 1239 1241 do { 1240 1242 next = pmd_addr_end(addr, end); 1241 - if (is_swap_pmd(*src_pmd) || pmd_trans_huge(*src_pmd) 1242 - || pmd_devmap(*src_pmd)) { 1243 + if (is_swap_pmd(*src_pmd) || pmd_trans_huge(*src_pmd)) { 1243 1244 int err; 1244 1245 VM_BUG_ON_VMA(next-addr != HPAGE_PMD_SIZE, src_vma); 1245 1246 err = copy_huge_pmd(dst_mm, src_mm, dst_pmd, src_pmd, ··· 1274 1277 src_pud = pud_offset(src_p4d, addr); 1275 1278 do { 1276 1279 next = pud_addr_end(addr, end); 1277 - if (pud_trans_huge(*src_pud) || pud_devmap(*src_pud)) { 1280 + if (pud_trans_huge(*src_pud)) { 1278 1281 int err; 1279 1282 1280 1283 VM_BUG_ON_VMA(next-addr != HPAGE_PUD_SIZE, src_vma); ··· 1788 1791 pmd = pmd_offset(pud, addr); 1789 1792 do { 1790 1793 next = pmd_addr_end(addr, end); 1791 - if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { 1794 + if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd)) { 1792 1795 if (next - addr != HPAGE_PMD_SIZE) 1793 1796 __split_huge_pmd(vma, pmd, addr, false); 1794 1797 else if (zap_huge_pmd(tlb, vma, pmd, addr)) { ··· 1830 1833 pud = pud_offset(p4d, addr); 1831 1834 do { 1832 1835 next = pud_addr_end(addr, end); 1833 - if (pud_trans_huge(*pud) || pud_devmap(*pud)) { 1836 + if (pud_trans_huge(*pud)) { 1834 1837 if (next - addr != HPAGE_PUD_SIZE) { 1835 1838 mmap_assert_locked(tlb->mm); 1836 1839 split_huge_pud(vma, pud, addr); ··· 6133 6136 pud_t orig_pud = *vmf.pud; 6134 6137 6135 6138 barrier(); 6136 - if (pud_trans_huge(orig_pud) || pud_devmap(orig_pud)) { 6139 + if (pud_trans_huge(orig_pud)) { 6137 6140 6138 6141 /* 6139 6142 * TODO once we support anonymous PUDs: NUMA case and ··· 6174 6177 pmd_migration_entry_wait(mm, vmf.pmd); 6175 6178 return 0; 6176 6179 } 6177 - if (pmd_trans_huge(vmf.orig_pmd) || pmd_devmap(vmf.orig_pmd)) { 6180 + if (pmd_trans_huge(vmf.orig_pmd)) { 6178 6181 if (pmd_protnone(vmf.orig_pmd) && vma_is_accessible(vma)) 6179 6182 return do_huge_pmd_numa_page(&vmf); 6180 6183
+1 -1
mm/migrate_device.c
··· 615 615 pmdp = pmd_alloc(mm, pudp, addr); 616 616 if (!pmdp) 617 617 goto abort; 618 - if (pmd_trans_huge(*pmdp) || pmd_devmap(*pmdp)) 618 + if (pmd_trans_huge(*pmdp)) 619 619 goto abort; 620 620 if (pte_alloc(mm, pmdp)) 621 621 goto abort;
+1 -1
mm/mprotect.c
··· 376 376 goto next; 377 377 378 378 _pmd = pmdp_get_lockless(pmd); 379 - if (is_swap_pmd(_pmd) || pmd_trans_huge(_pmd) || pmd_devmap(_pmd)) { 379 + if (is_swap_pmd(_pmd) || pmd_trans_huge(_pmd)) { 380 380 if ((next - addr != HPAGE_PMD_SIZE) || 381 381 pgtable_split_needed(vma, cp_flags)) { 382 382 __split_huge_pmd(vma, pmd, addr, false);
+2 -3
mm/mremap.c
··· 820 820 new_pud = alloc_new_pud(mm, pmc->new_addr); 821 821 if (!new_pud) 822 822 break; 823 - if (pud_trans_huge(*old_pud) || pud_devmap(*old_pud)) { 823 + if (pud_trans_huge(*old_pud)) { 824 824 if (extent == HPAGE_PUD_SIZE) { 825 825 move_pgt_entry(pmc, HPAGE_PUD, old_pud, new_pud); 826 826 /* We ignore and continue on error? */ ··· 839 839 if (!new_pmd) 840 840 break; 841 841 again: 842 - if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd) || 843 - pmd_devmap(*old_pmd)) { 842 + if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) { 844 843 if (extent == HPAGE_PMD_SIZE && 845 844 move_pgt_entry(pmc, HPAGE_PMD, old_pmd, new_pmd)) 846 845 continue;
+2 -3
mm/page_vma_mapped.c
··· 246 246 */ 247 247 pmde = pmdp_get_lockless(pvmw->pmd); 248 248 249 - if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde) || 250 - (pmd_present(pmde) && pmd_devmap(pmde))) { 249 + if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) { 251 250 pvmw->ptl = pmd_lock(mm, pvmw->pmd); 252 251 pmde = *pvmw->pmd; 253 252 if (!pmd_present(pmde)) { ··· 261 262 return not_found(pvmw); 262 263 return true; 263 264 } 264 - if (likely(pmd_trans_huge(pmde) || pmd_devmap(pmde))) { 265 + if (likely(pmd_trans_huge(pmde))) { 265 266 if (pvmw->flags & PVMW_MIGRATION) 266 267 return not_found(pvmw); 267 268 if (!check_pmd(pmd_pfn(pmde), pvmw))
+3 -5
mm/pagewalk.c
··· 143 143 * We are ONLY installing, so avoid unnecessarily 144 144 * splitting a present huge page. 145 145 */ 146 - if (pmd_present(*pmd) && 147 - (pmd_trans_huge(*pmd) || pmd_devmap(*pmd))) 146 + if (pmd_present(*pmd) && pmd_trans_huge(*pmd)) 148 147 continue; 149 148 } 150 149 ··· 209 210 * We are ONLY installing, so avoid unnecessarily 210 211 * splitting a present huge page. 211 212 */ 212 - if (pud_present(*pud) && 213 - (pud_trans_huge(*pud) || pud_devmap(*pud))) 213 + if (pud_present(*pud) && pud_trans_huge(*pud)) 214 214 continue; 215 215 } 216 216 ··· 906 908 * TODO: FW_MIGRATION support for PUD migration entries 907 909 * once there are relevant users. 908 910 */ 909 - if (!pud_present(pud) || pud_devmap(pud) || pud_special(pud)) { 911 + if (!pud_present(pud) || pud_special(pud)) { 910 912 spin_unlock(ptl); 911 913 goto not_found; 912 914 } else if (!pud_leaf(pud)) {
+3 -4
mm/pgtable-generic.c
··· 139 139 { 140 140 pmd_t pmd; 141 141 VM_BUG_ON(address & ~HPAGE_PMD_MASK); 142 - VM_BUG_ON(pmd_present(*pmdp) && !pmd_trans_huge(*pmdp) && 143 - !pmd_devmap(*pmdp)); 142 + VM_BUG_ON(pmd_present(*pmdp) && !pmd_trans_huge(*pmdp)); 144 143 pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp); 145 144 flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); 146 145 return pmd; ··· 152 153 pud_t pud; 153 154 154 155 VM_BUG_ON(address & ~HPAGE_PUD_MASK); 155 - VM_BUG_ON(!pud_trans_huge(*pudp) && !pud_devmap(*pudp)); 156 + VM_BUG_ON(!pud_trans_huge(*pudp)); 156 157 pud = pudp_huge_get_and_clear(vma->vm_mm, address, pudp); 157 158 flush_pud_tlb_range(vma, address, address + HPAGE_PUD_SIZE); 158 159 return pud; ··· 292 293 *pmdvalp = pmdval; 293 294 if (unlikely(pmd_none(pmdval) || is_pmd_migration_entry(pmdval))) 294 295 goto nomap; 295 - if (unlikely(pmd_trans_huge(pmdval) || pmd_devmap(pmdval))) 296 + if (unlikely(pmd_trans_huge(pmdval))) 296 297 goto nomap; 297 298 if (unlikely(pmd_bad(pmdval))) { 298 299 pmd_clear_bad(pmd);
+2 -2
mm/userfaultfd.c
··· 795 795 * (This includes the case where the PMD used to be THP and 796 796 * changed back to none after __pte_alloc().) 797 797 */ 798 - if (unlikely(!pmd_present(dst_pmdval) || pmd_trans_huge(dst_pmdval) || 799 - pmd_devmap(dst_pmdval))) { 798 + if (unlikely(!pmd_present(dst_pmdval) || 799 + pmd_trans_huge(dst_pmdval))) { 800 800 err = -EEXIST; 801 801 break; 802 802 }
-3
mm/vmscan.c
··· 3450 3450 if (!pmd_present(pmd) || is_huge_zero_pmd(pmd)) 3451 3451 return -1; 3452 3452 3453 - if (WARN_ON_ONCE(pmd_devmap(pmd))) 3454 - return -1; 3455 - 3456 3453 if (!pmd_young(pmd) && !mm_has_notifiers(vma->vm_mm)) 3457 3454 return -1; 3458 3455