Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add debugfs for kfd system and ttm mem used

This keeps track of kfd system mem used and kfd ttm mem used.

Signed-off-by: Alex Sierra <alex.sierra@amd.com>
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Alex Sierra and committed by
Alex Deucher
3d2af401 f9af3c16

+24
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
··· 172 172 struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context, 173 173 struct mm_struct *mm, 174 174 struct svm_range_bo *svm_bo); 175 + #if defined(CONFIG_DEBUG_FS) 176 + int kfd_debugfs_kfd_mem_limits(struct seq_file *m, void *data); 177 + #endif 175 178 #if IS_ENABLED(CONFIG_HSA_AMD) 176 179 bool amdkfd_fence_check_mm(struct dma_fence *f, struct mm_struct *mm); 177 180 struct amdgpu_amdkfd_fence *to_amdgpu_amdkfd_fence(struct dma_fence *f);
+19
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 2888 2888 } 2889 2889 return false; 2890 2890 } 2891 + 2892 + #if defined(CONFIG_DEBUG_FS) 2893 + 2894 + int kfd_debugfs_kfd_mem_limits(struct seq_file *m, void *data) 2895 + { 2896 + 2897 + spin_lock(&kfd_mem_limit.mem_limit_lock); 2898 + seq_printf(m, "System mem used %lldM out of %lluM\n", 2899 + (kfd_mem_limit.system_mem_used >> 20), 2900 + (kfd_mem_limit.max_system_mem_limit >> 20)); 2901 + seq_printf(m, "TTM mem used %lldM out of %lluM\n", 2902 + (kfd_mem_limit.ttm_mem_used >> 20), 2903 + (kfd_mem_limit.max_ttm_mem_limit >> 20)); 2904 + spin_unlock(&kfd_mem_limit.mem_limit_lock); 2905 + 2906 + return 0; 2907 + } 2908 + 2909 + #endif
+2
drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
··· 101 101 kfd_debugfs_rls_by_device, &kfd_debugfs_fops); 102 102 debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root, 103 103 kfd_debugfs_hang_hws_read, &kfd_debugfs_hang_hws_fops); 104 + debugfs_create_file("mem_limit", S_IFREG | 0200, debugfs_root, 105 + kfd_debugfs_kfd_mem_limits, &kfd_debugfs_fops); 104 106 } 105 107 106 108 void kfd_debugfs_fini(void)