From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Cc: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 19/27] drm/amdkfd: Fix a circular lock dependency
Date: Sun, 28 Apr 2019 07:44:16 +0000 [thread overview]
Message-ID: <20190428074331.30107-20-Felix.Kuehling@amd.com> (raw)
In-Reply-To: <20190428074331.30107-1-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
Fix a circular lock dependency exposed under userptr memory pressure.
The DQM lock is the only one taken inside the MMU notifier. We need
to make sure that no reclaim is done under this lock, and that
no other locks are taken under which reclaim is possible.
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
---
.../drm/amd/amdkfd/kfd_device_queue_manager.c | 33 ++++++++++++++++---
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 1562590d837e..0bfdb141b6e7 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -794,10 +794,14 @@ static int register_process(struct device_queue_manager *dqm,
retval = dqm->asic_ops.update_qpd(dqm, qpd);
dqm->processes_count++;
- kfd_inc_compute_active(dqm->dev);
dqm_unlock(dqm);
+ /* Outside the DQM lock because under the DQM lock we can't do
+ * reclaim or take other locks that others hold while reclaiming.
+ */
+ kfd_inc_compute_active(dqm->dev);
+
return retval;
}
@@ -818,7 +822,6 @@ static int unregister_process(struct device_queue_manager *dqm,
list_del(&cur->list);
kfree(cur);
dqm->processes_count--;
- kfd_dec_compute_active(dqm->dev);
goto out;
}
}
@@ -826,6 +829,13 @@ static int unregister_process(struct device_queue_manager *dqm,
retval = 1;
out:
dqm_unlock(dqm);
+
+ /* Outside the DQM lock because under the DQM lock we can't do
+ * reclaim or take other locks that others hold while reclaiming.
+ */
+ if (!retval)
+ kfd_dec_compute_active(dqm->dev);
+
return retval;
}
@@ -1519,6 +1529,7 @@ static int process_termination_nocpsch(struct device_queue_manager *dqm,
struct queue *q, *next;
struct device_process_node *cur, *next_dpn;
int retval = 0;
+ bool found = false;
dqm_lock(dqm);
@@ -1537,12 +1548,19 @@ static int process_termination_nocpsch(struct device_queue_manager *dqm,
list_del(&cur->list);
kfree(cur);
dqm->processes_count--;
- kfd_dec_compute_active(dqm->dev);
+ found = true;
break;
}
}
dqm_unlock(dqm);
+
+ /* Outside the DQM lock because under the DQM lock we can't do
+ * reclaim or take other locks that others hold while reclaiming.
+ */
+ if (found)
+ kfd_dec_compute_active(dqm->dev);
+
return retval;
}
@@ -1588,6 +1606,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
struct device_process_node *cur, *next_dpn;
enum kfd_unmap_queues_filter filter =
KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES;
+ bool found = false;
retval = 0;
@@ -1624,7 +1643,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
list_del(&cur->list);
kfree(cur);
dqm->processes_count--;
- kfd_dec_compute_active(dqm->dev);
+ found = true;
break;
}
}
@@ -1638,6 +1657,12 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
dqm_unlock(dqm);
+ /* Outside the DQM lock because under the DQM lock we can't do
+ * reclaim or take other locks that others hold while reclaiming.
+ */
+ if (found)
+ kfd_dec_compute_active(dqm->dev);
+
/* Lastly, free mqd resources.
* Do uninit_mqd() after dqm_unlock to avoid circular locking.
*/
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-04-28 7:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-28 7:44 [PATCH 00/27] KFD upstreaming Kuehling, Felix
[not found] ` <20190428074331.30107-1-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2019-04-28 7:44 ` [PATCH 01/27] drm/amdkfd: Use 64 bit sdma_bitmap Kuehling, Felix
2019-04-28 7:44 ` [PATCH 02/27] drm/amdkfd: Add sdma allocation debug message Kuehling, Felix
2019-04-28 7:44 ` [PATCH 03/27] drm/amdkfd: Differentiate b/t sdma_id and sdma_queue_id Kuehling, Felix
2019-04-28 7:44 ` [PATCH 05/27] drm/amdkfd: Fix a potential memory leak Kuehling, Felix
2019-04-28 7:44 ` [PATCH 04/27] drm/amdkfd: Shift sdma_engine_id and sdma_queue_id in mqd Kuehling, Felix
2019-04-28 7:44 ` [PATCH 06/27] drm/amdkfd: Introduce asic-specific mqd_manager_init function Kuehling, Felix
2019-04-28 7:44 ` [PATCH 08/27] drm/amdkfd: Init mqd managers in device queue manager init Kuehling, Felix
2019-04-28 7:44 ` [PATCH 07/27] drm/amdkfd: Introduce DIQ type mqd manager Kuehling, Felix
2019-04-28 7:44 ` [PATCH 09/27] drm/amdkfd: Add mqd size in mqd manager struct Kuehling, Felix
2019-04-28 7:44 ` [PATCH 10/27] drm/amdkfd: Allocate MQD trunk for HIQ and SDMA Kuehling, Felix
2019-04-28 7:44 ` [PATCH 12/27] drm/amdkfd: Allocate hiq and sdma mqd from mqd trunk Kuehling, Felix
2019-04-28 7:44 ` [PATCH 11/27] drm/amdkfd: Move non-sdma mqd allocation out of init_mqd Kuehling, Felix
2019-04-28 7:44 ` [PATCH 13/27] drm/amdkfd: Move sdma_queue_id calculation into allocate_sdma_queue() Kuehling, Felix
2019-04-28 7:44 ` [PATCH 15/27] drm/amdkfd: Fix sdma queue map issue Kuehling, Felix
2019-04-28 7:44 ` [PATCH 14/27] drm/amdkfd: Fix compute profile switching Kuehling, Felix
2019-04-28 7:44 ` [PATCH 16/27] drm/amdkfd: Introduce XGMI SDMA queue type Kuehling, Felix
2019-04-28 7:44 ` [PATCH 17/27] drm/amdkfd: Expose sdma engine numbers to topology Kuehling, Felix
2019-04-28 7:44 ` [PATCH 18/27] drm/amdkfd: Delete alloc_format field from map_queue struct Kuehling, Felix
2019-04-28 7:44 ` Kuehling, Felix [this message]
2019-04-28 7:44 ` [PATCH 20/27] drm/amdkfd: Fix gfx8 MEM_VIOL exception handler Kuehling, Felix
2019-04-28 7:44 ` [PATCH 22/27] drm/amdkfd: Fix gfx9 XNACK state save/restore Kuehling, Felix
2019-04-28 7:44 ` [PATCH 21/27] drm/amdkfd: Preserve wave state after instruction fetch MEM_VIOL Kuehling, Felix
2019-04-28 7:44 ` [PATCH 23/27] drm/amdkfd: Preserve ttmp[4:5] instead of ttmp[14:15] Kuehling, Felix
2019-04-28 7:44 ` [PATCH 25/27] drm/amdkfd: Add domain number into gpu_id Kuehling, Felix
2019-04-28 7:44 ` [PATCH 24/27] drm/amdkfd: Add VegaM support Kuehling, Felix
2019-04-28 7:44 ` [PATCH 26/27] drm/amdgpu: Use heavy weight for tlb invalidation on xgmi configuration Kuehling, Felix
2019-04-28 7:44 ` [PATCH 27/27] drm/amdgpu: Fix GTT size calculation Kuehling, Felix
[not found] ` <20190428074331.30107-28-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2019-04-29 12:34 ` Christian König
[not found] ` <86fa9fc3-7a8f-9855-ae1d-5c7ccf2b5260-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-04-29 23:16 ` Kuehling, Felix
[not found] ` <1b1ec993-1c4b-8661-9b3f-ac0ad8ae64c7-5C7GfCeVMHo@public.gmane.org>
2019-04-30 9:32 ` Christian König
[not found] ` <134a4999-776f-44c6-99a2-42e8b9366a73-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-04-30 15:36 ` Kuehling, Felix
[not found] ` <9f882acd-c48f-3bbd-2d90-659c2edead39-5C7GfCeVMHo@public.gmane.org>
2019-04-30 17:03 ` Koenig, Christian
[not found] ` <f5c698ad-2aff-b3c5-2041-05a10983438a-5C7GfCeVMHo@public.gmane.org>
2019-04-30 17:25 ` Kuehling, Felix
[not found] ` <8ba952ab-4836-4ca3-cd80-99f7367a7979-5C7GfCeVMHo@public.gmane.org>
2019-05-02 13:06 ` Koenig, Christian
2019-07-13 20:24 ` Felix Kuehling
2019-04-29 23:23 ` [PATCH 00/27] KFD upstreaming Kuehling, Felix
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=20190428074331.30107-20-Felix.Kuehling@amd.com \
--to=felix.kuehling-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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