On 7/10/26 22:17, Lorenzo Stoakes wrote: > With __install_special_mapping() moved to vma.c, vma_set_range() can be > made into a static function there and is now completely isolated from the > rest of mm.
Pedantic nit: it was already "static", but in a .h file Yeah it was also "inline" but that's not the important part of this change. So I'd say it was rather moved to vma.c, but you can ignore this nit if you want. > While we're here, we can also remove the insert_vm_struct() declaration > from mm.h - the function is implemented in vma.c and already declared in > vma.h, and has no users outside of mm. > > Also update the VMA userland tests to reflect this change. > > No functional change intended. > > Reviewed-by: Pedro Falcato <[email protected]> > Reviewed-by: Gregory Price <[email protected]> > Signed-off-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Vlastimil Babka (SUSE) <[email protected]> > --- > include/linux/mm.h | 1 - > mm/internal.h | 9 --------- > mm/vma.c | 8 ++++++++ > tools/testing/vma/shared.c | 9 --------- > tools/testing/vma/shared.h | 5 ----- > 5 files changed, 8 insertions(+), 24 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 3d69b597b9b1..762313b47301 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -4130,7 +4130,6 @@ void anon_rmap_tree_verify(struct anon_vma_chain *avc); > > /* mmap.c */ > extern int __vm_enough_memory(const struct mm_struct *mm, long pages, int > cap_sys_admin); > -extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *); > extern void exit_mmap(struct mm_struct *); > bool mmap_read_lock_maybe_expand(struct mm_struct *mm, struct vm_area_struct > *vma, > unsigned long addr, bool write); > diff --git a/mm/internal.h b/mm/internal.h > index 01a762bcc2b2..2c650d280e90 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -1540,15 +1540,6 @@ extern bool mirrored_kernelcore; > bool memblock_has_mirror(void); > void memblock_free_all(void); > > -static __always_inline void vma_set_range(struct vm_area_struct *vma, > - unsigned long start, unsigned long > end, > - pgoff_t pgoff) > -{ > - vma->vm_start = start; > - vma->vm_end = end; > - vma->vm_pgoff = pgoff; > -} > - > static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma) > { > /* > diff --git a/mm/vma.c b/mm/vma.c > index 5308aa5a8c91..cc0e449ad0be 100644 > --- a/mm/vma.c > +++ b/mm/vma.c > @@ -70,6 +70,14 @@ struct mmap_state { > .state = VMA_MERGE_START, \ > } > > +static void vma_set_range(struct vm_area_struct *vma, unsigned long start, > + unsigned long end, pgoff_t pgoff) > +{ > + vma->vm_start = start; > + vma->vm_end = end; > + vma->vm_pgoff = pgoff; > +} > + > /* Was this VMA ever forked from a parent, i.e. maybe contains CoW mappings? > */ > static bool vma_is_fork_child(struct vm_area_struct *vma) > { > diff --git a/tools/testing/vma/shared.c b/tools/testing/vma/shared.c > index 2565a5aecb80..bea9ea6db02a 100644 > --- a/tools/testing/vma/shared.c > +++ b/tools/testing/vma/shared.c > @@ -120,12 +120,3 @@ unsigned long rlimit(unsigned int limit) > { > return (unsigned long)-1; > } > - > -void vma_set_range(struct vm_area_struct *vma, > - unsigned long start, unsigned long end, > - pgoff_t pgoff) > -{ > - vma->vm_start = start; > - vma->vm_end = end; > - vma->vm_pgoff = pgoff; > -} > diff --git a/tools/testing/vma/shared.h b/tools/testing/vma/shared.h > index 8b9e3b11c3cb..ca4f1238f1c7 100644 > --- a/tools/testing/vma/shared.h > +++ b/tools/testing/vma/shared.h > @@ -125,8 +125,3 @@ void __vma_set_dummy_anon_vma(struct vm_area_struct *vma, > /* Provide a simple dummy VMA/anon_vma dummy setup for testing. */ > void vma_set_dummy_anon_vma(struct vm_area_struct *vma, > struct anon_vma_chain *avc); > - > -/* Helper function to specify a VMA's range. */ > -void vma_set_range(struct vm_area_struct *vma, > - unsigned long start, unsigned long end, > - pgoff_t pgoff); >
