Skip to contentSkip to conversation

drm/amdgpu: fix the null pointer to get timeline by scheduler fence

PATCH In review Huang Rui 5 participants 7 messages Aug 8, 2018 – Aug 14, 2018 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix the null pointer to get timeline by scheduler fence

We won't initialize fence scheduler in drm_sched_fence_create() anymore, so it will refer null fence scheduler if open trace event to get the timeline name. Actually, it is the scheduler name from the entity, so add a macro to replace legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067 PMD 0
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G           OE     4.18.0-rc1-custom #1
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd. Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30 [gpu_sched]
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13 48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f
[  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX: ffffa3ed81f27da8
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI: ffff8f24ebfb5400
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09: ffffffffae4deafc
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12: ffff8f24e891f898
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15: ffff8f24e3de97a8
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000) knlGS:0000000000000000
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4: 00000000003606e0
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170 [amdgpu]
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index e12871d..be01e1b 100644
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 
 	amdgpu_job_free_resources(job);
 
-	trace_amdgpu_cs_ioctl(job);
+	trace_amdgpu_cs_ioctl(job, entity);
 	amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
 	priority = job->base.s_priority;
 	drm_sched_entity_push_job(&job->base, entity);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +6 -4
index 8c2dab2..25cdcb7 100644
@@ -36,6 +36,8 @@
 
 #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
 	 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
+#define AMDGPU_GET_SCHED_NAME(entity) \
+	 (entity->rq->sched->name)
 
 TRACE_EVENT(amdgpu_mm_rreg,
 	    TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
 );
 
 TRACE_EVENT(amdgpu_cs_ioctl,
-	    TP_PROTO(struct amdgpu_job *job),
-	    TP_ARGS(job),
+	    TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity *entity),
+	    TP_ARGS(job, entity),
 	    TP_STRUCT__entry(
 			     __field(uint64_t, sched_job_id)
-			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			     __string(timeline, AMDGPU_GET_SCHED_NAME(entity))
 			     __field(unsigned int, context)
 			     __field(unsigned int, seqno)
 			     __field(struct dma_fence *, fence)
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 
 	    TP_fast_assign(
 			   __entry->sched_job_id = job->base.id;
-			   __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			   __assign_str(timeline, AMDGPU_GET_SCHED_NAME(entity))
 			   __entry->context = job->base.s_fence->finished.context;
 			   __entry->seqno = job->base.s_fence->finished.seqno;
 			   __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;
Signature · 6 lines
2.7.4

_______________________________________________
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): 1533711936-22450-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 85 lines

We won't initialize fence scheduler in drm_sched_fence_create() anymore, so it will refer null fence scheduler if open trace event to get the timeline name. Actually, it is the scheduler name from the entity, so add a macro to replace legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067 PMD 0
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G           OE     4.18.0-rc1-custom #1
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd. Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30 [gpu_sched]
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13 48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f
[  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX: ffffa3ed81f27da8
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI: ffff8f24ebfb5400
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09: ffffffffae4deafc
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12: ffff8f24e891f898
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15: ffff8f24e3de97a8
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000) knlGS:0000000000000000
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4: 00000000003606e0
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170 [amdgpu]
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----
  2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index e12871d..be01e1b 100644
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 
  	amdgpu_job_free_resources(job);
 
-	trace_amdgpu_cs_ioctl(job);
+	trace_amdgpu_cs_ioctl(job, entity);
  	amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
  	priority = job->base.s_priority;
  	drm_sched_entity_push_job(&job->base, entity);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -3
index 8c2dab2..25cdcb7 100644
@@ -36,6 +36,8 @@
 
  #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
  	 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
+#define AMDGPU_GET_SCHED_NAME(entity) \
+	 (entity->rq->sched->name)
 
  TRACE_EVENT(amdgpu_mm_rreg,
  	    TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
  );
 
  TRACE_EVENT(amdgpu_cs_ioctl,
-	    TP_PROTO(struct amdgpu_job *job),
-	    TP_ARGS(job),
+	    TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity *entity),
+	    TP_ARGS(job, entity),
  	    TP_STRUCT__entry(
  			     __field(uint64_t, sched_job_id)
-			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			     __string(timeline, AMDGPU_GET_SCHED_NAME(entity))
  			     __field(unsigned int, context)
  			     __field(unsigned int, seqno)
  			     __field(struct dma_fence *, fence)

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 183

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -1
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 
  	    TP_fast_assign(
  			   __entry->sched_job_id = job->base.id;
-			   __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			   __assign_str(timeline, AMDGPU_GET_SCHED_NAME(entity))
  			   __entry->context = job->base.s_fence->finished.context;
  			   __entry->seqno = job->base.s_fence->finished.seqno;
  			   __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;

_______________________________________________
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): 91ac6260-1f17-12a9-80e9-50d78756bb87-5C7GfCeVMHo@public.gmane.org

author
#4 lore raw
Quoted 9 lines · Christian

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

Could you please explain why move reschedule along can fix the issue. Seemingly, only s_fence's sched is written to entity rq's sched, it can avoid the issue.

sched_job->s_fence->sched = entity->rq->sched

Thanks,
Ray

Quoted 91 lines

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 86 lines

We won't initialize fence scheduler in drm_sched_fence_create() anymore, so it will refer null fence scheduler if open trace event to get the timeline name. Actually, it is the scheduler name from the entity, so add a macro to replace legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067 PMD 0
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G           OE     4.18.0-rc1-custom #1
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd. Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30 [gpu_sched]
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13 48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f
[  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX: ffffa3ed81f27da8
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI: ffff8f24ebfb5400
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09: ffffffffae4deafc
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12: ffff8f24e891f898
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15: ffff8f24e3de97a8
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000) knlGS:0000000000000000
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4: 00000000003606e0
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170 [amdgpu]
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----
  2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index e12871d..be01e1b 100644
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 
  	amdgpu_job_free_resources(job);
 
-	trace_amdgpu_cs_ioctl(job);
+	trace_amdgpu_cs_ioctl(job, entity);
  	amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
  	priority = job->base.s_priority;
  	drm_sched_entity_push_job(&job->base, entity);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +5 -3
index 8c2dab2..25cdcb7 100644
@@ -36,6 +36,8 @@
 
  #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
  	 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
+#define AMDGPU_GET_SCHED_NAME(entity) \
+	 (entity->rq->sched->name)
 
  TRACE_EVENT(amdgpu_mm_rreg,
  	    TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
  );
 
  TRACE_EVENT(amdgpu_cs_ioctl,
-	    TP_PROTO(struct amdgpu_job *job),
-	    TP_ARGS(job),
+	    TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity *entity),
+	    TP_ARGS(job, entity),
  	    TP_STRUCT__entry(
  			     __field(uint64_t, sched_job_id)
-			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			     __string(timeline, AMDGPU_GET_SCHED_NAME(entity))
  			     __field(unsigned int, context)
  			     __field(unsigned int, seqno)
  			     __field(struct dma_fence *, fence)
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 183

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -1
  	    TP_fast_assign(
  			   __entry->sched_job_id = job->base.id;
-			   __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+			   __assign_str(timeline, AMDGPU_GET_SCHED_NAME(entity))
  			   __entry->context = job->base.s_fence->finished.context;
  			   __entry->seqno = job->base.s_fence->finished.seqno;
  			   __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;

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

#5 lore raw
Quoted 11 lines · Huang Rui
Quoted 9 lines · Christian

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

Quoted 7 lines

Could you please explain why move reschedule along can fix the issue. Seemingly, only s_fence's sched is written to entity rq's sched, it can avoid the issue.

sched_job->s_fence->sched = entity->rq->sched

Because entity->rq->sched may not necessarily be the scheduler on which

this job will get scheduled. And assigning a wrong scheduler could lead to wrong dependency optimizations. Hence it was assigned NULL initially we don't know scheduler it will be scheduled on to avoid any wrong optimizations.

Cheers,
Nayan

Quoted 125 lines

Thanks,
Ray

Quoted 6 lines

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 1 line

We won't initialize fence scheduler in drm_sched_fence_create()

anymore, so it

Quoted 1 line
Quoted 1 line

will refer null fence scheduler if open trace event to get the

timeline name.

Quoted 1 line
Quoted 1 line

Actually, it is the scheduler name from the entity, so add a macro to

replace

Quoted 3 lines
Quoted 3 lines

legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference

at 0000000000000018

Quoted 1 line
Quoted 1 line
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067

PMD 0

Quoted 2 lines
Quoted 2 lines
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G

OE 4.18.0-rc1-custom #1

Quoted 1 line
Quoted 1 line
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd.

Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016

Quoted 1 line
Quoted 1 line
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30

[gpu_sched]

Quoted 1 line
Quoted 1 line
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13

48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f

Quoted 2 lines
Quoted 2 lines
[  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX:

ffffa3ed81f27da8

Quoted 1 line
Quoted 1 line
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI:

ffff8f24ebfb5400

Quoted 1 line
Quoted 1 line
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09:

ffffffffae4deafc

Quoted 1 line
Quoted 1 line
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12:

ffff8f24e891f898

Quoted 1 line
Quoted 1 line
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15:

ffff8f24e3de97a8

Quoted 1 line
Quoted 1 line
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000)

knlGS:0000000000000000

Quoted 2 lines
Quoted 2 lines
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4:

00000000003606e0

Quoted 1 line
Quoted 1 line
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2:

0000000000000000

Quoted 1 line
Quoted 1 line
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:

0000000000000400

Quoted 2 lines
Quoted 2 lines
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170

[amdgpu]

Quoted 12 lines
Quoted 12 lines
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]
Quoted 7 lines

Review

Quoted 7 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----
  2 files changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct

Quoted 4 lines

index e12871d..be01e1b 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct

amdgpu_cs_parser *p,

Quoted 9 lines

Review

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
    amdgpu_job_free_resources(job);
 
-   trace_amdgpu_cs_ioctl(job);
+   trace_amdgpu_cs_ioctl(job, entity);
    amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
    priority = job->base.s_priority;
    drm_sched_entity_push_job(&job->base, entity);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h line 38

Quoted 7 lines

index 8c2dab2..25cdcb7 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
@@ -36,6 +36,8 @@
 
  #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
 

job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
+#define AMDGPU_GET_SCHED_NAME(entity) \
+    (entity->rq->sched->name)
 
  TRACE_EVENT(amdgpu_mm_rreg,
        TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
  );
 
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -2
  TRACE_EVENT(amdgpu_cs_ioctl,
-       TP_PROTO(struct amdgpu_job *job),
-       TP_ARGS(job),
+       TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity

*entity),

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -1
+       TP_ARGS(job, entity),
        TP_STRUCT__entry(
                         __field(uint64_t, sched_job_id)
-                        __string(timeline,

AMDGPU_JOB_GET_TIMELINE_NAME(job))

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs, · line 170

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -0
+                        __string(timeline,

AMDGPU_GET_SCHED_NAME(entity))

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 178

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -1
                         __field(unsigned int, context)
                         __field(unsigned int, seqno)
                         __field(struct dma_fence *, fence)
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 
        TP_fast_assign(
                       __entry->sched_job_id = job->base.id;
-                      __assign_str(timeline,

AMDGPU_JOB_GET_TIMELINE_NAME(job))

Quoted 10 lines
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 180

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -0
+                      __assign_str(timeline,

AMDGPU_GET_SCHED_NAME(entity))

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 181

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->context =

job->base.s_fence->finished.context;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 182

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->seqno =

job->base.s_fence->finished.seqno;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 183

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->ring_name =

to_amdgpu_ring(job->base.sched)->name;

Quoted 1 line

_______________________________________________
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): CAFd4ddzbq5xLZUK6WfAS=hvjo8KaPbhwDxPV5jEkxUXMP3QN9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#7 lore raw
Quoted 17 lines · Nayan Deshmukh
Quoted 15 lines · Huang Rui
Quoted 9 lines · Christian

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

Could you please explain why move reschedule along can fix the issue. Seemingly, only s_fence's sched is written to entity rq's sched, it can avoid the issue.

Quoted 8 lines
Quoted 3 lines

sched_job->s_fence->sched = entity->rq->sched

Because entity->rq->sched may not necessarily be the scheduler on which

this job will get scheduled. And assigning a wrong scheduler could lead to wrong dependency optimizations. Hence it was assigned NULL initially we don't know scheduler it will be scheduled on to avoid any wrong optimizations.

Nayan, thank you. I got it. That's the reason that we assigned sfence->sched as NULL in drm_sched_job_init().

Thanks,
Ray

Quoted 135 lines

Cheers,
Nayan

Quoted 132 lines

Thanks,
Ray

Quoted 6 lines

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 1 line

We won't initialize fence scheduler in drm_sched_fence_create()

anymore, so it

Quoted 1 line
Quoted 1 line

will refer null fence scheduler if open trace event to get the

timeline name.

Quoted 1 line
Quoted 1 line

Actually, it is the scheduler name from the entity, so add a macro to

replace

Quoted 3 lines
Quoted 3 lines

legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference

at 0000000000000018

Quoted 1 line
Quoted 1 line
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067

PMD 0

Quoted 2 lines
Quoted 2 lines
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G

OE 4.18.0-rc1-custom #1

Quoted 1 line
Quoted 1 line
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd.

Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016

Quoted 1 line
Quoted 1 line
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30

[gpu_sched]

Quoted 1 line
Quoted 1 line
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13

48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f

Quoted 2 lines
Quoted 2 lines
[  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX:

ffffa3ed81f27da8

Quoted 1 line
Quoted 1 line
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI:

ffff8f24ebfb5400

Quoted 1 line
Quoted 1 line
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09:

ffffffffae4deafc

Quoted 1 line
Quoted 1 line
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12:

ffff8f24e891f898

Quoted 1 line
Quoted 1 line
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15:

ffff8f24e3de97a8

Quoted 1 line
Quoted 1 line
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000)

knlGS:0000000000000000

Quoted 2 lines
Quoted 2 lines
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4:

00000000003606e0

Quoted 1 line
Quoted 1 line
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2:

0000000000000000

Quoted 1 line
Quoted 1 line
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:

0000000000000400

Quoted 2 lines
Quoted 2 lines
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170

[amdgpu]

Quoted 12 lines
Quoted 12 lines
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]
Quoted 7 lines

Review

Quoted 7 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----
  2 files changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct

Quoted 4 lines

index e12871d..be01e1b 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct

amdgpu_cs_parser *p,

Quoted 9 lines

Review

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
    amdgpu_job_free_resources(job);
 
-   trace_amdgpu_cs_ioctl(job);
+   trace_amdgpu_cs_ioctl(job, entity);
    amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
    priority = job->base.s_priority;
    drm_sched_entity_push_job(&job->base, entity);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h line 38

Quoted 7 lines

index 8c2dab2..25cdcb7 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
@@ -36,6 +36,8 @@
 
  #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
 

job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
+#define AMDGPU_GET_SCHED_NAME(entity) \
+    (entity->rq->sched->name)
 
  TRACE_EVENT(amdgpu_mm_rreg,
        TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
  );
 
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs, · line 166

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -2
  TRACE_EVENT(amdgpu_cs_ioctl,
-       TP_PROTO(struct amdgpu_job *job),
-       TP_ARGS(job),
+       TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity

*entity),

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs, · line 168

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -1
+       TP_ARGS(job, entity),
        TP_STRUCT__entry(
                         __field(uint64_t, sched_job_id)
-                        __string(timeline,

AMDGPU_JOB_GET_TIMELINE_NAME(job))

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs, · line 170

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -0
+                        __string(timeline,

AMDGPU_GET_SCHED_NAME(entity))

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 178

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -1
                         __field(unsigned int, context)
                         __field(unsigned int, seqno)
                         __field(struct dma_fence *, fence)
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
 
        TP_fast_assign(
                       __entry->sched_job_id = job->base.id;
-                      __assign_str(timeline,

AMDGPU_JOB_GET_TIMELINE_NAME(job))

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 180

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -0
+                      __assign_str(timeline,

AMDGPU_GET_SCHED_NAME(entity))

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 181

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->context =

job->base.s_fence->finished.context;

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h TRACE_EVENT(amdgpu_cs_ioctl, · line 182

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->seqno =

job->base.s_fence->finished.seqno;

Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
                       __entry->ring_name =
Quoted 8 lines
Quoted 3 lines

to_amdgpu_ring(job->base.sched)->name;

Quoted 1 line

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

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

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

Any updates on this issue?

Regards,
Andres

Quoted 100 lines · Christian König

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 88 lines

We won't initialize fence scheduler in drm_sched_fence_create() anymore, so it will refer null fence scheduler if open trace event to get the timeline name. Actually, it is the scheduler name from the entity, so add a macro to replace legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067 PMD 0
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G OE     4.18.0-rc1-custom #1
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd. Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30 [gpu_sched]
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13 48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f [  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX: ffffa3ed81f27da8
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI: ffff8f24ebfb5400
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09: ffffffffae4deafc
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12: ffff8f24e891f898
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15: ffff8f24e3de97a8
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000) knlGS:0000000000000000
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4: 00000000003606e0
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  212.985720] Call Trace:
[  212.988236]  trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170 [amdgpu]
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----

  2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index e12871d..be01e1b 100644
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct 
 amdgpu_cs_parser *p,
       amdgpu_job_free_resources(job);
-    trace_amdgpu_cs_ioctl(job);
+    trace_amdgpu_cs_ioctl(job, entity);
       amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
       priority = job->base.s_priority;
       drm_sched_entity_push_job(&job->base, entity);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +4 -2
index 8c2dab2..25cdcb7 100644
@@ -36,6 +36,8 @@
   #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
 
 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished) 
 
+#define AMDGPU_GET_SCHED_NAME(entity) \
+     (entity->rq->sched->name)
   TRACE_EVENT(amdgpu_mm_rreg,
           TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
   );
   TRACE_EVENT(amdgpu_cs_ioctl,
-        TP_PROTO(struct amdgpu_job *job),
-        TP_ARGS(job),
+        TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity 
 *entity),
+        TP_ARGS(job, entity),

          TP_STRUCT__entry(
                   __field(uint64_t, sched_job_id)
-                 __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job)) +                 __string(timeline, AMDGPU_GET_SCHED_NAME(entity)) __field(unsigned int, context) __field(unsigned int, seqno) __field(struct dma_fence *, fence)

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,

          TP_fast_assign(
                 __entry->sched_job_id = job->base.id;
-               __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job)) +               __assign_str(timeline, AMDGPU_GET_SCHED_NAME(entity))

Quoted 8 lines
Quoted 3 lines

                 __entry->context = job->base.s_fence->finished.context; __entry->seqno = job->base.s_fence->finished.seqno; __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;

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

_______________________________________________
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): 40bb865b-2eff-7075-43b9-456896b1d043-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#10 lore raw

That is fixed by "drm/scheduler: bind job earlier to scheduler".

Christian.

Am 13.08.2018 um 16:33 schrieb Andres Rodriguez:

Quoted 114 lines

Any updates on this issue?

Regards,
Andres

Quoted 100 lines · Christian König

Yeah that is a known issue, but this solution is not correct either.

See the scheduler where the job is execute on is simply not determined yet when we want to trace it.

So using the scheduler name from the entity is wrong as well.

We should probably move the reschedule from drm_sched_entity_push_job() to drm_sched_job_init() to fix that.

I will prepare a patch for that today,
Christian.

Am 08.08.2018 um 09:05 schrieb Huang Rui:

Quoted 88 lines

We won't initialize fence scheduler in drm_sched_fence_create() anymore, so it will refer null fence scheduler if open trace event to get the timeline name. Actually, it is the scheduler name from the entity, so add a macro to replace legacy getting timeline name by job.

[  212.844281] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  212.852401] PGD 8000000427c13067 P4D 8000000427c13067 PUD 4235fc067 PMD 0
[  212.859419] Oops: 0000 [#1] SMP PTI
[  212.862981] CPU: 4 PID: 1520 Comm: amdgpu_test Tainted: G           OE     4.18.0-rc1-custom #1
[  212.872194] Hardware name: Gigabyte Technology Co., Ltd. Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  212.881704] RIP: 0010:drm_sched_fence_get_timeline_name+0x2b/0x30 [gpu_sched]
[  212.888948] Code: 1f 44 00 00 48 8b 47 08 48 3d c0 b1 4f c0 74 13 48 83 ef 60 48 3d 60 b1 4f c0 b8 00 00 00 00 48 0f 45 f8 48 8b 87 e0 00 00 00 <48> 8b 40 18 c3 0f 1f 44 00 00 b8 01 00 00 00 c3 0f 1f 44 00 00 0f [  212.908162] RSP: 0018:ffffa3ed81f27af0 EFLAGS: 00010246
[  212.913483] RAX: 0000000000000000 RBX: 0000000000070034 RCX: ffffa3ed81f27da8
[  212.920735] RDX: ffff8f24ebfb5460 RSI: ffff8f24e40d3c00 RDI: ffff8f24ebfb5400
[  212.928008] RBP: ffff8f24e40d3c00 R08: 0000000000000000 R09: ffffffffae4deafc
[  212.935263] R10: ffffffffada000ed R11: 0000000000000001 R12: ffff8f24e891f898
[  212.942558] R13: 0000000000000000 R14: ffff8f24ebc46000 R15: ffff8f24e3de97a8
[  212.949796] FS:  00007ffff7fd2700(0000) GS:ffff8f24fed00000(0000) knlGS:0000000000000000
[  212.958047] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  212.963921] CR2: 0000000000000018 CR3: 0000000423422003 CR4: 00000000003606e0
[  212.971201] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  212.978482] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  212.985720] Call Trace:
[  212.988236] trace_event_raw_event_amdgpu_cs_ioctl+0x4c/0x170 [amdgpu]
[  212.994904]  ? amdgpu_ctx_add_fence+0xa9/0x110 [amdgpu]
[  213.000246]  ? amdgpu_job_free_resources+0x4b/0x70 [amdgpu]
[  213.005944]  amdgpu_cs_ioctl+0x16d1/0x1b50 [amdgpu]
[  213.010920]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.016354]  drm_ioctl_kernel+0x8a/0xd0 [drm]
[  213.020794]  ? recalc_sigpending+0x17/0x50
[  213.024965]  drm_ioctl+0x2d7/0x390 [drm]
[  213.028979]  ? amdgpu_cs_find_mapping+0xf0/0xf0 [amdgpu]
[  213.034366]  ? do_signal+0x36/0x700
[  213.037928]  ? signal_wake_up_state+0x15/0x30
[  213.042375]  amdgpu_drm_ioctl+0x46/0x80 [amdgpu]

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 10 ++++++----

  2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
index e12871d..be01e1b 100644
@@ -1247,7 +1247,7 @@ static int amdgpu_cs_submit(struct 
 amdgpu_cs_parser *p,
       amdgpu_job_free_resources(job);
-    trace_amdgpu_cs_ioctl(job);
+    trace_amdgpu_cs_ioctl(job, entity);
       amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
       priority = job->base.s_priority;
       drm_sched_entity_push_job(&job->base, entity);
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +4 -2
index 8c2dab2..25cdcb7 100644
@@ -36,6 +36,8 @@
   #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished) 
 
+#define AMDGPU_GET_SCHED_NAME(entity) \
+     (entity->rq->sched->name)
   TRACE_EVENT(amdgpu_mm_rreg,
           TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
@@ -161,11 +163,11 @@ TRACE_EVENT(amdgpu_cs,
   );
   TRACE_EVENT(amdgpu_cs_ioctl,
-        TP_PROTO(struct amdgpu_job *job),
-        TP_ARGS(job),
+        TP_PROTO(struct amdgpu_job *job, struct drm_sched_entity 
 *entity),
+        TP_ARGS(job, entity),

          TP_STRUCT__entry(
                   __field(uint64_t, sched_job_id)
-                 __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job)) +                 __string(timeline, AMDGPU_GET_SCHED_NAME(entity)) __field(unsigned int, context) __field(unsigned int, seqno) __field(struct dma_fence *, fence)

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +0 -0
@@ -175,7 +177,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,

          TP_fast_assign(
                 __entry->sched_job_id = job->base.id;
-               __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
+               __assign_str(timeline, AMDGPU_GET_SCHED_NAME(entity))

Quoted 8 lines
Quoted 3 lines

                 __entry->context = job->base.s_fence->finished.context; __entry->seqno = job->base.s_fence->finished.seqno; __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;

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

Quoted 4 lines

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

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