From: Yuan Can yuancan@huawei.com
ascend inclusion category: feature bugzilla: NA CVE: NA
-----------------------------------------------------------------
svsp_mm may still be used by hardware(aicore/dvpp) after process is gone, same as normal mm, thus release should happen when normal mm is actually released.
Signed-off-by: Yuan Can yuancan@huawei.com Signed-off-by: Zhang Zekun zhangzekun11@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com --- include/linux/mm_types.h | 4 ++++ kernel/fork.c | 12 ++++++++++++ 2 files changed, 16 insertions(+)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 99ae1f9a9019..cf6b2a435d52 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -391,7 +391,11 @@ struct vm_area_struct { #endif struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
+#ifdef CONFIG_ASCEND_SVSP + struct mm_struct *svsp_mm; +#else KABI_RESERVE(1) +#endif KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4) diff --git a/kernel/fork.c b/kernel/fork.c index 150c970e84f4..5e72f644c2a5 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1059,6 +1059,10 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, mm_init_uprobes_state(mm); hugetlb_count_init(mm);
+#ifdef CONFIG_ASCEND_SVSP + mm->svsp_mm = NULL; +#endif + if (current->mm) { mm->flags = current->mm->flags & MMF_INIT_MASK; mm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK; @@ -1121,6 +1125,14 @@ static inline void __mmput(struct mm_struct *mm) { VM_BUG_ON(atomic_read(&mm->mm_users));
+#ifdef CONFIG_ASCEND_SVSP + if (mm->svsp_mm) { + exit_mmap(mm->svsp_mm); + mmdrop(mm->svsp_mm); + mm->svsp_mm = NULL; + } +#endif + uprobe_clear_state(mm); exit_aio(mm); ksm_exit(mm);