On Thu, Jul 02, 2026 at 12:22:56PM +0100, Pedro Falcato wrote: > On Mon, Jun 29, 2026 at 01:23:33PM +0100, Lorenzo Stoakes wrote: > > This function is operating on VMAs and rightly belongs in vma.c, where it > > can be subject to VMA userland testing and allows us to isolate it from the > > rest of mm. > > > > The _install_special_mapping() function will remain in mmap.c as a wrapper, > > since this is used by architecture-specific code. > > > > Doing so allows us to isolate more functions in vma.c for the same reasons. > > > > This forms part of work to allow for tracking MAP_PRIVATE file-backed > > mappings by their anonymous virtual page offset, as doing so allows us to > > isolate and keep code that interacts with this together. > > > > No functional change intended. > > > > Signed-off-by: Lorenzo Stoakes <[email protected]> > > --- > > mm/mmap.c | 38 -------------------------------------- > > mm/vma.c | 38 ++++++++++++++++++++++++++++++++++++++ > > mm/vma.h | 5 +++++ > > 3 files changed, 43 insertions(+), 38 deletions(-) > > > > diff --git a/mm/mmap.c b/mm/mmap.c > > index 2d09a57e3620..46174e706bbe 100644 > > --- a/mm/mmap.c > > +++ b/mm/mmap.c > > @@ -1447,44 +1447,6 @@ static vm_fault_t special_mapping_fault(struct > > vm_fault *vmf) > > return VM_FAULT_SIGBUS; > > } > > > > -static struct vm_area_struct *__install_special_mapping( > > - struct mm_struct *mm, > > - unsigned long addr, unsigned long len, > > - vm_flags_t vm_flags, void *priv, > > - const struct vm_operations_struct *ops) > > -{ > > - int ret; > > - struct vm_area_struct *vma; > > - > > - vma = vm_area_alloc(mm); > > - if (unlikely(vma == NULL)) > > - return ERR_PTR(-ENOMEM); > > - > > - vma_set_range(vma, addr, addr + len, 0); > > - vm_flags |= mm->def_flags | VM_DONTEXPAND; > > - if (pgtable_supports_soft_dirty()) > > - vm_flags |= VM_SOFTDIRTY; > > - vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK); > > - vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); > > - > > - vma->vm_ops = ops; > > - vma->vm_private_data = priv; > > - > > - ret = insert_vm_struct(mm, vma); > > - if (ret) > > - goto out; > > - > > - vm_stat_account(mm, vma->vm_flags, len >> PAGE_SHIFT); > > - > > - perf_event_mmap(vma); > > - > > - return vma; > > - > > -out: > > - vm_area_free(vma); > > - return ERR_PTR(ret); > > -} > > - > > bool vma_is_special_mapping(const struct vm_area_struct *vma, > > const struct vm_special_mapping *sm) > > { > > diff --git a/mm/vma.c b/mm/vma.c > > index cb7222e20c93..f4de706a2728 100644 > > --- a/mm/vma.c > > +++ b/mm/vma.c > > @@ -3399,3 +3399,41 @@ __weak unsigned long vma_mmu_pagesize(struct > > vm_area_struct *vma) > > { > > return vma_kernel_pagesize(vma); > > } > > + > > +struct vm_area_struct *__install_special_mapping( > > + struct mm_struct *mm, > > + unsigned long addr, unsigned long len, > > + vm_flags_t vm_flags, void *priv, > > + const struct vm_operations_struct *ops) > > +{ > > + int ret; > > + struct vm_area_struct *vma; > > + > > + vma = vm_area_alloc(mm); > > + if (unlikely(vma == NULL)) > > + return ERR_PTR(-ENOMEM); > > + > > + vma_set_range(vma, addr, addr + len, 0); > > + vm_flags |= mm->def_flags | VM_DONTEXPAND; > > + if (pgtable_supports_soft_dirty()) > > + vm_flags |= VM_SOFTDIRTY; > > + vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK); > > + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); > > + > > + vma->vm_ops = ops; > > + vma->vm_private_data = priv; > > + > > + ret = insert_vm_struct(mm, vma); > > + if (ret) > > + goto out; > > + > > + vm_stat_account(mm, vma->vm_flags, len >> PAGE_SHIFT); > > + > > + perf_event_mmap(vma); > > + > > + return vma; > > + > > +out: > > + vm_area_free(vma); > > + return ERR_PTR(ret); > > +} > > diff --git a/mm/vma.h b/mm/vma.h > > index 47fe35e5307e..14f026bf3be4 100644 > > --- a/mm/vma.h > > +++ b/mm/vma.h > > @@ -775,4 +775,9 @@ static inline bool map_deny_write_exec(const > > vma_flags_t *old, > > } > > #endif > > > > +struct vm_area_struct *__install_special_mapping(struct mm_struct *mm, > > + unsigned long addr, unsigned long len, > > + vm_flags_t vm_flags, void *priv, > > + const struct vm_operations_struct *ops); > > + > > #endif /* __MM_VMA_H */ > > I'm really annoyed that _install_special_mapping has a leading underscore. > That's it.
Yeah it's horrible :) > > Reviewed-by: Pedro Falcato <[email protected]> Thanks! > > -- > Pedro Cheers, Lorenzo
