mirror of https://gitee.com/openkylin/linux.git
drm/i915: Track clients and print their object usage in debugfs
By stashing a pointer of who opened the device and keeping a list of open fd, we can then walk each client and inspect how many objects they have open. For example, i915_gem_objects: 1102 objects, 613646336 bytes 663 [662] objects, 468783104 [468750336] bytes in gtt 37 [37] active objects, 46874624 [46874624] bytes 626 [625] inactive objects, 421908480 [421875712] bytes 282 unbound objects, 6512640 bytes 85 purgeable objects, 6787072 bytes 28 pinned mappable objects, 3686400 bytes 40 fault mappable objects, 27783168 bytes 2145386496 [536870912] gtt total Xorg: 43 objects, 32243712 bytes (10223616 active, 16683008 inactive, 4096 unbound) gnome-shell: 30 objects, 28381184 bytes (0 active, 28336128 inactive, 0 unbound) xonotic-linux64: 1032 objects, 569933824 bytes (46874624 active, 383545344 inactive, 6508544 unbound) v2: Use existing drm->filelist as pointed out by Ben. v3: Not even stashing the task_struct is required as Ben pointed out drm_file->pid. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
ef1b460d1b
commit
2db8e9d6b2
|
@ -196,6 +196,32 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
struct file_stats {
|
||||||
|
int count;
|
||||||
|
size_t total, active, inactive, unbound;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int per_file_stats(int id, void *ptr, void *data)
|
||||||
|
{
|
||||||
|
struct drm_i915_gem_object *obj = ptr;
|
||||||
|
struct file_stats *stats = data;
|
||||||
|
|
||||||
|
stats->count++;
|
||||||
|
stats->total += obj->base.size;
|
||||||
|
|
||||||
|
if (obj->gtt_space) {
|
||||||
|
if (!list_empty(&obj->ring_list))
|
||||||
|
stats->active += obj->base.size;
|
||||||
|
else
|
||||||
|
stats->inactive += obj->base.size;
|
||||||
|
} else {
|
||||||
|
if (!list_empty(&obj->global_list))
|
||||||
|
stats->unbound += obj->base.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int i915_gem_object_info(struct seq_file *m, void* data)
|
static int i915_gem_object_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;
|
||||||
|
@ -204,6 +230,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
|
||||||
u32 count, mappable_count, purgeable_count;
|
u32 count, mappable_count, purgeable_count;
|
||||||
size_t size, mappable_size, purgeable_size;
|
size_t size, mappable_size, purgeable_size;
|
||||||
struct drm_i915_gem_object *obj;
|
struct drm_i915_gem_object *obj;
|
||||||
|
struct drm_file *file;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = mutex_lock_interruptible(&dev->struct_mutex);
|
ret = mutex_lock_interruptible(&dev->struct_mutex);
|
||||||
|
@ -263,6 +290,21 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
|
||||||
dev_priv->gtt.total,
|
dev_priv->gtt.total,
|
||||||
dev_priv->gtt.mappable_end - dev_priv->gtt.start);
|
dev_priv->gtt.mappable_end - dev_priv->gtt.start);
|
||||||
|
|
||||||
|
seq_printf(m, "\n");
|
||||||
|
list_for_each_entry_reverse(file, &dev->filelist, lhead) {
|
||||||
|
struct file_stats stats;
|
||||||
|
|
||||||
|
memset(&stats, 0, sizeof(stats));
|
||||||
|
idr_for_each(&file->object_idr, per_file_stats, &stats);
|
||||||
|
seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
|
||||||
|
get_pid_task(file->pid, PIDTYPE_PID)->comm,
|
||||||
|
stats.count,
|
||||||
|
stats.total,
|
||||||
|
stats.active,
|
||||||
|
stats.inactive,
|
||||||
|
stats.unbound);
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue