Re: [PATCH] mm/mmap: introduce vma_range_init()

From: Liam R. Howlett
Date: Tue Jan 23 2024 - 09:40:38 EST


* Yajun Deng <yajun.deng@xxxxxxxxx> [240122 22:41]:
>
> On 2024/1/23 11:19, Liam R. Howlett wrote:
> > * Yajun Deng <yajun.deng@xxxxxxxxx> [240122 21:23]:
> > > On 2024/1/23 08:18, Liam R. Howlett wrote:
> > > > * Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> [240122 18:40]:
> > > > > On Mon, 22 Jan 2024 17:00:31 -0500 "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx> wrote:
> > > > >
> > > > > > * Yajun Deng <yajun.deng@xxxxxxxxx> [240110 21:15]:
> > > > > > > There is a lot of code needs to set the range of vma, introduce
> > > > > > > vma_range_init() to initialize the range of vma.
> > > > > > >
> > > > > > > Signed-off-by: Yajun Deng <yajun.deng@xxxxxxxxx>
> > > > > > > ---
> > > > > > > include/linux/mm.h | 9 +++++++++
> > > > > > > mm/mmap.c | 29 +++++++----------------------
> > > > > > > 2 files changed, 16 insertions(+), 22 deletions(-)
> > > > > > This isn't a whole lot of code, are there others? We're losing code
> > > > > > clarity in favour of saving 6 lines?
> > > > > >
> > > > > Oh. I thought it was a nice cleanup which made things more clear.
> > > > I'm not totally against it; that's why I suggested the changes below. I
> > > > think a name change would go a long way for clarity. It's not as much as
> > > > I though it would be though.
> > > >
> > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > > > > > > index f5a97dec5169..abb4534be3cc 100644
> > > > > > > --- a/include/linux/mm.h
> > > > > > > +++ b/include/linux/mm.h
> > > > > > > @@ -3516,6 +3516,15 @@ static inline bool range_in_vma(struct vm_area_struct *vma,
> > > > > > > return (vma && vma->vm_start <= start && end <= vma->vm_end);
> > > > > > > }
> > > > > > > +static inline void vma_range_init(struct vm_area_struct *vma,
> > > > > > Any reason this can't be in mm/internal.h ?
> > > > > That would be good.
> > > > One other thing, do we trust this to be inlined correctly by the
> > > > compiler or should this be __always_inline? I'd expect it to be okay as
> > > > it is, but I've been proven wrong in a perf trace before..
> > > >
> > > Okay, I would take __always_inline and put it in mm/internal.h in v2.
> > I'm not confident in this suggestion as the rest.
> > Please rename the function when you move it.
>
> inline is a suggestion, __always_inline is mandatory.
> I think __always_inline is better if we're demanding.
>
> > > > > > vma_range_set(), vma_set_range(), or just vma_range() might be a better
> > > > > > name? My thinking is that some of these are actually modifying the vma
> > > > > > and not just initializing it, right?
> > > > > I'd vote for vma_set_range().
> > ^ This part, use vma_set_range() please.
>
> Okay.
>
>
> By the way, I sent another patch with ("mm/mmap: simplify vma_merge()")
> subject a few days ago.
>
> Please comment if you would like.

Oh, okay.

Can you please Cc people on these? I almost missed this one and I know
several other people will be interested in the vma_merge() patch
changes.