Re: [PATCH v2 11/13] mm/gup: Handle huge pmd for follow_pmd_mask()

From: Jason Gunthorpe
Date: Mon Jan 15 2024 - 13:51:24 EST


On Wed, Jan 03, 2024 at 05:14:21PM +0800, peterx@xxxxxxxxxx wrote:
> From: Peter Xu <peterx@xxxxxxxxxx>
>
> Replace pmd_trans_huge() with pmd_thp_or_huge() to also cover pmd_huge() as
> long as enabled.
>
> FOLL_TOUCH and FOLL_SPLIT_PMD only apply to THP, not yet huge.
>
> Since now follow_trans_huge_pmd() can process hugetlb pages, renaming it
> into follow_huge_pmd() to match what it does. Move it into gup.c so not
> depend on CONFIG_THP.
>
> When at it, move the ctx->page_mask setup into follow_huge_pmd(), only set
> it when the page is valid. It was not a bug to set it before even if GUP
> failed (page==NULL), because follow_page_mask() callers always ignores
> page_mask if so. But doing so makes the code cleaner.
>
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
> mm/gup.c | 107 ++++++++++++++++++++++++++++++++++++++++++++---
> mm/huge_memory.c | 86 +------------------------------------
> mm/internal.h | 5 +--
> 3 files changed, 105 insertions(+), 93 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason