提交 ebde394a 编写于 作者: A Anshuman Khandual 提交者: Zheng Zengkai

mm: Exclude CDM nodes from task->mems_allowed and root cpuset

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

Task struct's mems_allowed element decides the final nodemask from which
memory can be allocated in the task context irrespective any applicable
memory policy. CDM nodes should not be used for user allocations, its one
of the overall requirements of it's isolation. So they should not be part
of any task's mems_allowed nodemask. System RAM nodemask is used instead
of node_states[N_MEMORY] nodemask during mems_allowed initialization and
it's update during memory hotlugs.
Signed-off-by: NAnshuman Khandual <khandual@linux.vnet.ibm.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 225dda6b
...@@ -413,9 +413,11 @@ static void guarantee_online_cpus(struct cpuset *cs, struct cpumask *pmask) ...@@ -413,9 +413,11 @@ static void guarantee_online_cpus(struct cpuset *cs, struct cpumask *pmask)
*/ */
static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask) static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask)
{ {
while (!nodes_intersects(cs->effective_mems, node_states[N_MEMORY])) nodemask_t ram_nodes = system_mem_nodemask();
while (!nodes_intersects(cs->effective_mems, ram_nodes))
cs = parent_cs(cs); cs = parent_cs(cs);
nodes_and(*pmask, cs->effective_mems, node_states[N_MEMORY]); nodes_and(*pmask, cs->effective_mems, ram_nodes);
} }
/* /*
...@@ -3168,7 +3170,7 @@ static void cpuset_hotplug_workfn(struct work_struct *work) ...@@ -3168,7 +3170,7 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
/* fetch the available cpus/mems and find out which changed how */ /* fetch the available cpus/mems and find out which changed how */
cpumask_copy(&new_cpus, cpu_active_mask); cpumask_copy(&new_cpus, cpu_active_mask);
new_mems = node_states[N_MEMORY]; new_mems = system_mem_nodemask();
/* /*
* If subparts_cpus is populated, it is likely that the check below * If subparts_cpus is populated, it is likely that the check below
...@@ -3291,11 +3293,11 @@ static struct notifier_block cpuset_track_online_nodes_nb = { ...@@ -3291,11 +3293,11 @@ static struct notifier_block cpuset_track_online_nodes_nb = {
void __init cpuset_init_smp(void) void __init cpuset_init_smp(void)
{ {
cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask); cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask);
top_cpuset.mems_allowed = node_states[N_MEMORY]; top_cpuset.mems_allowed = system_mem_nodemask();
top_cpuset.old_mems_allowed = top_cpuset.mems_allowed; top_cpuset.old_mems_allowed = top_cpuset.mems_allowed;
cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask); cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
top_cpuset.effective_mems = node_states[N_MEMORY]; top_cpuset.effective_mems = system_mem_nodemask();
register_hotmemory_notifier(&cpuset_track_online_nodes_nb); register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册