]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/vma: the pgoff is correct if can_merge_right
authorWei Yang <richard.weiyang@gmail.com>
Thu, 24 Oct 2024 09:33:47 +0000 (09:33 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:26 +0000 (21:29 -0700)
commitfc53259b2aae96a4ebbed574adc06ade6fdd47ac
tree09f6d4d0316980958cf1ffd84d91abe7a5bfdc71
parent6d015f08adc097adb543811261b400bf1f855cc4
mm/vma: the pgoff is correct if can_merge_right

By this point can_vma_merge_right() must have returned true, which implies
can_vma_merge_before() also returned true, which already asserts that the
pgoff is as expected for a merge with the following VMA, thus this
assignment is redundant.

Below is a more detail explanation.

Current definition of can_vma_merge_right() is:

static bool can_vma_merge_right(struct vma_merge_struct *vmg,
bool can_merge_left)
{
if (!vmg->next || vmg->end != vmg->next->vm_start ||
    !can_vma_merge_before(vmg))
return false;
...
}

And:

static bool can_vma_merge_before(struct vma_merge_struct *vmg)
{
pgoff_t pglen = PHYS_PFN(vmg->end - vmg->start);
...
if (vmg->next->vm_pgoff == vmg->pgoff + pglen)
return true;
...
}

Which implies vmg->pgoff == vmg->next->vm_pgoff - pglen.

None of these values are changed between the check and prior assignment,
so this was an entirely redundant assignment.

[lorenzo.stoakes@oracle.com: rephrase the change log]
Link: https://lkml.kernel.org/r/20241024093347.18057-1-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Jann Horn <jannh@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vma.c