Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Junjia" <junjia.chen@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.brost@intel.com, thomas.hellstrom@linux.intel.com,
	rodrigo.vivi@intel.com, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, "Chen,
	Junjia" <junjia.chen@intel.com>,
	Chen@freedesktop.org
Subject: [PATCH] drm/xe: Add creator TID to sched job trace points
Date: Mon, 29 Jun 2026 14:15:27 +0800	[thread overview]
Message-ID: <20260629061527.146714-1-junjia.chen@intel.com> (raw)

Capture the creating task pid when a scheduler job is allocated
and emit it in the sched job trace events alongside the
exec queue pointer.

This makes it easier to correlate queue activity back to
the userspace thread that submitted the work.

Signed-off-by: Chen, Junjia <junjia.chen@intel.com>
---
 drivers/gpu/drm/xe/xe_sched_job.c       |  2 ++
 drivers/gpu/drm/xe/xe_sched_job_types.h |  3 +++
 drivers/gpu/drm/xe/xe_trace.h           | 12 +++++++++---
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_sched_job.c b/drivers/gpu/drm/xe/xe_sched_job.c
index b64e6a434807..1356755cd180 100644
--- a/drivers/gpu/drm/xe/xe_sched_job.c
+++ b/drivers/gpu/drm/xe/xe_sched_job.c
@@ -7,6 +7,7 @@
 
 #include <uapi/drm/xe_drm.h>
 #include <linux/dma-fence-chain.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 
 #include "xe_device.h"
@@ -111,6 +112,7 @@ struct xe_sched_job *xe_sched_job_create(struct xe_exec_queue *q,
 
 	job->q = q;
 	job->sample_timestamp = U64_MAX;
+	job->creator_tid = task_pid_nr(current);
 	kref_init(&job->refcount);
 	xe_exec_queue_get(job->q);
 
diff --git a/drivers/gpu/drm/xe/xe_sched_job_types.h b/drivers/gpu/drm/xe/xe_sched_job_types.h
index 0490b1247a6e..f2ad94105b37 100644
--- a/drivers/gpu/drm/xe/xe_sched_job_types.h
+++ b/drivers/gpu/drm/xe/xe_sched_job_types.h
@@ -7,6 +7,7 @@
 #define _XE_SCHED_JOB_TYPES_H_
 
 #include <linux/kref.h>
+#include <linux/types.h>
 
 #include <drm/gpu_scheduler.h>
 
@@ -59,6 +60,8 @@ struct xe_sched_job {
 	u32 lrc_seqno;
 	/** @migrate_flush_flags: Additional flush flags for migration jobs */
 	u32 migrate_flush_flags;
+	/** @creator_tid: task pid that created this job */
+	pid_t creator_tid;
 	/** @sample_timestamp: Sampling of job timestamp in TDR */
 	u64 sample_timestamp;
 	/** @ring_ops_flush_tlb: The ring ops need to flush TLB before payload. */
diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
index dfd87f03c4fd..a3115d6e4c6a 100644
--- a/drivers/gpu/drm/xe/xe_trace.h
+++ b/drivers/gpu/drm/xe/xe_trace.h
@@ -258,8 +258,10 @@ DECLARE_EVENT_CLASS(xe_sched_job,
 
 		    TP_STRUCT__entry(
 			     __string(dev, __dev_name_eq(job->q))
+			     __field(struct xe_exec_queue *, q)
 			     __field(u32, seqno)
 			     __field(u32, lrc_seqno)
+			     __field(pid_t, creator_tid)
 			     __field(u8, gt_id)
 			     __field(u16, guc_id)
 			     __field(u32, guc_state)
@@ -271,8 +273,10 @@ DECLARE_EVENT_CLASS(xe_sched_job,
 
 		    TP_fast_assign(
 			   __assign_str(dev);
+			   __entry->q = job->q;
 			   __entry->seqno = xe_sched_job_seqno(job);
 			   __entry->lrc_seqno = xe_sched_job_lrc_seqno(job);
+			   __entry->creator_tid = job->creator_tid;
 			   __entry->gt_id = job->q->gt->info.id;
 			   __entry->guc_id = job->q->guc->id;
 			   __entry->guc_state =
@@ -283,9 +287,11 @@ DECLARE_EVENT_CLASS(xe_sched_job,
 			   __entry->batch_addr = (u64)job->ptrs[0].batch_addr;
 			   ),
 
-		    TP_printk("dev=%s, fence=%p, seqno=%u, lrc_seqno=%u, gt=%u, guc_id=%d, batch_addr=0x%012llx, guc_state=0x%x, flags=0x%x, error=%d",
-			      __get_str(dev), __entry->fence, __entry->seqno,
-			      __entry->lrc_seqno, __entry->gt_id, __entry->guc_id,
+		    TP_printk("dev=%s, q=%p, fence=%p, seqno=%u, lrc_seqno=%u, creator_tid=%d, gt=%u, guc_id=%d, batch_addr=0x%012llx, guc_state=0x%x, flags=0x%x, error=%d",
+			      __get_str(dev), __entry->q, __entry->fence,
+			      __entry->seqno, __entry->lrc_seqno,
+			      __entry->creator_tid,
+			      __entry->gt_id, __entry->guc_id,
 			      __entry->batch_addr, __entry->guc_state,
 			      __entry->flags, __entry->error)
 );
-- 
2.43.0


             reply	other threads:[~2026-06-29  6:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  6:15 Chen, Junjia [this message]
2026-06-29 15:27 ` [PATCH] drm/xe: Add creator TID to sched job trace points Matthew Brost
2026-06-29 19:51 ` ✓ CI.KUnit: success for " Patchwork
2026-06-29 20:54 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-30  5:01 ` ✓ Xe.CI.FULL: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260629061527.146714-1-junjia.chen@intel.com \
    --to=junjia.chen@intel.com \
    --cc=Chen@freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox