提交 6fa39bc1 编写于 作者: M Michel Dänzer 提交者: Alex Deucher

drm/amdgpu: Use kvmalloc_array for allocating VRAM manager nodes array

It can be quite big, and there's no need for it to be physically
contiguous. This is less likely to fail under memory pressure (has
actually happened while running piglit).

Cc: stable@vger.kernel.org
Signed-off-by: NMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: NChristian König <christian.koenig@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 91c822c3
...@@ -135,7 +135,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, ...@@ -135,7 +135,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node); num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node);
} }
nodes = kcalloc(num_nodes, sizeof(*nodes), GFP_KERNEL); nodes = kvmalloc_array(num_nodes, sizeof(*nodes),
GFP_KERNEL | __GFP_ZERO);
if (!nodes) if (!nodes)
return -ENOMEM; return -ENOMEM;
...@@ -190,7 +191,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, ...@@ -190,7 +191,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
drm_mm_remove_node(&nodes[i]); drm_mm_remove_node(&nodes[i]);
spin_unlock(&mgr->lock); spin_unlock(&mgr->lock);
kfree(nodes); kvfree(nodes);
return r == -ENOSPC ? 0 : r; return r == -ENOSPC ? 0 : r;
} }
...@@ -229,7 +230,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, ...@@ -229,7 +230,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
atomic64_sub(usage, &mgr->usage); atomic64_sub(usage, &mgr->usage);
atomic64_sub(vis_usage, &mgr->vis_usage); atomic64_sub(vis_usage, &mgr->vis_usage);
kfree(mem->mm_node); kvfree(mem->mm_node);
mem->mm_node = NULL; mem->mm_node = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册