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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: add shared fdinfo stats

Add shared stats. Useful for seeing shared memory.

v2: take dma-buf into account as well
v3: use the new gem helper

Link: https://lore.kernel.org/all/20231207180225.439482-1-alexander.deucher@amd.com/
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: Christian König <christian.keonig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>

authored by

Alex Deucher and committed by
Christian König
ba1a58d5 d50ea100

+21
+4
drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
··· 97 97 stats.requested_visible_vram/1024UL); 98 98 drm_printf(p, "amd-requested-gtt:\t%llu KiB\n", 99 99 stats.requested_gtt/1024UL); 100 + drm_printf(p, "drm-shared-vram:\t%llu KiB\n", stats.vram_shared/1024UL); 101 + drm_printf(p, "drm-shared-gtt:\t%llu KiB\n", stats.gtt_shared/1024UL); 102 + drm_printf(p, "drm-shared-cpu:\t%llu KiB\n", stats.cpu_shared/1024UL); 103 + 100 104 for (hw_ip = 0; hw_ip < AMDGPU_HW_IP_NUM; ++hw_ip) { 101 105 if (!usage[hw_ip]) 102 106 continue;
+11
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 1273 1273 struct amdgpu_mem_stats *stats) 1274 1274 { 1275 1275 uint64_t size = amdgpu_bo_size(bo); 1276 + struct drm_gem_object *obj; 1276 1277 unsigned int domain; 1278 + bool shared; 1277 1279 1278 1280 /* Abort if the BO doesn't currently have a backing store */ 1279 1281 if (!bo->tbo.resource) 1280 1282 return; 1283 + 1284 + obj = &bo->tbo.base; 1285 + shared = drm_gem_object_is_shared_for_memory_stats(obj); 1281 1286 1282 1287 domain = amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type); 1283 1288 switch (domain) { ··· 1290 1285 stats->vram += size; 1291 1286 if (amdgpu_bo_in_cpu_visible_vram(bo)) 1292 1287 stats->visible_vram += size; 1288 + if (shared) 1289 + stats->vram_shared += size; 1293 1290 break; 1294 1291 case AMDGPU_GEM_DOMAIN_GTT: 1295 1292 stats->gtt += size; 1293 + if (shared) 1294 + stats->gtt_shared += size; 1296 1295 break; 1297 1296 case AMDGPU_GEM_DOMAIN_CPU: 1298 1297 default: 1299 1298 stats->cpu += size; 1299 + if (shared) 1300 + stats->cpu_shared += size; 1300 1301 break; 1301 1302 } 1302 1303
+6
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 138 138 struct amdgpu_mem_stats { 139 139 /* current VRAM usage, includes visible VRAM */ 140 140 uint64_t vram; 141 + /* current shared VRAM usage, includes visible VRAM */ 142 + uint64_t vram_shared; 141 143 /* current visible VRAM usage */ 142 144 uint64_t visible_vram; 143 145 /* current GTT usage */ 144 146 uint64_t gtt; 147 + /* current shared GTT usage */ 148 + uint64_t gtt_shared; 145 149 /* current system memory usage */ 146 150 uint64_t cpu; 151 + /* current shared system memory usage */ 152 + uint64_t cpu_shared; 147 153 /* sum of evicted buffers, includes visible VRAM */ 148 154 uint64_t evicted_vram; 149 155 /* sum of evicted buffers due to CPU access */