On Mon, Jun 29, 2026 at 01:23:36PM +0100, Lorenzo Stoakes wrote: > We are calculating the pgoff as an offset, since we have vma_add_pgoff() > and vma_sub_pgoff() available, just offset this value directly and use > __vma_set_range() for vma->vm_[start, end] values. > > We take care to update the range before offsetting the page offset, so the > adjusted VMA's vm_start and vm_pgoff are mutually consistent at the point > the page offset helpers operate - this matters once vma_set_pgoff() comes > to assert invariants which relate the two. > > Doing so lays the foundation for future work which allows for use of > virtual page offsets for MAP_PRIVATE-file backed mappings. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes <[email protected]> > --- > mm/vma.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/mm/vma.c b/mm/vma.c > index e3355eab11f2..0579fc8c9bd5 100644 > --- a/mm/vma.c > +++ b/mm/vma.c > @@ -714,9 +714,6 @@ void validate_mm(struct mm_struct *mm) > */ > static void vmg_adjust_set_range(struct vma_merge_struct *vmg) > { > - struct vm_area_struct *adjust; > - pgoff_t pgoff; > - > if (vmg->__adjust_middle_start) { > /* > * vmg->start vmg->end > @@ -735,8 +732,8 @@ static void vmg_adjust_set_range(struct vma_merge_struct > *vmg) > struct vm_area_struct *middle = vmg->middle; > const unsigned long delta = vmg->end - middle->vm_start; > > - pgoff = vma_start_pgoff(middle) + (delta >> PAGE_SHIFT); > - adjust = middle; > + __vma_set_range(middle, vmg->end, middle->vm_end); > + vma_add_pgoff(middle, delta >> PAGE_SHIFT); > } else if (vmg->__adjust_next_start) { > /* > * Originally: > @@ -764,13 +761,9 @@ static void vmg_adjust_set_range(struct vma_merge_struct > *vmg) > struct vm_area_struct *next = vmg->next; > const unsigned long delta = next->vm_start - vmg->end; > > - pgoff = vma_start_pgoff(next) - (delta >> PAGE_SHIFT); > - adjust = next; > - } else { > - return; > + __vma_set_range(next, vmg->end, next->vm_end); > + vma_sub_pgoff(next, delta >> PAGE_SHIFT); > } > - > - vma_set_range(adjust, vmg->end, adjust->vm_end, pgoff); > }
Maybe this should be squashed with That Other Patch that touches this. Anyway, Reviewed-by: Pedro Falcato <[email protected]> -- Pedro
