Re: [PATCH -mm] mm, madvise, THP: Use THP aligned address in madvise_free_huge_pmd()

From: Michal Hocko
Date: Thu Mar 15 2018 - 08:29:53 EST


On Wed 14-03-18 21:39:54, Zi Yan wrote:
> This cannot happen.
>
> Two address parameters are passed: addr and next.
> If âaddrâ is not aligned and ânextâ is aligned or the end of madvise range, which might not be aligned,
> either way next - addr < HPAGE_PMD_SIZE.
>
> This means the code in âif (next - addr != HPAGE_PMD_SIZE)â, which is above your second hunk,
> will split the THP between âaddrâ and ânextâ and get out as long as âaddrâ is not aligned.
> Thus, the code in your second hunk should always get aligned âaddrâ.

OK, so what would happen if the above doesn't hold anymore after some
change up the call chain? Is it critical? If yes, do we want VM_BUG_ON
to detect that? Or at least document the asumption?
--
Michal Hocko
SUSE Labs