提交 2d2fe6b4 编写于 作者: D Ding Tianhong 提交者: Yang Yingliang

ascend: mm: add an owner for mm_struct

ascend inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI
CVE: NA

-------------------------------------------------

The mm->owner is only used for MEMCG currently, but the ascend share
pool features will use it later, so make it to a general features and
select it for CONFIG_MEMCG.
Signed-off-by: NTang Yizhou <tangyizhou@huawei.com>
Signed-off-by: NDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 562117a9
...@@ -455,7 +455,7 @@ struct mm_struct { ...@@ -455,7 +455,7 @@ struct mm_struct {
spinlock_t ioctx_lock; spinlock_t ioctx_lock;
struct kioctx_table __rcu *ioctx_table; struct kioctx_table __rcu *ioctx_table;
#endif #endif
#ifdef CONFIG_MEMCG #ifdef CONFIG_MM_OWNER
/* /*
* "owner" points to a task that is regarded as the canonical * "owner" points to a task that is regarded as the canonical
* user/owner of this mm. All of the following must be true in * user/owner of this mm. All of the following must be true in
......
...@@ -704,6 +704,7 @@ config MEMCG ...@@ -704,6 +704,7 @@ config MEMCG
bool "Memory controller" bool "Memory controller"
select PAGE_COUNTER select PAGE_COUNTER
select EVENTFD select EVENTFD
select MM_OWNER
help help
Provides control over the memory footprint of tasks in a cgroup. Provides control over the memory footprint of tasks in a cgroup.
......
...@@ -330,7 +330,7 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent) ...@@ -330,7 +330,7 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
} }
} }
#ifdef CONFIG_MEMCG #ifdef CONFIG_MM_OWNER
/* /*
* A task is exiting. If it owned this mm, find a new owner for the mm. * A task is exiting. If it owned this mm, find a new owner for the mm.
*/ */
...@@ -416,7 +416,7 @@ void mm_update_next_owner(struct mm_struct *mm) ...@@ -416,7 +416,7 @@ void mm_update_next_owner(struct mm_struct *mm)
task_unlock(c); task_unlock(c);
put_task_struct(c); put_task_struct(c);
} }
#endif /* CONFIG_MEMCG */ #endif /* CONFIG_MM_OWNER */
/* /*
* Turn us into a lazy TLB process if we * Turn us into a lazy TLB process if we
......
...@@ -962,7 +962,7 @@ static void mm_init_aio(struct mm_struct *mm) ...@@ -962,7 +962,7 @@ static void mm_init_aio(struct mm_struct *mm)
static __always_inline void mm_clear_owner(struct mm_struct *mm, static __always_inline void mm_clear_owner(struct mm_struct *mm,
struct task_struct *p) struct task_struct *p)
{ {
#ifdef CONFIG_MEMCG #ifdef CONFIG_MM_OWNER
if (mm->owner == p) if (mm->owner == p)
WRITE_ONCE(mm->owner, NULL); WRITE_ONCE(mm->owner, NULL);
#endif #endif
...@@ -970,7 +970,7 @@ static __always_inline void mm_clear_owner(struct mm_struct *mm, ...@@ -970,7 +970,7 @@ static __always_inline void mm_clear_owner(struct mm_struct *mm,
static void mm_init_owner(struct mm_struct *mm, struct task_struct *p) static void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
{ {
#ifdef CONFIG_MEMCG #ifdef CONFIG_MM_OWNER
mm->owner = p; mm->owner = p;
#endif #endif
} }
......
...@@ -299,6 +299,10 @@ config VIRT_TO_BUS ...@@ -299,6 +299,10 @@ config VIRT_TO_BUS
deprecated interface virt_to_bus(). All new architectures deprecated interface virt_to_bus(). All new architectures
should probably not select this. should probably not select this.
config MM_OWNER
bool "Enable the ownership the mm owner"
help
This option enables mm_struct's to have an owner.
config MMU_NOTIFIER config MMU_NOTIFIER
bool bool
......
...@@ -129,7 +129,7 @@ void dump_mm(const struct mm_struct *mm) ...@@ -129,7 +129,7 @@ void dump_mm(const struct mm_struct *mm)
#ifdef CONFIG_AIO #ifdef CONFIG_AIO
"ioctx_table %px\n" "ioctx_table %px\n"
#endif #endif
#ifdef CONFIG_MEMCG #ifdef CONFIG_MM_OWNER
"owner %px " "owner %px "
#endif #endif
"exe_file %px\n" "exe_file %px\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册