Re: [PATCH 1/2] mm/mremap: Clean up vma_to_resize()

From: Liam R. Howlett
Date: Thu Oct 17 2024 - 19:53:53 EST


* Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> [241017 17:08]:
> On Thu, 17 Oct 2024 11:15:20 -0700 Jeff Xu <jeffxu@xxxxxxxxxxxx> wrote:
>
> > > > > -static struct vm_area_struct *vma_to_resize(unsigned long addr,
> > > > > +static int mremap_vma_check(struct vm_area_struct *vma, unsigned long addr,
> > > > The original function is vma_to_resize, and mremap_vma_check is
> > > > missing this context.
> > > > Maybe mremap_vma_check_resize is a better name ?
> > >
> > > Good point. That suggestion is long though. Perhaps
> > > vma_check_resize(), since this is a static function in the mremap.c
> > > file, it is fine to drop mremap from the name.
> > >
> > I'm ok with that.
>
> Any function with "check" in the name makes my teeth ache. "check"
> what? And the name doesn't carry any connotation of the return value's
> meaning.
>
> eg, "check_the_cheese()" versus "cheese_is_fresh()". The latter name
> tells you what is being checked and it tells you what a "true" return
> value means.

Fair enough, how about resize_is_valid()?

>
> Also, the dang function isn't documented.

I'll add that, thanks.

>
> Also, why is mremap_to() calling mremap_vma_check() without testing its
> return value? mremap_vma_check() doesn't actually alter anything, does
> it? If it does then it's misnamed.

That's an issue, I'll fix it.

Thanks,
Liam