Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amdgpu: free_memory calculation can result in negative free memory #333

Open
kkartaltepe opened this issue Nov 24, 2024 · 1 comment
Open

Comments

@kkartaltepe
Copy link

kkartaltepe commented Nov 24, 2024

From

// TODO: Determine if we want to include GTT (GPU accessible system memory)
SET_GPUINFO_DYNAMIC(dynamic_info, total_memory, memory_info.vram.total_heap_size);
SET_GPUINFO_DYNAMIC(dynamic_info, used_memory, memory_info.vram.heap_usage);
SET_GPUINFO_DYNAMIC(dynamic_info, free_memory, memory_info.vram.usable_heap_size - dynamic_info->used_memory);
SET_GPUINFO_DYNAMIC(dynamic_info, mem_util_rate,
(dynamic_info->total_memory - dynamic_info->free_memory) * 100 / dynamic_info->total_memory);

Dumping the values on my machine gives

Gpu: AMD Radeon 780M
Gpu clock: 800Mhz
Mem clock: 2800Mhz
Gpu util: 18%
Mem util: 112%
Mem total: 603979776 B
Mem used: 522059776 B
Mem free: -76898304 B

Perhaps this is an amdgpu issue though as I would expect the memory_info.vram.usable_heap_size > memory_info.vram.heap_usage, but this doesnt seem to be the case. Though im not sure this is exposed in the UI anywhere so maybe its not a big deal.

@kkartaltepe
Copy link
Author

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c#L752-L757 appears to be the source of the calculation, i think the pin memory here is getting double counted when free space is calculated this way. So it is most appropriate to just do total_heap_size - heap_usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant