Re: [patch for-5.3 0/4] revert immediate fallback to remote hugepages

From: Vlastimil Babka
Date: Tue Oct 29 2019 - 10:15:05 EST


On 10/24/19 8:59 PM, David Rientjes wrote:
>> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
>> index 4ae967bcf954..2c48146f3ee2 100644
>> --- a/mm/mempolicy.c
>> +++ b/mm/mempolicy.c
>> @@ -2129,18 +2129,20 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma,
>> nmask = policy_nodemask(gfp, pol);
>> if (!nmask || node_isset(hpage_node, *nmask)) {
>> mpol_cond_put(pol);
>> + /*
>> + * First, try to allocate THP only on local node, but
>> + * don't reclaim unnecessarily, just compact.
>> + */
>> page = __alloc_pages_node(hpage_node,
>> - gfp | __GFP_THISNODE, order);
>> + gfp | __GFP_THISNODE | __GFP_NORETRY, order);
>>
>> /*
>> - * If hugepage allocations are configured to always
>> - * synchronous compact or the vma has been madvised
>> - * to prefer hugepage backing, retry allowing remote
>> - * memory as well.
>> + * If that fails, allow both compaction and reclaim,
>> + * but on all nodes.
>> */
>> - if (!page && (gfp & __GFP_DIRECT_RECLAIM))
>> + if (!page)
>> page = __alloc_pages_node(hpage_node,
>> - gfp | __GFP_NORETRY, order);
>> + gfp, order);
>>
>> goto out;
>> }
> Hi Vlastimil,
>
> For the default case where thp enabled is not set to "always" and the VMA

I assume you meant "defrag" instead of "enabled".

> is not madvised for MADV_HUGEPAGE, how does this prefer to return node
> local pages rather than remote hugepages? The idea is to optimize for
> access latency when the vma has not been explicitly madvised.

Right, you mentioned this before IIRC, and I forgot. How about this?
We could be also smarter and consolidate to a single attempt if there's
actually just a single NUMA node, but that can be optimized later.

----8<----