On 7/7/25 07:27, Lorenzo Stoakes wrote: > We are currently checking some things later, and some things > immediately. Aggregate the checks and avoid ones that need not be made. > > Simplify things by aligning lengths immediately. Defer setting the delta > parameter until later, which removes some duplicate code in the hugetlb > case. > > We can safely perform the checks moved from mremap_to() to > check_mremap_params() because: > > * If we set a new address via vrm_set_new_addr(), then this is guaranteed > to not overlap nor to position the new VMA past TASK_SIZE, so there's no > need to check these later. > > * We can simply page align lengths immediately. We do not need to check for > overlap nor TASK_SIZE sanity after hugetlb alignment as this asserts > addresses are huge-aligned, then huge-aligns lengths, rounding down. This > means any existing overlap would have already been caught. > > Moving things around like this lays the groundwork for subsequent changes > to permit operations on batches of VMAs. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>