提交 00a465fb 编写于 作者: Z Zhou Guanghui 提交者: Zhang Zekun

mm: fix ignore cpuset enforcement

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I612UG
CVE: NA

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

Since the current condition ignores the cpuset enforcement by adding
__GFP_THISNODEi to the gfp_mask, this will result in allocations that
specify __GFP_THISNODE and non-cdm nodes not subject to cpuset
restrictions.

For example, procA pid 1000:
node 0 cpus: 0 1 2 3
node 0 free: 57199MB
node 1 cpus: 4 5 6 7
node 1 free: 55930MB

cpuset/test/cpuset.mems  1
cpuset/test/tasks        1000
cpuset/test/cpuset.cpus  0-3

No cdm node exists. When procA malloc 100MB memory, the result is:
node 0 cpus: 0 1 2 3
node 0 free: 57099MB
node 1 cpus: 4 5 6 7
node 1 free: 55930MB
This is not what we expected, and in fact 100 MB of memory should be
allocated from node1. The reason for this problem is that THP specifies
__GFP_THISNODE to attempt to allocate from the local node.

Therefore, the cpuset enforcement should be ignored only when explicitly
allocating memory from the cdm node using __GFP_ THISNODE.
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
上级 3442b8cf
......@@ -4946,7 +4946,8 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
ac->migratetype = gfp_migratetype(gfp_mask);
#ifdef CONFIG_COHERENT_DEVICE
if (cpusets_enabled() && !(*alloc_gfp & __GFP_THISNODE)) {
if (cpusets_enabled() &&
(!(*alloc_gfp & __GFP_THISNODE) || !is_cdm_node(preferred_nid))) {
#else
if (cpusets_enabled()) {
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册