Re: [RFC 10/10] mm: Remove pXX_devmap

Jason Gunthorpe
2024-04-11T12:57:30Z

On Thu, Apr 11, 2024 at 10:57:31AM +1000, Alistair Popple wrote:
> The devmap PTE special bit was used to detect mappings of FS DAX
> pages. This tracking was required to ensure the generic mm did not
> manipulate the page reference counts as FS DAX implemented it's own
> reference counting scheme.
>
> Now that FS DAX pages have their references counted the same way as
> normal pages this tracking is no longer needed and can be
> removed.
>
> Almost all existing uses of pmd_devmap() are paired with a check of
> pmd_trans_huge(). As pmd_trans_huge() now returns true for FS DAX pages
> dropping the check in these cases doesn't change anything.
>
> However care needs to be taken because pmd_trans_huge() also checks that
> a page is not an FS DAX page. This is dealt with either by checking
> !vma_is_dax() or relying on the fact that the page pointer was obtained
> from a page list. This is possible because zone device pages cannot
> appear in any page list due to sharing page->lru with page->pgmap.
>
> Signed-off-by: Alistair Popple <apopple@nvidia.com>
> ---
> Documentation/mm/arch_pgtable_helpers.rst | 6 +-
> arch/arm64/include/asm/pgtable.h | 24 +---
> arch/powerpc/include/asm/book3s/64/pgtable.h | 42 +------
> arch/powerpc/mm/book3s64/hash_pgtable.c | 3 +-
> arch/powerpc/mm/book3s64/pgtable.c | 8 +-
> arch/powerpc/mm/book3s64/radix_pgtable.c | 5 +-
> arch/powerpc/mm/pgtable.c | 2 +-
> arch/x86/include/asm/pgtable.h | 31 +----
> fs/dax.c | 5 +-
> fs/userfaultfd.c | 2 +-
> include/linux/huge_mm.h | 10 +-
> include/linux/mm.h | 7 +-
> include/linux/pgtable.h | 17 +--
> mm/debug_vm_pgtable.c | 51 +-------
> mm/gup.c | 151 +--------------------
> mm/hmm.c | 5 +-
> mm/huge_memory.c | 100 +-------------
> mm/khugepaged.c | 2 +-
> mm/mapping_dirty_helpers.c | 4 +-
> mm/memory.c | 25 +---
> mm/migrate_device.c | 2 +-
> mm/mprotect.c | 2 +-
> mm/mremap.c | 5 +-
> mm/page_vma_mapped.c | 5 +-
> mm/pgtable-generic.c | 7 +-
> mm/vmscan.c | 5 +-
> 26 files changed, 48 insertions(+), 478 deletions(-)

This is great

I suggest splitting it up into two parts, remove the functional code
in the core mm calling these functions testing and setting pXX_devmap
(and maybe this needs several patches for clarity) and then remove all
the remaining dead code once all the callers are gone.

Jason