amdkfd: Memory availability can never be negative
Subsystems (3)
PATCH 1/1 amdkfd: Memory availability can never be negative
Our assumptions about how much KFD memory is currently available for allocation may be violated by various complexities so we define the reported value as advisory, however we should never report negative availability.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -0
@@ -1583,6 +1583,9 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev) - reserved_for_pt;spin_unlock (&kfd_mem_limit.mem_limit_lock); +if ((int64_t )available <0 ) + available =0 ; +return ALIGN_DOWN (available,VRAM_AVAILABLITY_ALIGN ); }
Signature · 1 line
2.39.0
Felix Kuehling
maintainerAm 2023-03-01 um 18:46 schrieb Daniel Phillips:
Quoted 15 lines
Our assumptions about how much KFD memory is currently available for allocation may be violated by various complexities so we define the reported value as advisory, however we should never report negative availability.
Signed-off-by Daniel Phillips <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev) · line 1587
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2
-0@@ -1583,6 +1583,9 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev) - reserved_for_pt;spin_unlock (&kfd_mem_limit.mem_limit_lock); +if ((int64_t )available <0 ) + available =0 ;
Instead of casting avaliable to a signed type here, you could define it with a signed type in the first place. ssize_t would be appropriate.
Regards,
Felix
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-0+return ALIGN_DOWN (available,VRAM_AVAILABLITY_ALIGN ); }