aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-03-19 09:45:45 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-20 10:09:21 -0400
commit6313c20490c8ae32ffb40f45c60734db53ca85ea (patch)
treeea1ef00091bbe6f11a676e62a745bb04603245da
parent2a5913a8670a6925c04e397e0a8ebd72cb4b2d26 (diff)
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: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ben Widawsky <benjamin.widawsky@intel.com> Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c49
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c1
3 files changed, 43 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index d1e0a360558f..2bba4c25c53e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -299,28 +299,57 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
299} while (0) 299} while (0)
300 300
301struct file_stats { 301struct file_stats {
302 struct drm_i915_file_private *file_priv;
302 int count; 303 int count;
303 size_t total, active, inactive, unbound; 304 size_t total, global, active, inactive, unbound;
304}; 305};
305 306
306static int per_file_stats(int id, void *ptr, void *data) 307static int per_file_stats(int id, void *ptr, void *data)
307{ 308{
308 struct drm_i915_gem_object *obj = ptr; 309 struct drm_i915_gem_object *obj = ptr;
309 struct file_stats *stats = data; 310 struct file_stats *stats = data;
311 struct i915_vma *vma;
310 312
311 stats->count++; 313 stats->count++;
312 stats->total += obj->base.size; 314 stats->total += obj->base.size;
313 315
314 if (i915_gem_obj_ggtt_bound(obj)) { 316 if (USES_FULL_PPGTT(obj->base.dev)) {
315 if (!list_empty(&obj->ring_list)) 317 list_for_each_entry(vma, &obj->vma_list, vma_link) {
316 stats->active += obj->base.size; 318 struct i915_hw_ppgtt *ppgtt;
317 else 319
318 stats->inactive += obj->base.size; 320 if (!drm_mm_node_allocated(&vma->node))
321 continue;
322
323 if (i915_is_ggtt(vma->vm)) {
324 stats->global += obj->base.size;
325 continue;
326 }
327
328 ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
329 if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
330 continue;
331
332 if (obj->ring) /* XXX per-vma statistic */
333 stats->active += obj->base.size;
334 else
335 stats->inactive += obj->base.size;
336
337 return 0;
338 }
319 } else { 339 } else {
320 if (!list_empty(&obj->global_list)) 340 if (i915_gem_obj_ggtt_bound(obj)) {
321 stats->unbound += obj->base.size; 341 stats->global += obj->base.size;
342 if (obj->ring)
343 stats->active += obj->base.size;
344 else
345 stats->inactive += obj->base.size;
346 return 0;
347 }
322 } 348 }
323 349
350 if (!list_empty(&obj->global_list))
351 stats->unbound += obj->base.size;
352
324 return 0; 353 return 0;
325} 354}
326 355
@@ -411,6 +440,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
411 struct task_struct *task; 440 struct task_struct *task;
412 441
413 memset(&stats, 0, sizeof(stats)); 442 memset(&stats, 0, sizeof(stats));
443 stats.file_priv = file->driver_priv;
414 idr_for_each(&file->object_idr, per_file_stats, &stats); 444 idr_for_each(&file->object_idr, per_file_stats, &stats);
415 /* 445 /*
416 * Although we have a valid reference on file->pid, that does 446 * 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 */ 450 */
421 rcu_read_lock(); 451 rcu_read_lock();
422 task = pid_task(file->pid, PIDTYPE_PID); 452 task = pid_task(file->pid, PIDTYPE_PID);
423 seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n", 453 seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu unbound)\n",
424 task ? task->comm : "<unknown>", 454 task ? task->comm : "<unknown>",
425 stats.count, 455 stats.count,
426 stats.total, 456 stats.total,
427 stats.active, 457 stats.active,
428 stats.inactive, 458 stats.inactive,
459 stats.global,
429 stats.unbound); 460 stats.unbound);
430 rcu_read_unlock(); 461 rcu_read_unlock();
431 } 462 }
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c5c57608460c..9b8c1e06a787 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -725,6 +725,8 @@ struct i915_hw_ppgtt {
725 dma_addr_t *gen8_pt_dma_addr[4]; 725 dma_addr_t *gen8_pt_dma_addr[4];
726 }; 726 };
727 727
728 struct i915_hw_context *ctx;
729
728 int (*enable)(struct i915_hw_ppgtt *ppgtt); 730 int (*enable)(struct i915_hw_ppgtt *ppgtt);
729 int (*switch_mm)(struct i915_hw_ppgtt *ppgtt, 731 int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
730 struct intel_ring_buffer *ring, 732 struct intel_ring_buffer *ring,
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index b5a58372eb06..6043062ffce7 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -215,6 +215,7 @@ create_vm_for_ctx(struct drm_device *dev, struct i915_hw_context *ctx)
215 return ERR_PTR(ret); 215 return ERR_PTR(ret);
216 } 216 }
217 217
218 ppgtt->ctx = ctx;
218 return ppgtt; 219 return ppgtt;
219} 220}
220 221