[PATCH 1/1] amdkfd: Memory availability can never be negative
Felix Kuehling
felix.kuehling at amd.com
Thu Mar 2 21:41:20 UTC 2023
Am 2023-03-01 um 20:09 schrieb Daniel Phillips:
> 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 <daniel.phillips at amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 6f236ded5f12..ec74f0ad62a9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -1574,7 +1574,7 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev)
> {
> uint64_t reserved_for_pt =
> ESTIMATE_PT_SIZE(amdgpu_amdkfd_total_mem_size);
> - size_t available;
> + ssize_t available;
>
> spin_lock(&kfd_mem_limit.mem_limit_lock);
> available = adev->gmc.real_vram_size
> @@ -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 (available < 0)
> + available = 0;
> +
> return ALIGN_DOWN(available, VRAM_AVAILABLITY_ALIGN);
> }
>
More information about the amd-gfx
mailing list