On 5/30/22 08:36, Muchun Song wrote: > On Fri, May 27, 2022 at 03:58:48PM -0700, Mike Kravetz wrote: >> As an optimization for loops sequentially processing hugetlb address >> ranges, huge_pmd_unshare would update a passed address if it unshared a >> pmd. Updating a loop control variable outside the loop like this is >> generally a bad idea. These loops are now using hugetlb_mask_last_hp > > Totally agree. > >> to optimize scanning when non-present ptes are discovered. The same >> can be done when huge_pmd_unshare returns 1 indicating a pmd was >> unshared. >> >> Remove address update from huge_pmd_unshare. Change the passed argument >> type and update all callers. In loops sequentially processing addresses >> use hugetlb_mask_last_hp to update address if pmd is unshared. >> >> Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > > Acked-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> > > Some nits below. > >> ptep = huge_pte_offset(mm, address, sz); >> if (!ptep) >> continue; >> ptl = huge_pte_lock(h, mm, ptep); >> /* We don't want 'address' to be changed */ > > Dead comment, should be removed. Thanks! I missed that. -- Mike Kravetz