Re: [PATCH 13/30] mm/vma: refactor vmg_adjust_set_range() for clarity

From: Gregory Price

Date: Thu Jul 09 2026 - 11:25:22 EST


On Mon, Jun 29, 2026 at 01:23:24PM +0100, Lorenzo Stoakes wrote:
> Add comments with ASCII diagrams to describe what we're doing, avoid
> dubious use of PHYS_PFN(), and use vma_start_pgoff().
>
> The most complicated scenario represented here is vmg->__adjust_next_start
> - when this is set, vmg->[start, end] actually indicate the range to be
> retained, so take special care to describe this accurately.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

Reviewed-by: Gregory Price <gourry@xxxxxxxxxx>

> + /*
> + * vmg->start vmg->end
> + * | |
> + * v merge v
> + * <------------->
> + * delta
> + * <------>
> + * |------|----------------|
> + * | prev | middle |
> + * |------|----------------|
> + * ^
> + * |
> + * middle->vm_start
> + */

Even with these diagrams, it's a bit difficult to understand what the
actual intent/result of this chunk is (but that may be a limitation of
me not spending enough time reading the surrounding code, not a comment
of your work here).

~Gregory

> + /*
> + * Originally:
> + *
> + * vmg->start vmg->end
> + * | |
> + * v merge v
> + * <------------>
> + * . .
> + * merge_existing_range() updates to:
> + * . .
> + * vmg->start vmg->end .
> + * | | .
> + * v retain v .
> + * <----------> .
> + * delta .
> + * <-----> .
> + * |----------------|------|
> + * | middle | next |
> + * |----------------|------|
> + * ^
> + * |
> + * next->vm_start
> + */