Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Add process name to devcoredump

Process name help us track what application caused the gpug hang, this
is crucial when running several applications at the same time.

v2:
- handle Xe KMD exec_queues without VM

v3:
- use get_pid_task() (suggested by Nirmoy)

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Nirmoy Das <nirmoy.das@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240522201203.145403-1-jose.souza@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

José Roberto de Souza and committed by
Rodrigo Vivi
b10d0c5e e8ac8048

+15
+13
drivers/gpu/drm/xe/xe_devcoredump.c
··· 110 110 drm_printf(&p, "Snapshot time: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec); 111 111 ts = ktime_to_timespec64(ss->boot_time); 112 112 drm_printf(&p, "Uptime: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec); 113 + drm_printf(&p, "Process: %s\n", ss->process_name); 113 114 xe_device_snapshot_print(xe, &p); 114 115 115 116 drm_printf(&p, "\n**** GuC CT ****\n"); ··· 167 166 enum xe_hw_engine_id id; 168 167 u32 adj_logical_mask = q->logical_mask; 169 168 u32 width_mask = (0x1 << q->width) - 1; 169 + const char *process_name = "no process"; 170 + struct task_struct *task = NULL; 171 + 170 172 int i; 171 173 bool cookie; 172 174 173 175 ss->snapshot_time = ktime_get_real(); 174 176 ss->boot_time = ktime_get_boottime(); 177 + 178 + if (q->vm) { 179 + task = get_pid_task(q->vm->xef->drm->pid, PIDTYPE_PID); 180 + if (task) 181 + process_name = task->comm; 182 + } 183 + snprintf(ss->process_name, sizeof(ss->process_name), process_name); 184 + if (task) 185 + put_task_struct(task); 175 186 176 187 ss->gt = q->gt; 177 188 INIT_WORK(&ss->work, xe_devcoredump_deferred_snap_work);
+2
drivers/gpu/drm/xe/xe_devcoredump_types.h
··· 26 26 ktime_t snapshot_time; 27 27 /** @boot_time: Relative boot time so the uptime can be calculated. */ 28 28 ktime_t boot_time; 29 + /** @process_name: Name of process that triggered this gpu hang */ 30 + char process_name[TASK_COMM_LEN]; 29 31 30 32 /** @gt: Affected GT, used by forcewake for delayed capture */ 31 33 struct xe_gt *gt;