Skip to contentSkip to conversation

drm/amdgpu: trace amdgpu_job fence details

PATCH In review Andres Rodriguez 3 participants 7 messages Feb 22, 2017 – Feb 24, 2017 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: trace amdgpu_job fence details

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job)
 	/* if gpu reset, hw fence will be replaced here */
 	dma_fence_put(job->fence);
 	job->fence = dma_fence_get(fence);
+	trace_amdgpu_job_attach_fence(job);
+
 	amdgpu_job_free_resources(job);
 	return fence;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +22 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
 		      __entry->fence, __entry->ring_name, __entry->num_ibs)
 );
 
+TRACE_EVENT(amdgpu_job_attach_fence,
+	    TP_PROTO(struct amdgpu_job *job),
+	    TP_ARGS(job),
+	    TP_STRUCT__entry(
+			     __field(struct amdgpu_device *, adev)
+			     __field(struct amd_sched_job *, sched_job)
+			     __string(timeline, job->fence->ops->get_timeline_name(job->fence))
+			     __field(unsigned int, context)
+			     __field(unsigned int, seqno)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->adev = job->adev;
+			   __entry->sched_job = &job->base;
+			   __assign_str(timeline, job->fence->ops->get_timeline_name(job->fence))
+			   __entry->context = job->fence->context;
+			   __entry->seqno = job->fence->seqno;
+			   ),
+	    TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, seqno:%u",
+		      __entry->adev, __entry->sched_job,
+		      __get_str(timeline), __entry->context, __entry->seqno)
+);
 
 TRACE_EVENT(amdgpu_vm_grab_id,
 	    TP_PROTO(struct amdgpu_vm *vm, int ring, struct amdgpu_job *job),
Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170222234717.3854-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 47 lines · Andres Rodriguez

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job)
 	/* if gpu reset, hw fence will be replaced here */
 	dma_fence_put(job->fence);
 	job->fence = dma_fence_get(fence);
+	trace_amdgpu_job_attach_fence(job);
+
 	amdgpu_job_free_resources(job);
 	return fence;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +15 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
 		      __entry->fence, __entry->ring_name, __entry->num_ibs)
 );
 
+TRACE_EVENT(amdgpu_job_attach_fence,
+	    TP_PROTO(struct amdgpu_job *job),
+	    TP_ARGS(job),
+	    TP_STRUCT__entry(
+			     __field(struct amdgpu_device *, adev)
+			     __field(struct amd_sched_job *, sched_job)
+			     __string(timeline, job->fence->ops->get_timeline_name(job->fence))
+			     __field(unsigned int, context)
+			     __field(unsigned int, seqno)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->adev = job->adev;
+			   __entry->sched_job = &job->base;
+			   __assign_str(timeline, job->fence->ops->get_timeline_name(job->fence))

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 174

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +7 -0
+			   __entry->context = job->fence->context;
+			   __entry->seqno = job->fence->seqno;
+			   ),
+	    TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, seqno:%u",
+		      __entry->adev, __entry->sched_job,
+		      __get_str(timeline), __entry->context, __entry->seqno)
+);
 
 TRACE_EVENT(amdgpu_vm_grab_id,
 	    TP_PROTO(struct amdgpu_vm *vm, int ring, struct amdgpu_job *job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive

Am 23.02.2017 um 00:47 schrieb Andres Rodriguez:

Quoted 28 lines

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job)
  	/* if gpu reset, hw fence will be replaced here */
  	dma_fence_put(job->fence);
  	job->fence = dma_fence_get(fence);
+	trace_amdgpu_job_attach_fence(job);
+
  	amdgpu_job_free_resources(job);
  	return fence;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
index a18ae1e..0a61ed9 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 155

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +6 -0
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
  		      __entry->fence, __entry->ring_name, __entry->num_ibs)
  );
 
+TRACE_EVENT(amdgpu_job_attach_fence,
+	    TP_PROTO(struct amdgpu_job *job),
+	    TP_ARGS(job),
+	    TP_STRUCT__entry(
+			     __field(struct amdgpu_device *, adev)
+			     __field(struct amd_sched_job *, sched_job)

Neither add adev nor sched_job pointer to your trace point.

The adev pointer is completely meaningless in the logs and the scheduler job might already be freed when the printk is called.

Just checked the source and a couple of other trace points get this horrible wrong as well, so that isn't your fault. Going to put it on my todo to fix those.

Regards,
Christian.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +9 -0
+			     __string(timeline, job->fence->ops->get_timeline_name(job->fence))
+			     __field(unsigned int, context)
+			     __field(unsigned int, seqno)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->adev = job->adev;
+			   __entry->sched_job = &job->base;
+			   __assign_str(timeline, job->fence->ops->get_timeline_name(job->fence))

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 174

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +7 -0
+			   __entry->context = job->fence->context;
+			   __entry->seqno = job->fence->seqno;
+			   ),
+	    TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, seqno:%u",
+		      __entry->adev, __entry->sched_job,
+		      __get_str(timeline), __entry->context, __entry->seqno)
+);
 
  TRACE_EVENT(amdgpu_vm_grab_id,
  	    TP_PROTO(struct amdgpu_vm *vm, int ring, struct amdgpu_job *job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a1f29e6c-0a76-8805-710d-ec357b3d3eb3-5C7GfCeVMHo@public.gmane.org

#5 lore raw
Quoted 32 lines · Christian König

Am 23.02.2017 um 00:47 schrieb Andres Rodriguez:

Quoted 31 lines

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct 
 amd_sched_job *sched_job)
      /* if gpu reset, hw fence will be replaced here */
      dma_fence_put(job->fence);
      job->fence = dma_fence_get(fence);
+    trace_amdgpu_job_attach_fence(job);
+
      amdgpu_job_free_resources(job);
      return fence;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
                __entry->fence, __entry->ring_name, __entry->num_ibs)
  );
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 155

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -0
  +TRACE_EVENT(amdgpu_job_attach_fence,
+        TP_PROTO(struct amdgpu_job *job),
+        TP_ARGS(job),
+        TP_STRUCT__entry(
+                 __field(struct amdgpu_device *, adev)
+                 __field(struct amd_sched_job *, sched_job)

Neither add adev nor sched_job pointer to your trace point.

Would it be okay then to grab a reference to the scheduler fence in amdgpu_job_run and print the sched fence pointer here?

That would give us enough info to correlate other trace points like amdgpu_cs_ioctl aor amdgpu_sched_run_job to the respective dma_fence tracepoints.

Quoted 22 lines

The adev pointer is completely meaningless in the logs and the scheduler job might already be freed when the printk is called.

Just checked the source and a couple of other trace points get this horrible wrong as well, so that isn't your fault. Going to put it on my todo to fix those.

Regards,
Christian.

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +12 -0
+                 __string(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+                 __field(unsigned int, context)
+                 __field(unsigned int, seqno)
+                 ),
+
+        TP_fast_assign(
+               __entry->adev = job->adev;
+               __entry->sched_job = &job->base;
+               __assign_str(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+               __entry->context = job->fence->context;
+               __entry->seqno = job->fence->seqno;
+               ),
Quoted 10 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +4 -0
+        TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, 
 seqno:%u",
+              __entry->adev, __entry->sched_job,
+              __get_str(timeline), __entry->context, __entry->seqno)
+);
    TRACE_EVENT(amdgpu_vm_grab_id,
          TP_PROTO(struct amdgpu_vm *vm, int ring, struct amdgpu_job 

*job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 62565e6f-40e5-fdbd-3c75-8b214bb82881-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#7 lore raw
Quoted 43 lines · Andres Rodriguez
Quoted 32 lines · Christian König

Am 23.02.2017 um 00:47 schrieb Andres Rodriguez:

Quoted 31 lines

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 ++++++++++++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct 
 amd_sched_job *sched_job)
      /* if gpu reset, hw fence will be replaced here */
      dma_fence_put(job->fence);
      job->fence = dma_fence_get(fence);
+    trace_amdgpu_job_attach_fence(job);
+
      amdgpu_job_free_resources(job);
      return fence;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
                __entry->fence, __entry->ring_name, __entry->num_ibs)
  );
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 155

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -0
  +TRACE_EVENT(amdgpu_job_attach_fence,
+        TP_PROTO(struct amdgpu_job *job),
+        TP_ARGS(job),
+        TP_STRUCT__entry(
+                 __field(struct amdgpu_device *, adev)
+                 __field(struct amd_sched_job *, sched_job)

Neither add adev nor sched_job pointer to your trace point.

Quoted 7 lines

Would it be okay then to grab a reference to the scheduler fence in amdgpu_job_run and print the sched fence pointer here?

That would give us enough info to correlate other trace points like amdgpu_cs_ioctl aor amdgpu_sched_run_job to the respective dma_fence tracepoints.

Quoted 2 lines

The adev pointer is completely meaningless in the logs and the scheduler job might already be freed when the printk is called.

Hey Christian,

I was just double checking the lifetime of the scheduler job, and it should still be valid during amdgpu_job_run. The lifetime of the job is tied to the scheduler finished fence which won't be signaled until amdgpu_job_run finishes even if the HW fence has signaled.

This is assuming that the trace printks are synchronous.

So I think printing the job and dropping adev should be okay if the above holds true, unless I'm missing something else.

Quoted 22 lines
Quoted 22 lines

Just checked the source and a couple of other trace points get this horrible wrong as well, so that isn't your fault. Going to put it on my todo to fix those.

Regards,
Christian.

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +13 -0
+                 __string(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+                 __field(unsigned int, context)
+                 __field(unsigned int, seqno)
+                 ),
+
+        TP_fast_assign(
+               __entry->adev = job->adev;
+               __entry->sched_job = &job->base;
+               __assign_str(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+               __entry->context = job->fence->context;
+               __entry->seqno = job->fence->seqno;
+               ),
+        TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, 
 seqno:%u",
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
+              __entry->adev, __entry->sched_job,
+              __get_str(timeline), __entry->context, __entry->seqno)
+);
    TRACE_EVENT(amdgpu_vm_grab_id,
          TP_PROTO(struct amdgpu_vm *vm, int ring, struct amdgpu_job 

*job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 54a7e402-1d21-5898-549a-7482e13df049-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#9 lore raw

Am 23.02.2017 um 21:48 schrieb Andres Rodriguez:

Quoted 53 lines · Andres Rodriguez
Quoted 50 lines · Christian König
Quoted 33 lines

Am 23.02.2017 um 00:47 schrieb Andres Rodriguez:

Quoted 32 lines

This trace is intended to provide the required information to associate the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22 
++++++++++++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct 
 amd_sched_job *sched_job)
      /* if gpu reset, hw fence will be replaced here */
      dma_fence_put(job->fence);
      job->fence = dma_fence_get(fence);
+    trace_amdgpu_job_attach_fence(job);
+
      amdgpu_job_free_resources(job);
      return fence;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
                __entry->fence, __entry->ring_name, __entry->num_ibs)
  );
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 154

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -0
  +TRACE_EVENT(amdgpu_job_attach_fence,
+        TP_PROTO(struct amdgpu_job *job),
+        TP_ARGS(job),
+        TP_STRUCT__entry(
+                 __field(struct amdgpu_device *, adev)
+                 __field(struct amd_sched_job *, sched_job)

Neither add adev nor sched_job pointer to your trace point.

Would it be okay then to grab a reference to the scheduler fence in amdgpu_job_run and print the sched fence pointer here?

That would give us enough info to correlate other trace points like amdgpu_cs_ioctl aor amdgpu_sched_run_job to the respective dma_fence tracepoints.

Quoted 1 line
Quoted 6 lines
Quoted 1 line
Quoted 1 line

The adev pointer is completely meaningless in the logs and the scheduler job might already be freed when the printk is called.

Hey Christian,

I was just double checking the lifetime of the scheduler job, and it should still be valid during amdgpu_job_run. The lifetime of the job is tied to the scheduler finished fence which won't be signaled until amdgpu_job_run finishes even if the HW fence has signaled.

This is assuming that the trace printks are synchronous.

That assumption is incorrect.

The parameters are stored on a ring buffer when the trace point is executed, but the string is composed later on when you request the trace content from userspace.

Additional to that printing pointers which are heavily reallocated is a bad idea because once the job is freed the pointer will certainly be reused for another job.

Using the numbers from the scheduler fence is the right approach here and you don't even need to grab another reference, just save the context and sequence number as identifier for the job.

Regards,
Christian.

Quoted 35 lines

So I think printing the job and dropping adev should be okay if the above holds true, unless I'm missing something else.

Quoted 31 lines
Quoted 30 lines

Just checked the source and a couple of other trace points get this horrible wrong as well, so that isn't your fault. Going to put it on my todo to fix those.

Regards,
Christian.

Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +16 -0
+                 __string(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+                 __field(unsigned int, context)
+                 __field(unsigned int, seqno)
+                 ),
+
+        TP_fast_assign(
+               __entry->adev = job->adev;
+               __entry->sched_job = &job->base;
+               __assign_str(timeline, 
 job->fence->ops->get_timeline_name(job->fence))
+               __entry->context = job->fence->context;
+               __entry->seqno = job->fence->seqno;
+               ),
+        TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u, 
 seqno:%u",
+              __entry->adev, __entry->sched_job,
+              __get_str(timeline), __entry->context, __entry->seqno)
+);
    TRACE_EVENT(amdgpu_vm_grab_id,
          TP_PROTO(struct amdgpu_vm *vm, int ring, struct 

amdgpu_job *job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): acb2a074-0552-1dcb-9be9-30a958cf3970-5C7GfCeVMHo@public.gmane.org

#11 lore raw
Quoted 77 lines · Christian König

Am 23.02.2017 um 21:48 schrieb Andres Rodriguez:

Quoted 61 lines · Andres Rodriguez
Quoted 47 lines · Christian König
Quoted 36 lines

Am 23.02.2017 um 00:47 schrieb Andres Rodriguez:

Quoted 35 lines

This trace is intended to provide the required information to associate
the completion of an amdgpu_job with its corresponding dma_fence_* tracepoints.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c   |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 22
++++++++++++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
index 86a1242..84a04e4 100644
@@ -177,6 +177,8 @@ static struct dma_fence *amdgpu_job_run(struct
 amd_sched_job *sched_job)
      /* if gpu reset, hw fence will be replaced here */
      dma_fence_put(job->fence);
      job->fence = dma_fence_get(fence);
+    trace_amdgpu_job_attach_fence(job);
+
      amdgpu_job_free_resources(job);
      return fence;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
index a18ae1e..0a61ed9 100644
@@ -147,6 +147,28 @@ TRACE_EVENT(amdgpu_sched_run_job,
                __entry->fence, __entry->ring_name, __entry->num_ibs)
  );
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_sched_run_job, · line 154

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -0
  +TRACE_EVENT(amdgpu_job_attach_fence,
+        TP_PROTO(struct amdgpu_job *job),
+        TP_ARGS(job),
+        TP_STRUCT__entry(
+                 __field(struct amdgpu_device *, adev)
+                 __field(struct amd_sched_job *, sched_job)

Neither add adev nor sched_job pointer to your trace point.

Quoted 11 lines

Would it be okay then to grab a reference to the scheduler fence in amdgpu_job_run and print the sched fence pointer here?

That would give us enough info to correlate other trace points like amdgpu_cs_ioctl aor amdgpu_sched_run_job to the respective dma_fence tracepoints.

Quoted 3 lines

The adev pointer is completely meaningless in the logs and the scheduler job might already be freed when the printk is called.

Quoted 8 lines

Hey Christian,

I was just double checking the lifetime of the scheduler job, and it should still be valid during amdgpu_job_run. The lifetime of the job is tied to the scheduler finished fence which won't be signaled until amdgpu_job_run finishes even if the HW fence has signaled.

This is assuming that the trace printks are synchronous.

That assumption is incorrect.

The parameters are stored on a ring buffer when the trace point is executed, but the string is composed later on when you request the trace content from userspace.

Quoted 7 lines

Additional to that printing pointers which are heavily reallocated is a bad idea because once the job is freed the pointer will certainly be reused for another job.

Using the numbers from the scheduler fence is the right approach here and you don't even need to grab another reference, just save the context and sequence number as identifier for the job.

Thanks for the explanation.

Using the scheduler fence as you suggested also means that we have the data available on the amdgpu_sched_run_job and we won't require an extra trace point. So that is overall cleaner.

I'll send a patch to use that approach instead. I won't be removing anything from amdgpu_sched_run_job though since I'm not sure of the backwards compat rules for trace events.

Regards,
Andres

Quoted 43 lines

Regards,
Christian.

Quoted 38 lines

So I think printing the job and dropping adev should be okay if the above holds true, unless I'm missing something else.

Quoted 33 lines
Quoted 32 lines

Just checked the source and a couple of other trace points get this horrible wrong as well, so that isn't your fault. Going to put it on my todo to fix those.

Regards,
Christian.

Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +16 -0
+                 __string(timeline,
 job->fence->ops->get_timeline_name(job->fence))
+                 __field(unsigned int, context)
+                 __field(unsigned int, seqno)
+                 ),
+
+        TP_fast_assign(
+               __entry->adev = job->adev;
+               __entry->sched_job = &job->base;
+               __assign_str(timeline,
 job->fence->ops->get_timeline_name(job->fence))
+               __entry->context = job->fence->context;
+               __entry->seqno = job->fence->seqno;
+               ),
+        TP_printk("adev=%p, sched_job=%p, timeline:%s, context:%u,
 seqno:%u",
+              __entry->adev, __entry->sched_job,
+              __get_str(timeline), __entry->context, __entry->seqno)
+);
    TRACE_EVENT(amdgpu_vm_grab_id,
          TP_PROTO(struct amdgpu_vm *vm, int ring, struct

amdgpu_job *job),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx