We also add success and error hooks for post-action processing for e.g. output debug log on success and filtering error codes. v2: * Propagated tags, thanks everyone! :) * Refactored resctl patch to avoid assigned-but-not-used variable. * Updated resctl change to not use .mmap_abort as discussed with Jason. * Removed .mmap_abort as discussed with Jason. * Removed references to .mmap_abort from documentation. * Fixed silly VM_WARN_ON_ONCE() mistake (asserting opposite of what we mean to) as per report from Alexander. * Fixed relay kerneldoc error. * Renamed __mmap_prelude to __mmap_setup, keep __mmap_complete the same as per David. * Fixed docs typo in mmap_complete description + formatted bold rather than capitalised as per Randy. * Eliminated mmap_complete and rework into actions specified in mmap_prepare (via vm_area_desc) which therefore eliminates the driver's ability to do anything crazy and allows us to control generic logic. * Added helper functions for these - vma_desc_set_remap(), vma_desc_set_mixedmap(). * However unfortunately had to add post action hooks to vm_area_desc, as already hugetlbfs for instance needs to access the VMA to function correctly. It is at least the smallest possible means of doing this. * Updated VMA test logic, the stacked filesystem compatibility layer and documentation to reflect this. * Updated hugetlbfs implementation to use new approach, and refactored to accept desc where at all possible and to do as much as possible in .mmap_prepare, and the minimum required in the new post_hook callback. * Updated /dev/mem and /dev/zero mmap logic to use the new mechanism. * Updated cramfs, resctl to use the new mechanism. * Updated proc_mmap hooks to only have proc_mmap_prepare. * Updated the vmcore implementation to use the new hooks. * Updated kcov to use the new hooks. * Added hooks for success/failure for post-action handling. * Added custom action hook for truly custom cases. * Abstracted actions to separate type so we can use generic custom actions in custom handlers when necessary. * Added callout re: lock issue raised in https://lore.kernel.org/linux-mm/20250801162930.GB184255@xxxxxxxxxx/ as per discussion with Jason. v1: https://lore.kernel.org/all/cover.1757329751.git.lorenzo.stoakes@xxxxxxxxxx/ Lorenzo Stoakes (16): mm/shmem: update shmem to use mmap_prepare device/dax: update devdax to use mmap_prepare mm: add vma_desc_size(), vma_desc_pages() helpers relay: update relay to use mmap_prepare mm/vma: rename __mmap_prepare() function to avoid confusion mm: add remap_pfn_range_prepare(), remap_pfn_range_complete() mm: introduce io_remap_pfn_range_[prepare, complete]() mm: add ability to take further action in vm_area_desc doc: update porting, vfs documentation for mmap_prepare actions mm/hugetlbfs: update hugetlbfs to use mmap_prepare mm: update mem char driver to use mmap_prepare mm: update resctl to use mmap_prepare mm: update cramfs to use mmap_prepare fs/proc: add the proc_mmap_prepare hook for procfs fs/proc: update vmcore to use .proc_mmap_prepare kcov: update kcov to use mmap_prepare Documentation/filesystems/porting.rst | 5 + Documentation/filesystems/vfs.rst | 4 + arch/csky/include/asm/pgtable.h | 5 + arch/mips/alchemy/common/setup.c | 28 ++++- arch/mips/include/asm/pgtable.h | 10 ++ arch/s390/kernel/crash_dump.c | 6 +- arch/sparc/include/asm/pgtable_32.h | 29 ++++- arch/sparc/include/asm/pgtable_64.h | 29 ++++- drivers/char/mem.c | 75 ++++++------ drivers/dax/device.c | 32 +++-- fs/cramfs/inode.c | 46 ++++---- fs/hugetlbfs/inode.c | 30 +++-- fs/ntfs3/file.c | 2 +- fs/proc/inode.c | 12 +- fs/proc/vmcore.c | 54 ++++++--- fs/resctrl/pseudo_lock.c | 22 ++-- include/linux/hugetlb.h | 9 +- include/linux/hugetlb_inline.h | 15 ++- include/linux/mm.h | 83 ++++++++++++- include/linux/mm_types.h | 61 ++++++++++ include/linux/proc_fs.h | 1 + include/linux/shmem_fs.h | 3 +- include/linux/vmalloc.h | 10 +- kernel/kcov.c | 42 ++++--- kernel/relay.c | 33 +++--- mm/hugetlb.c | 77 +++++++----- mm/memory.c | 128 ++++++++++++-------- mm/secretmem.c | 2 +- mm/shmem.c | 49 ++++++-- mm/util.c | 150 ++++++++++++++++++++++- mm/vma.c | 74 ++++++++---- mm/vmalloc.c | 16 ++- tools/testing/vma/vma_internal.h | 164 +++++++++++++++++++++++++- 33 files changed, 1002 insertions(+), 304 deletions(-) -- 2.51.0