Re: [PATCH V2] mm: mempolicy: skip non-migratable VMAs when setting MPOL_MF_LAZY

From: Liang Chen
Date: Fri Jan 15 2016 - 07:54:15 EST


Hi Naoya,

Yeah. Thanks for the remindingï

vma_policy_mof doesn't need to be checked because with MPOL_MF_LAZY
do_mbind always sets the MPOL_F_MOF flag.
VM_HUGETLB and VM_MIXEDMAP vma should be excluded to avoid compound
pages being marked for migration and unexpected COWs when handling
hugetlb fault.

I will send a patch to add these check soon.

Thanks,
Liang

On Wed, Jan 13, 2016 at 4:16 PM, Naoya Horiguchi
<n-horiguchi@xxxxxxxxxxxxx> wrote:
> Hello Liang,
>
> On Thu, Jan 07, 2016 at 11:52:38AM +0800, Liang Chen wrote:
>> MPOL_MF_LAZY is not visible from userspace since 'commit a720094ded8c
>> ("mm: mempolicy: Hide MPOL_NOOP and MPOL_MF_LAZY from userspace for now")'
>> , but it should still skip non-migratable VMAs such as VM_IO, VM_PFNMAP,
>> and VM_HUGETLB VMAs, and avoid useless overhead of minor faults.
>>
>> Signed-off-by: Liang Chen <liangchen.linux@xxxxxxxxx>
>> Signed-off-by: Gavin Guo <gavin.guo@xxxxxxxxxxxxx>
>> ---
>> Changes since v2:
>> - Add more description into the changelog
>>
>> We have been evaluating the enablement of MPOL_MF_LAZY again, and found
>> this issue. And we decided to push this patch upstream no matter if we
>> finally determine to propose re-enablement of MPOL_MF_LAZY or not. Since
>> it can be a potential problem even if MPOL_MF_LAZY is not enabled this
>> time.
>> ---
>> mm/mempolicy.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
>> index 87a1779..436ff411 100644
>> --- a/mm/mempolicy.c
>> +++ b/mm/mempolicy.c
>> @@ -610,7 +610,8 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
>>
>> if (flags & MPOL_MF_LAZY) {
>> /* Similar to task_numa_work, skip inaccessible VMAs */
>> - if (vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))
>> + if (vma_migratable(vma) &&
>> + vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))
>> change_prot_numa(vma, start, endvma);
>> return 1;
>> }
>
> task_numa_work() does more vma checks before entering change_prot_numa() like
> vma_policy_mof(), is_vm_hugetlb_page(), and (vma->vm_flags & VM_MIXEDMAP).
> So is it better to use the same check set to limit the target vmas to auto-numa
> enabled ones?
>
> Thanks,
> Naoya Horiguchi