drm/i915: track pid of GEM object creators
Subsystems (2)
PATCH 1/1 drm/i915: track pid of GEM object creators
This allows to hopefully find out who was responsible for the GPU death.
To simplify post-portem analysis, we also search for the the processes names when gathering the i915_error_state and when peeking at the list of active gem objects in debugfs.
--- drivers/gpu/drm/i915/i915_debugfs.c | 18 ++++++++++++++++++ drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/i915_gem_execbuffer.c | 3 +++ drivers/gpu/drm/i915/i915_irq.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +18 -0
@@ -151,6 +151,20 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) }if (obj->ring !=NULL )seq_printf (m," (%s)" , obj->ring->name); +if (obj->pid) { +struct pid *p; +struct task_struct *tsk =NULL ; + p =find_get_pid (obj->pid); +if (p) + tsk =get_pid_task (p,PIDTYPE_PID ); + +seq_printf (m," (pid: %5d [%s])" , + obj->pid, + (tsk) ? tsk->comm :"unknown" ); + +put_pid (p); + + } }static int i915_gem_object_list_info (struct seq_file *m,void *data)
@@ -730,6 +744,10 @@ static void print_error_buffers(struct seq_file *m,seq_printf (m," (name: %d)" , err->name);if (err->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , err->fence_reg); +if (err->pid) { +seq_printf (m," (pid: %d [%s])" , err->pid, + (err->comm) ? err->comm :"unknown" ); + }seq_printf (m,"\n" ); err++;
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -193,6 +193,8 @@ struct drm_i915_error_state { u32 purgeable:1; u32 ring:4; u32 cache_level:2; +u32 pid; +char comm[TASK_COMM_LEN ]; } *active_bo, *pinned_bo;u32 active_bo_count, pinned_bo_count;struct intel_overlay_error_state *overlay;
@@ -891,6 +893,9 @@ struct drm_i915_gem_object {/** for phy allocated objects */ struct drm_i915_gem_phys_object *phys_obj; +/** pid of caller process */ +uint32_t pid; +/** * Number of crtcs where this object is currently the fb, but * will be page flipped away on the next vblank. When it
drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 -0
@@ -1140,6 +1140,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,list_add_tail (&obj->exec_list, &objects); obj->exec_handle = exec[i].handle; obj->exec_entry = &exec[i]; + +/* Discover pid of caller process */ + obj->pid = file->pid;eb_add_object (eb, obj); }
drivers/gpu/drm/i915/i915_irq.c +14 -0
@@ -789,8 +789,22 @@ static u32 capture_bo_list(struct drm_i915_error_buffer *err,int i =0 ;list_for_each_entry (obj, head, mm_list) { +struct pid *p; +struct task_struct *tsk =NULL ; + err->size = obj->base.size; err->name = obj->base.name; + + err->pid = obj->pid; + p =find_get_pid (err->pid); +if (p) + tsk =get_pid_task (p,PIDTYPE_PID ); + +snprintf (err->comm,TASK_COMM_LEN , + (tsk) ? tsk->comm :"unknown" ); + +put_pid (p); + err->seqno = obj->last_rendering_seqno; err->gtt_offset = obj->gtt_offset; err->read_domains = obj->base.read_domains;
Signature · 1 line
1.7.8.1
Quoted 7 lines · Eugeni Dodonov
This allows to hopefully find out who was responsible for the GPU death.
To simplify post-portem analysis, we also search for the the processes names when gathering the
i915_error_stateand when peeking at the list of active gem objects in debugfs.Signed-off-by Eugeni Dodonov <[email protected]>
s/portem/mortem
I'd recommend adding some logic for flink'd buffers. Perhaps a list of processes is too tedious, but just knowing a buffer was exported, is a start.
How will this actually work? Since the error occurs asynchronously, surely another process could have come in and submitted work with that BO (in the semaphores case especially) at which point you'll overwrite obj->pid. Now probably you were aware of this, but I think this makes the feature almost unusable for trickier bugs, and in those cases at best it's misleading, and at worst it's harmful.
I once thought about this as well, and the only coherent way to do it is to track per seqno all this information. Maybe that's even worth doing with certain debug flags?
I guess I'd feel a lot better about this if you had actually used this feature to debug non-trivial bugs, and if you have - describe them and I'll offer up my r-b.
Quoted 1 line
[...]
Quoted 5 lines · Eugeni Dodonov
This allows to hopefully find out who was responsible for the GPU death.
To simplify post-portem analysis, we also search for the the processes names when gathering the
i915_error_stateand when peeking at the list of active gem objects in debugfs.
I think just recording pid at create as opposed to the last exec would be fine -- my DRI2 buffers are charged to the X Server, my 3D client buffers are always charged to it, and batchbuffers are always the client that execced it because they're not shared.
I've definitely wanted this in the debug info, and written a hack like this (but worse) before.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx