From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Yajun Deng <yajun.deng@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap: introduce vma_range_init()
Date: Mon, 22 Jan 2024 19:18:30 -0500 [thread overview]
Message-ID: <20240123001830.glqdmrv2qc56zfpc@revolver> (raw)
In-Reply-To: <20240122154031.b710f834b14d9027176f439a@linux-foundation.org>
* Andrew Morton <akpm@linux-foundation.org> [240122 18:40]:
> On Mon, 22 Jan 2024 17:00:31 -0500 "Liam R. Howlett" <Liam.Howlett@Oracle.com> wrote:
>
> > * Yajun Deng <yajun.deng@linux.dev> [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@linux.dev>
> > > ---
> > > 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..
>
> > 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().
>
Using vma_set_range() leaves vma_range() or vma_size(), which could be
added for the calculations of vma->vm_end - vma->vm_start. Davidlohr
suggested such a beast a few years ago, but that one would need to live
in the include/linux/mm.h as it occurs a lot more.
$ git grep "vma->vm_end - vma->vm_start" | wc -l
198
.. for just those named vma.
next prev parent reply other threads:[~2024-01-23 0:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 2:15 Yajun Deng
2024-01-22 22:00 ` Liam R. Howlett
2024-01-22 23:40 ` Andrew Morton
2024-01-23 0:18 ` Liam R. Howlett [this message]
2024-01-23 2:23 ` Yajun Deng
2024-01-23 3:19 ` Liam R. Howlett
2024-01-23 3:41 ` Yajun Deng
2024-01-23 14:39 ` Liam R. Howlett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123001830.glqdmrv2qc56zfpc@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=yajun.deng@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox