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: convert vmf_insert_mixed() from using pte_devmap to pte_special

DAX no longer requires device PTEs as it always has a ZONE_DEVICE page
associated with the PTE that can be reference counted normally. Other
users of pte_devmap are drivers that set PFN_DEV when calling
vmf_insert_mixed() which ensures vm_normal_page() returns NULL for these
entries.

There is no reason to distinguish these pte_devmap users so in order to
free up a PTE bit use pte_special instead for entries created with
vmf_insert_mixed(). This will ensure vm_normal_page() will continue to
return NULL for these pages.

Architectures that don't support pte_special also don't support pte_devmap
so those will continue to rely on pfn_valid() to determine if the page can
be mapped.

Link: https://lkml.kernel.org/r/93086bd446e7bf8e4c85345613ac18f706b01f60.1750323463.git-series.apopple@nvidia.com
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.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: 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: 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
4b1d3145 79065255

+3 -22
-3
mm/hmm.c
··· 302 302 goto fault; 303 303 304 304 /* 305 - * Bypass devmap pte such as DAX page when all pfn requested 306 - * flags(pfn_req_flags) are fulfilled. 307 305 * Since each architecture defines a struct page for the zero page, just 308 306 * fall through and treat it like a normal page. 309 307 */ 310 308 if (!vm_normal_page(walk->vma, addr, pte) && 311 - !pte_devmap(pte) && 312 309 !is_zero_pfn(pte_pfn(pte))) { 313 310 if (hmm_pte_need_fault(hmm_vma_walk, pfn_req_flags, 0)) { 314 311 pte_unmap(ptep);
+2 -18
mm/memory.c
··· 598 598 return NULL; 599 599 if (is_zero_pfn(pfn)) 600 600 return NULL; 601 - if (pte_devmap(pte)) 602 - /* 603 - * NOTE: New users of ZONE_DEVICE will not set pte_devmap() 604 - * and will have refcounts incremented on their struct pages 605 - * when they are inserted into PTEs, thus they are safe to 606 - * return here. Legacy ZONE_DEVICE pages that set pte_devmap() 607 - * do not have refcounts. Example of legacy ZONE_DEVICE is 608 - * MEMORY_DEVICE_FS_DAX type in pmem or virtio_fs drivers. 609 - */ 610 - return NULL; 611 601 612 602 print_bad_pte(vma, addr, pte, NULL); 613 603 return NULL; ··· 2473 2483 } 2474 2484 2475 2485 /* Ok, finally just insert the thing.. */ 2476 - if (pfn_t_devmap(pfn)) 2477 - entry = pte_mkdevmap(pfn_t_pte(pfn, prot)); 2478 - else 2479 - entry = pte_mkspecial(pfn_t_pte(pfn, prot)); 2486 + entry = pte_mkspecial(pfn_t_pte(pfn, prot)); 2480 2487 2481 2488 if (mkwrite) { 2482 2489 entry = pte_mkyoung(entry); ··· 2584 2597 /* these checks mirror the abort conditions in vm_normal_page */ 2585 2598 if (vma->vm_flags & VM_MIXEDMAP) 2586 2599 return true; 2587 - if (pfn_t_devmap(pfn)) 2588 - return true; 2589 2600 if (pfn_t_special(pfn)) 2590 2601 return true; 2591 2602 if (is_zero_pfn(pfn_t_to_pfn(pfn))) ··· 2615 2630 * than insert_pfn). If a zero_pfn were inserted into a VM_MIXEDMAP 2616 2631 * without pte special, it would there be refcounted as a normal page. 2617 2632 */ 2618 - if (!IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && 2619 - !pfn_t_devmap(pfn) && pfn_t_valid(pfn)) { 2633 + if (!IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && pfn_t_valid(pfn)) { 2620 2634 struct page *page; 2621 2635 2622 2636 /*
+1 -1
mm/vmscan.c
··· 3425 3425 if (!pte_present(pte) || is_zero_pfn(pfn)) 3426 3426 return -1; 3427 3427 3428 - if (WARN_ON_ONCE(pte_devmap(pte) || pte_special(pte))) 3428 + if (WARN_ON_ONCE(pte_special(pte))) 3429 3429 return -1; 3430 3430 3431 3431 if (!pte_young(pte) && !mm_has_notifiers(vma->vm_mm))