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

From: Andrew Morton
Date: Thu Oct 17 2024 - 17:08:19 EST


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.

Also, the dang function isn't documented.

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.