Skip to content

Commit

Permalink
drm/amdgpu: Use free system memory size for kfd memory accounting
Browse files Browse the repository at this point in the history
With the current kfd memory accounting scheme, kfd applications
can use up to 15/16 of total system memory. For system which
has small total system memory size it leaves small system memory
for OS. For example, if the system has totally 16GB of system
memory, this scheme leave OS and non-kfd applications only 1GB
of system memory. In many cases, this leads to OOM killer.

This patch changed the KFD system memory accounting scheme.
15/16 of free system memory when kfd driver load. This deduct
the system memory that OS already use.

Signed-off-by: Oak Zeng <[email protected]>
Suggested-by: Philip Yang <[email protected]>
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
oakzeng authored and alexdeucher committed Mar 24, 2021
1 parent b335f28 commit df23d1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int amdgpu_amdkfd_init(void)
int ret;

si_meminfo(&si);
amdgpu_amdkfd_total_mem_size = si.totalram - si.totalhigh;
amdgpu_amdkfd_total_mem_size = si.freeram - si.freehigh;
amdgpu_amdkfd_total_mem_size *= si.mem_unit;

ret = kgd2kfd_init();
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void amdgpu_amdkfd_gpuvm_init_mem_limits(void)
uint64_t mem;

si_meminfo(&si);
mem = si.totalram - si.totalhigh;
mem = si.freeram - si.freehigh;
mem *= si.mem_unit;

spin_lock_init(&kfd_mem_limit.mem_limit_lock);
Expand Down

0 comments on commit df23d1b

Please sign in to comment.