Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Add process name to devcoredump
@ 2024-05-21 17:51 José Roberto de Souza
  2024-05-21 19:04 ` Nirmoy Das
  0 siblings, 1 reply; 2+ messages in thread
From: José Roberto de Souza @ 2024-05-21 17:51 UTC (permalink / raw)
  To: intel-xe; +Cc: Rodrigo Vivi, José Roberto de Souza

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

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 drivers/gpu/drm/xe/xe_devcoredump.c       | 8 ++++++++
 drivers/gpu/drm/xe/xe_devcoredump_types.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index 3d7980232be1c..69968d7feb8bc 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -110,6 +110,7 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
 	drm_printf(&p, "Snapshot time: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec);
 	ts = ktime_to_timespec64(ss->boot_time);
 	drm_printf(&p, "Uptime: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec);
+	drm_printf(&p, "Process: %s\n", ss->process_name);
 	xe_device_snapshot_print(xe, &p);
 
 	drm_printf(&p, "\n**** GuC CT ****\n");
@@ -166,12 +167,19 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
 	enum xe_hw_engine_id id;
 	u32 adj_logical_mask = q->logical_mask;
 	u32 width_mask = (0x1 << q->width) - 1;
+	struct task_struct *task;
 	int i;
 	bool cookie;
 
 	ss->snapshot_time = ktime_get_real();
 	ss->boot_time = ktime_get_boottime();
 
+	rcu_read_lock();
+	task = pid_task(q->vm->xef->drm->pid, PIDTYPE_PID);
+	if (task)
+		strscpy(ss->process_name, task->comm, sizeof(ss->process_name));
+	rcu_read_unlock();
+
 	ss->gt = q->gt;
 	INIT_WORK(&ss->work, xe_devcoredump_deferred_snap_work);
 
diff --git a/drivers/gpu/drm/xe/xe_devcoredump_types.h b/drivers/gpu/drm/xe/xe_devcoredump_types.h
index 6f654b63c7f1c..923cdf72a816a 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump_types.h
+++ b/drivers/gpu/drm/xe/xe_devcoredump_types.h
@@ -26,6 +26,8 @@ struct xe_devcoredump_snapshot {
 	ktime_t snapshot_time;
 	/** @boot_time:  Relative boot time so the uptime can be calculated. */
 	ktime_t boot_time;
+	/** @process_name: Name of process that triggered this gpu hang */
+	char process_name[TASK_COMM_LEN];
 
 	/** @gt: Affected GT, used by forcewake for delayed capture */
 	struct xe_gt *gt;
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/xe: Add process name to devcoredump
  2024-05-21 17:51 [PATCH] drm/xe: Add process name to devcoredump José Roberto de Souza
@ 2024-05-21 19:04 ` Nirmoy Das
  0 siblings, 0 replies; 2+ messages in thread
From: Nirmoy Das @ 2024-05-21 19:04 UTC (permalink / raw)
  To: José Roberto de Souza, intel-xe; +Cc: Rodrigo Vivi


On 5/21/2024 7:51 PM, José Roberto de Souza wrote:
> Process name help us track what application caused the gpug hang, this
> is crucial when running several applications at the same time.
>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_devcoredump.c       | 8 ++++++++
>   drivers/gpu/drm/xe/xe_devcoredump_types.h | 2 ++
>   2 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> index 3d7980232be1c..69968d7feb8bc 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> @@ -110,6 +110,7 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
>   	drm_printf(&p, "Snapshot time: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec);
>   	ts = ktime_to_timespec64(ss->boot_time);
>   	drm_printf(&p, "Uptime: %lld.%09ld\n", ts.tv_sec, ts.tv_nsec);
> +	drm_printf(&p, "Process: %s\n", ss->process_name);
>   	xe_device_snapshot_print(xe, &p);
>   
>   	drm_printf(&p, "\n**** GuC CT ****\n");
> @@ -166,12 +167,19 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
>   	enum xe_hw_engine_id id;
>   	u32 adj_logical_mask = q->logical_mask;
>   	u32 width_mask = (0x1 << q->width) - 1;
> +	struct task_struct *task;
>   	int i;
>   	bool cookie;
>   
>   	ss->snapshot_time = ktime_get_real();
>   	ss->boot_time = ktime_get_boottime();
>   
> +	rcu_read_lock();
> +	task = pid_task(q->vm->xef->drm->pid, PIDTYPE_PID);
> +	if (task)
> +		strscpy(ss->process_name, task->comm, sizeof(ss->process_name));
> +	rcu_read_unlock();

Use get_pid_task() instead. Otherwise

Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>

> +
>   	ss->gt = q->gt;
>   	INIT_WORK(&ss->work, xe_devcoredump_deferred_snap_work);
>   
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump_types.h b/drivers/gpu/drm/xe/xe_devcoredump_types.h
> index 6f654b63c7f1c..923cdf72a816a 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump_types.h
> +++ b/drivers/gpu/drm/xe/xe_devcoredump_types.h
> @@ -26,6 +26,8 @@ struct xe_devcoredump_snapshot {
>   	ktime_t snapshot_time;
>   	/** @boot_time:  Relative boot time so the uptime can be calculated. */
>   	ktime_t boot_time;
> +	/** @process_name: Name of process that triggered this gpu hang */
> +	char process_name[TASK_COMM_LEN];
>   
>   	/** @gt: Affected GT, used by forcewake for delayed capture */
>   	struct xe_gt *gt;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-21 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 17:51 [PATCH] drm/xe: Add process name to devcoredump José Roberto de Souza
2024-05-21 19:04 ` Nirmoy Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox