Commit 7ea23565 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: rework GEM info printing

Print BOs grouped per client.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent ebb36d19
...@@ -531,7 +531,6 @@ struct amdgpu_bo { ...@@ -531,7 +531,6 @@ struct amdgpu_bo {
struct amdgpu_bo *parent; struct amdgpu_bo *parent;
struct ttm_bo_kmap_obj dma_buf_vmap; struct ttm_bo_kmap_obj dma_buf_vmap;
pid_t pid;
struct amdgpu_mn *mn; struct amdgpu_mn *mn;
struct list_head mn_list; struct list_head mn_list;
}; };
......
...@@ -83,7 +83,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, ...@@ -83,7 +83,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
return r; return r;
} }
*obj = &robj->gem_base; *obj = &robj->gem_base;
robj->pid = task_pid_nr(current);
mutex_lock(&adev->gem.mutex); mutex_lock(&adev->gem.mutex);
list_add_tail(&robj->list, &adev->gem.objects); list_add_tail(&robj->list, &adev->gem.objects);
...@@ -694,44 +693,73 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, ...@@ -694,44 +693,73 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
} }
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
static int amdgpu_debugfs_gem_bo_info(int id, void *ptr, void *data)
{
struct drm_gem_object *gobj = ptr;
struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj);
struct seq_file *m = data;
unsigned domain;
const char *placement;
unsigned pin_count;
domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
switch (domain) {
case AMDGPU_GEM_DOMAIN_VRAM:
placement = "VRAM";
break;
case AMDGPU_GEM_DOMAIN_GTT:
placement = " GTT";
break;
case AMDGPU_GEM_DOMAIN_CPU:
default:
placement = " CPU";
break;
}
seq_printf(m, "\t0x%08x: %12ld byte %s @ 0x%010Lx",
id, amdgpu_bo_size(bo), placement,
amdgpu_bo_gpu_offset(bo));
pin_count = ACCESS_ONCE(bo->pin_count);
if (pin_count)
seq_printf(m, " pin count %d", pin_count);
seq_printf(m, "\n");
return 0;
}
static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
{ {
struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_info_node *node = (struct drm_info_node *)m->private;
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
struct amdgpu_device *adev = dev->dev_private; struct drm_file *file;
struct amdgpu_bo *rbo; int r;
unsigned i = 0;
mutex_lock(&adev->gem.mutex); r = mutex_lock_interruptible(&dev->struct_mutex);
list_for_each_entry(rbo, &adev->gem.objects, list) { if (r)
unsigned pin_count; return r;
unsigned domain;
const char *placement; list_for_each_entry(file, &dev->filelist, lhead) {
struct task_struct *task;
domain = amdgpu_mem_type_to_domain(rbo->tbo.mem.mem_type);
switch (domain) { /*
case AMDGPU_GEM_DOMAIN_VRAM: * Although we have a valid reference on file->pid, that does
placement = "VRAM"; * not guarantee that the task_struct who called get_pid() is
break; * still alive (e.g. get_pid(current) => fork() => exit()).
case AMDGPU_GEM_DOMAIN_GTT: * Therefore, we need to protect this ->comm access using RCU.
placement = " GTT"; */
break; rcu_read_lock();
case AMDGPU_GEM_DOMAIN_CPU: task = pid_task(file->pid, PIDTYPE_PID);
default: seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid),
placement = " CPU"; task ? task->comm : "<unknown>");
break; rcu_read_unlock();
}
seq_printf(m, "bo[0x%08x] %12ld %s @ 0x%010Lx pid %8d", spin_lock(&file->table_lock);
i, amdgpu_bo_size(rbo), placement, idr_for_each(&file->object_idr, amdgpu_debugfs_gem_bo_info, m);
amdgpu_bo_gpu_offset(rbo), rbo->pid); spin_unlock(&file->table_lock);
pin_count = ACCESS_ONCE(rbo->pin_count);
if (pin_count)
seq_printf(m, " pin count %d", pin_count);
seq_printf(m, "\n");
i++;
} }
mutex_unlock(&adev->gem.mutex);
mutex_unlock(&dev->struct_mutex);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment