Skip to contentSkip to conversation

drm/amdkfd: fix cp hang in eviction

PATCH In review Huang, JinHuiEric 2 participants 3 messages Jul 10, 2019 – Jul 11, 2019 1 message not in the archive

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

PATCH 1/1 drm/amdkfd: fix cp hang in eviction

The cp hang occurs in OCL conformance test only on supermicro platform which has 40 cores and the test generates 40 threads. The root cause is race condition in non-protected flags.

The fix is to add flags of is_evicted and is_active(init_mqd()) into protected area.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +9 -7
index 9ffdda5..f23e17b 100644
@@ -1157,12 +1157,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
 
 	mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
 			q->properties.type)];
-	/*
-	 * Eviction state logic: mark all queues as evicted, even ones
-	 * not currently active. Restoring inactive queues later only
-	 * updates the is_evicted flag but is a no-op otherwise.
-	 */
-	q->properties.is_evicted = !!qpd->evicted;
+
 	if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
 		q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
 		dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
@@ -1173,9 +1168,16 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
 		retval = -ENOMEM;
 		goto out_deallocate_doorbell;
 	}
+
+	dqm_lock(dqm);
+	/*
+	 * Eviction state logic: mark all queues as evicted, even ones
+	 * not currently active. Restoring inactive queues later only
+	 * updates the is_evicted flag but is a no-op otherwise.
+	 */
+	q->properties.is_evicted = !!qpd->evicted;
 	mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj,
 				&q->gart_mqd_addr, &q->properties);
-	dqm_lock(dqm);
 
 	list_add(&q->list, &qpd->queues_list);
 	qpd->queue_count++;
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): 1562772046-7681-1-git-send-email-JinhuiEric.Huang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

ping.

Quoted 38 lines · JinHuiEric

The cp hang occurs in OCL conformance test only on supermicro platform which has 40 cores and the test generates 40 threads. The root cause is race condition in non-protected flags.

The fix is to add flags of is_evicted and is_active(init_mqd()) into protected area.

---
  drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -6
index 9ffdda5..f23e17b 100644
@@ -1157,12 +1157,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
 
  	mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
  			q->properties.type)];
-	/*
-	 * Eviction state logic: mark all queues as evicted, even ones
-	 * not currently active. Restoring inactive queues later only
-	 * updates the is_evicted flag but is a no-op otherwise.
-	 */
-	q->properties.is_evicted = !!qpd->evicted;
+
  	if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
  		q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
  		dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
@@ -1173,9 +1168,16 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
  		retval = -ENOMEM;
  		goto out_deallocate_doorbell;
  	}
+
+	dqm_lock(dqm);
+	/*
+	 * Eviction state logic: mark all queues as evicted, even ones

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, · line 1183

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -1
+	 * not currently active. Restoring inactive queues later only
+	 * updates the is_evicted flag but is a no-op otherwise.
+	 */
+	q->properties.is_evicted = !!qpd->evicted;
  	mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj,
  				&q->gart_mqd_addr, &q->properties);
-	dqm_lock(dqm);
 
  	list_add(&q->list, &qpd->queues_list);
  	qpd->queue_count++;

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

Reviewed-by Felix Kuehling
#3 lore raw
In reply to a message not in the archive
Quoted 8 lines · JinHuiEric

The cp hang occurs in OCL conformance test only on supermicro platform which has 40 cores and the test generates 40 threads. The root cause is race condition in non-protected flags.

The fix is to add flags of is_evicted and is_active(init_mqd()) into protected area.

Sorry, I missed this one. I only saw the one earlier that you recalled.

Quoted 30 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -6
index 9ffdda5..f23e17b 100644
@@ -1157,12 +1157,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
 
  	mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
  			q->properties.type)];
-	/*
-	 * Eviction state logic: mark all queues as evicted, even ones
-	 * not currently active. Restoring inactive queues later only
-	 * updates the is_evicted flag but is a no-op otherwise.
-	 */
-	q->properties.is_evicted = !!qpd->evicted;
+
  	if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
  		q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
  		dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
@@ -1173,9 +1168,16 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
  		retval = -ENOMEM;
  		goto out_deallocate_doorbell;
  	}
+
+	dqm_lock(dqm);
+	/*
+	 * Eviction state logic: mark all queues as evicted, even ones

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, · line 1183

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4 -1
+	 * not currently active. Restoring inactive queues later only
+	 * updates the is_evicted flag but is a no-op otherwise.
+	 */
+	q->properties.is_evicted = !!qpd->evicted;
  	mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj,
  				&q->gart_mqd_addr, &q->properties);
-	dqm_lock(dqm);
 
  	list_add(&q->list, &qpd->queues_list);
  	qpd->queue_count++;

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