[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpEBLNH9KKXNYnYL+7AjzfZcrqfFqtsZmMEzn=sa-Zmc3Q@mail.gmail.com>
Date: Tue, 24 Jun 2025 07:33:45 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: David Hildenbrand <david@...hat.com>
Cc: Vlastimil Babka <vbabka@...e.cz>, Andrew Morton <akpm@...ux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Jann Horn <jannh@...gle.com>, Mike Rapoport <rppt@...nel.org>, Michal Hocko <mhocko@...e.com>,
Colin Cross <ccross@...gle.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] mm, madvise: move madvise_set_anon_name() down the file
On Tue, Jun 24, 2025 at 7:05 AM David Hildenbrand <david@...hat.com> 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@...e.cz>
> > ---
> > 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@...hat.com>
Reviewed-by: Suren Baghdasaryan <surenb@...gle.com>
>
> --
> Cheers,
>
> David / dhildenb
>
Powered by blists - more mailing lists