From: Anshuman Khandual khandual@linux.vnet.ibm.com
ascend inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4JMLR CVE: NA -------------------
Kernel cannot track device memory accesses behind VMAs containing CDM memory. Hence all the VM_CDM marked VMAs should not be part of the auto NUMA migration scheme. This patch also adds a new function is_cdm_vma() to detect any VMA marked with flag VM_CDM.
Signed-off-by: Anshuman Khandual khandual@linux.vnet.ibm.com Signed-off-by: Lijun Fang fanglijun3@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- include/linux/mempolicy.h | 14 ++++++++++++++ kernel/sched/fair.c | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 5f1c74df264d..64ab4398ba90 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -181,6 +181,20 @@ extern int mpol_parse_str(char *str, struct mempolicy **mpol);
extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);
+#ifdef CONFIG_COHERENT_DEVICE +static inline bool is_cdm_vma(struct vm_area_struct *vma) +{ + if (vma->vm_flags & VM_CDM) + return true; + return false; +} +#else +static inline bool is_cdm_vma(struct vm_area_struct *vma) +{ + return false; +} +#endif + /* Check if a vma is migratable */ extern bool vma_migratable(struct vm_area_struct *vma);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9c34ad6f9a67..1a0cb9a4161e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2836,7 +2836,8 @@ static void task_numa_work(struct callback_head *work) } for (; vma; vma = vma->vm_next) { if (!vma_migratable(vma) || !vma_policy_mof(vma) || - is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_MIXEDMAP)) { + is_vm_hugetlb_page(vma) || is_cdm_vma(vma) || + (vma->vm_flags & VM_MIXEDMAP)) { continue; }