Re: [PATCH -mm -v4 08/21] mm, THP, swap: Support to read a huge swap cluster for swapin a THP

From: Huang\, Ying
Date: Tue Jul 03 2018 - 22:25:04 EST


Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> writes:

> On Fri, Jun 22, 2018 at 11:51:38AM +0800, Huang, Ying wrote:
>> @@ -411,14 +414,32 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
> ...
>> + if (thp_swap_supported() && huge_cluster) {
>> + gfp_t gfp = alloc_hugepage_direct_gfpmask(vma);
>> +
>> + new_page = alloc_hugepage_vma(gfp, vma,
>> + addr, HPAGE_PMD_ORDER);
>
> When allocating a huge page, we ignore the gfp_mask argument.
>
> That doesn't matter right now since AFAICT we're not losing any flags: gfp_mask
> from existing callers of __read_swap_cache_async seems to always be a subset of
> GFP_HIGHUSER_MOVABLE and alloc_hugepage_direct_gfpmask always returns a
> superset of that.
>
> But maybe we should warn here in case we end up violating a restriction from a
> future caller. Something like this?:
>
>> + gfp_t gfp = alloc_hugepage_direct_gfpmask(vma);
> VM_WARN_ONCE((gfp | gfp_mask) != gfp,
> "ignoring gfp_mask bits");

This looks good! Thanks! Will add this.

Best Regards,
Huang, Ying