Re: [PATCH v2 3/4] mm, madvise: move madvise_set_anon_name() down the file
From: Suren Baghdasaryan
Date: Tue Jun 24 2025 - 10:48:58 EST
On Tue, Jun 24, 2025 at 7:05 AM David Hildenbrand <david@xxxxxxxxxx> wrote:
>
> On 24.06.25 15:03, Vlastimil Babka wrote:
> > Preparatory change so that we can use madvise_lock()/unlock() in the
> > function without forward declarations or more thorough shuffling.
If you respin the series please add a note that there is no functional
change here.
> >
> > Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>
> > ---
> > mm/madvise.c | 64 ++++++++++++++++++++++++++++++------------------------------
> > 1 file changed, 32 insertions(+), 32 deletions(-)
> >
> > diff --git a/mm/madvise.c b/mm/madvise.c
> > index 7e8819b5e9a0f183213ffe19d7e52bd5fda5f49d..cae064479cdf908707c45b941bd03d43d095eab6 100644
> > --- a/mm/madvise.c
> > +++ b/mm/madvise.c
> > @@ -133,38 +133,6 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,
> >
> > return 0;
> > }
> > -
> > -static int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
> > - unsigned long len_in, struct anon_vma_name *anon_name)
> > -{
> > - unsigned long end;
> > - unsigned long len;
> > - struct madvise_behavior madv_behavior = {
> > - .mm = mm,
> > - .behavior = __MADV_SET_ANON_VMA_NAME,
> > - .lock_mode = MADVISE_MMAP_WRITE_LOCK,
> > - .anon_name = anon_name,
> > - };
> > -
> > - if (start & ~PAGE_MASK)
> > - return -EINVAL;
> > - len = (len_in + ~PAGE_MASK) & PAGE_MASK;
> > -
> > - /* Check to see whether len was rounded up from small -ve to zero */
> > - if (len_in && !len)
> > - return -EINVAL;
> > -
> > - end = start + len;
> > - if (end < start)
> > - return -EINVAL;
> > -
> > - if (end == start)
> > - return 0;
> > -
> > - madv_behavior.range.start = start;
> > - madv_behavior.range.end = end;
> > - return madvise_walk_vmas(&madv_behavior);
> > -}
> > #else /* CONFIG_ANON_VMA_NAME */
> > static int replace_anon_vma_name(struct vm_area_struct *vma,
> > struct anon_vma_name *anon_name)
> > @@ -2109,6 +2077,38 @@ static inline bool is_valid_name_char(char ch)
> > !strchr(ANON_VMA_NAME_INVALID_CHARS, ch);
> > }
> >
> > +static int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
> > + unsigned long len_in, struct anon_vma_name *anon_name)
> > +{
> > + unsigned long end;
> > + unsigned long len;
> > + struct madvise_behavior madv_behavior = {
> > + .mm = mm,
> > + .behavior = __MADV_SET_ANON_VMA_NAME,
> > + .lock_mode = MADVISE_MMAP_WRITE_LOCK,
> > + .anon_name = anon_name,
> > + };
> > +
> > + if (start & ~PAGE_MASK)
> > + return -EINVAL;
> > + len = (len_in + ~PAGE_MASK) & PAGE_MASK;
> > +
> > + /* Check to see whether len was rounded up from small -ve to zero */
> > + if (len_in && !len)
> > + return -EINVAL;
> > +
> > + end = start + len;
> > + if (end < start)
> > + return -EINVAL;
> > +
> > + if (end == start)
> > + return 0;
> > +
> > + madv_behavior.range.start = start;
> > + madv_behavior.range.end = end;
> > + return madvise_walk_vmas(&madv_behavior);
> > +}
> > +
> > int set_anon_vma_name(unsigned long addr, unsigned long size,
> > const char __user *uname)
> > {
> >
>
> Personally, I would squash that into #4, given that #4 is pretty small ;)
>
> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
>
> --
> Cheers,
>
> David / dhildenb
>