Commit 6313c204 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Per-process stats work better when evaluated per-process

The idea of printing objects used by each process is to judge how each
process is using them. This means that we need to evaluate whether the
object is bound for that particular process, rather than just whether it
is bound into the global GTT.

v2: Restore the non-full-ppgtt path for simplicity as we may not even
    create vma with older hardware.

v3: Tweak handling of global entries and default context entries.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Ben Widawsky <benjamin.widawsky@intel.com>
Reviewed-by: default avatarBen Widawsky <ben@bwidawsk.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 2a5913a8
...@@ -299,28 +299,57 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data) ...@@ -299,28 +299,57 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
} while (0) } while (0)
struct file_stats { struct file_stats {
struct drm_i915_file_private *file_priv;
int count; int count;
size_t total, active, inactive, unbound; size_t total, global, active, inactive, unbound;
}; };
static int per_file_stats(int id, void *ptr, void *data) static int per_file_stats(int id, void *ptr, void *data)
{ {
struct drm_i915_gem_object *obj = ptr; struct drm_i915_gem_object *obj = ptr;
struct file_stats *stats = data; struct file_stats *stats = data;
struct i915_vma *vma;
stats->count++; stats->count++;
stats->total += obj->base.size; stats->total += obj->base.size;
if (i915_gem_obj_ggtt_bound(obj)) { if (USES_FULL_PPGTT(obj->base.dev)) {
if (!list_empty(&obj->ring_list)) list_for_each_entry(vma, &obj->vma_list, vma_link) {
stats->active += obj->base.size; struct i915_hw_ppgtt *ppgtt;
else
stats->inactive += obj->base.size; if (!drm_mm_node_allocated(&vma->node))
continue;
if (i915_is_ggtt(vma->vm)) {
stats->global += obj->base.size;
continue;
}
ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
continue;
if (obj->ring) /* XXX per-vma statistic */
stats->active += obj->base.size;
else
stats->inactive += obj->base.size;
return 0;
}
} else { } else {
if (!list_empty(&obj->global_list)) if (i915_gem_obj_ggtt_bound(obj)) {
stats->unbound += obj->base.size; stats->global += obj->base.size;
if (obj->ring)
stats->active += obj->base.size;
else
stats->inactive += obj->base.size;
return 0;
}
} }
if (!list_empty(&obj->global_list))
stats->unbound += obj->base.size;
return 0; return 0;
} }
...@@ -411,6 +440,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) ...@@ -411,6 +440,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
struct task_struct *task; struct task_struct *task;
memset(&stats, 0, sizeof(stats)); memset(&stats, 0, sizeof(stats));
stats.file_priv = file->driver_priv;
idr_for_each(&file->object_idr, per_file_stats, &stats); idr_for_each(&file->object_idr, per_file_stats, &stats);
/* /*
* Although we have a valid reference on file->pid, that does * Although we have a valid reference on file->pid, that does
...@@ -420,12 +450,13 @@ static int i915_gem_object_info(struct seq_file *m, void* data) ...@@ -420,12 +450,13 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
*/ */
rcu_read_lock(); rcu_read_lock();
task = pid_task(file->pid, PIDTYPE_PID); task = pid_task(file->pid, PIDTYPE_PID);
seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n", seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu unbound)\n",
task ? task->comm : "<unknown>", task ? task->comm : "<unknown>",
stats.count, stats.count,
stats.total, stats.total,
stats.active, stats.active,
stats.inactive, stats.inactive,
stats.global,
stats.unbound); stats.unbound);
rcu_read_unlock(); rcu_read_unlock();
} }
......
...@@ -725,6 +725,8 @@ struct i915_hw_ppgtt { ...@@ -725,6 +725,8 @@ struct i915_hw_ppgtt {
dma_addr_t *gen8_pt_dma_addr[4]; dma_addr_t *gen8_pt_dma_addr[4];
}; };
struct i915_hw_context *ctx;
int (*enable)(struct i915_hw_ppgtt *ppgtt); int (*enable)(struct i915_hw_ppgtt *ppgtt);
int (*switch_mm)(struct i915_hw_ppgtt *ppgtt, int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
struct intel_ring_buffer *ring, struct intel_ring_buffer *ring,
......
...@@ -215,6 +215,7 @@ create_vm_for_ctx(struct drm_device *dev, struct i915_hw_context *ctx) ...@@ -215,6 +215,7 @@ create_vm_for_ctx(struct drm_device *dev, struct i915_hw_context *ctx)
return ERR_PTR(ret); return ERR_PTR(ret);
} }
ppgtt->ctx = ctx;
return ppgtt; return ppgtt;
} }
......
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