[PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump

From: Matt Turner

Date: Wed Dec 02 2026 - 17:37:00 EST


The process and thread in the devcoredump header come from the VM's
task info, which amdgpu_vm_set_task_info() updates on every submission
to record the thread that last submitted to the VM. In a multithreaded
process that is not necessarily the thread that submitted the job that
hung.

Record the submitting thread and its process in the job at CS time, as
amdgpu_vm_set_task_info() does for the VM, and print them in the
coredump header in the same layout as the VM's task info.

Suggested-by: Gregoire Pean <gpean@xxxxxxxxxxx>
Signed-off-by: Matt Turner <mattst88@xxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 +++++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 4 ++++
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 6 ++++++
4 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 71e2b83faa12..858a723ed667 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -311,6 +311,11 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
GFP_KERNEL, &p->jobs[i]);
if (ret)
goto free_all_kdata;
+ p->jobs[i]->submit_tgid = current->tgid;
+ p->jobs[i]->submit_pid = current->pid;
+ get_task_comm(p->jobs[i]->submit_process_name,
+ current->group_leader);
+ get_task_comm(p->jobs[i]->submit_comm, current);
switch (p->adev->enforce_isolation[fpriv->xcp_id]) {
case AMDGPU_ENFORCE_ISOLATION_DISABLE:
default:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 033e1b94fcd7..62a0ae0aff87 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -604,6 +604,16 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
coredump->reset_task_info.task.comm,
coredump->reset_task_info.task.pid);

+ /*
+ * The VM's task info above is the last thread that submitted to the
+ * VM; this is the thread that submitted the hung job.
+ */
+ if (coredump->submit_pid)
+ drm_printf(&p,
+ "submitter process_name: %s TGID: %d thread: %s PID: %d\n",
+ coredump->submit_process_name, coredump->submit_tgid,
+ coredump->submit_comm, coredump->submit_pid);
+
/* SOC Information */
drm_printf(&p, "\nSOC Information\n");
drm_printf(&p, "SOC Device id: %d\n", coredump->adev->pdev->device);
@@ -877,6 +887,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
}
coredump->pasid = job->pasid;
coredump->vmid = job->vmid;
+ coredump->submit_tgid = job->submit_tgid;
+ coredump->submit_pid = job->submit_pid;
+ memcpy(coredump->submit_process_name, job->submit_process_name,
+ sizeof(coredump->submit_process_name));
+ memcpy(coredump->submit_comm, job->submit_comm,
+ sizeof(coredump->submit_comm));
coredump->num_ibs = job->num_ibs;
for (i = 0; i < job->num_ibs; ++i) {
struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index d62031369e56..c0192d0c583a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -81,6 +81,10 @@ struct amdgpu_coredump_info {

unsigned int pasid;
unsigned int vmid;
+ pid_t submit_tgid;
+ pid_t submit_pid;
+ char submit_process_name[TASK_COMM_LEN];
+ char submit_comm[TASK_COMM_LEN];
int num_ibs;
struct amdgpu_coredump_ib_info ibs[] __counted_by(num_ibs);
};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
index 18e788f0e790..0a6263781387 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
@@ -100,6 +100,12 @@ struct amdgpu_job {
bool enforce_isolation;
bool run_cleaner_shader;

+ /* thread that submitted the job, for the devcoredump */
+ pid_t submit_tgid;
+ pid_t submit_pid;
+ char submit_process_name[TASK_COMM_LEN];
+ char submit_comm[TASK_COMM_LEN];
+
uint32_t num_ibs;
struct amdgpu_ib ibs[];
};

--
2.56.1