RE: [PATCH] perf map: fix overlapped map handling
From: Steve MacLean
Date: Fri Sep 20 2019 - 17:46:20 EST
>> after->start = map->end;
>> + after->pgoff = pos->map_ip(pos, map->end);
>
> So is this equivalent to what __split_vma() does in the kernel, i.e.:
>
> if (new_below)
> new->vm_end = addr;
> else {
> new->vm_start = addr;
> new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
> }
>
> where new->vm_pgoff starts equal to the vm_pgoff of the mmap being split?
It is roughly equivalent. The pgoff in struct map is stored in bytes not in pages, so it doesn't include the shift.
An earlier version of this patch used:
after->start = map->end;
+ after->pgoff += map->end - pos->start;
Instead of the newer Functionally equivalent:
after->start = map->end;
+ after->pgoff = pos->map_ip(pos, map->end);
I preferred the latter form as it made more sense with the assertion that the mapping of map->end should match in pos and after.
Steve