Re: [PATCH v5 02/14] mm/gup: check every subpage of a compound page during isolation

From: Jason Gunthorpe
Date: Tue Jan 19 2021 - 13:57:42 EST


On Mon, Jan 18, 2021 at 11:39:08PM -0500, Pavel Tatashin wrote:
> When pages are isolated in check_and_migrate_movable_pages() we skip
> compound number of pages at a time. However, as Jason noted, it is
> not necessary correct that pages[i] corresponds to the pages that
> we skipped. This is because it is possible that the addresses in
> this range had split_huge_pmd()/split_huge_pud(), and these functions
> do not update the compound page metadata.
>
> The problem can be reproduced if something like this occurs:
>
> 1. User faulted huge pages.
> 2. split_huge_pmd() was called for some reason
> 3. User has unmapped some sub-pages in the range
> 4. User tries to longterm pin the addresses.
>
> The resulting pages[i] might end-up having pages which are not compound
> size page aligned.
>
> Fixes: aa712399c1e8 ("mm/gup: speed up check_and_migrate_cma_pages() on huge page")
>
> Reported-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

No new line after fixes

> Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> mm/gup.c | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)

Looks good

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Thanks,
Jason