[BUG] KFD deadlock: profiler_lock and the DQM lock are taken in opposite orders (profiler release vs create_queue_cpsch), all of /dev/kfd hangs on MI355X with amdgpu-dkms 7.1.3
@benrichard-amd ci sta già lavorando.
Dal 24/11/2026.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 18/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- operating-systems
Direzione di ricerca
Start in amd/amdkfd/kfd_process.c at kfd_process_profiler_release() and in kfd_device_queue_manager.c at create_queue_cpsch()/set_perfcount(); the opposing profiler_lock read is in kfd_mqd_manager_v9.c and the _v10/_v11/_v12/_vi variants. Read both lock orders together and confirm with lockdep, since the reported reproduction needs an MI355X node plus rocpctl. Done means one order is removed (for example READ_ONCE or computing the flag before dqm_lock) without changing perfcount semantics.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
On a node with 8x AMD Instinct MI355X, amdgpu-dkms 7.1.3 deadlocked in KFD. After that, every open of /dev/kfd, every queue ioctl and every exit of a GPU process blocked in uninterruptible sleep, on all eight GPUs, until the node was rebooted. systemctl reboot itself took about 19 minutes to complete.
The cause is an ABBA lock inversion between kfd->profiler_lock and the device queue manager lock. Both orders are in the DKMS source, quoted below; one side is also in the kernel log.
Environment
- GPU: 8x AMD Instinct MI355X (gfx950), SR-IOV virtual functions inside a cloud VM ("AMD Instinct MI355X VF", device id 0x75b3)
- Driver:
amdgpu-dkms 1:7.1.3.31500000-2390945.24.04 - Kernel: 6.8.0-147-generic, Ubuntu 24.04
- ROCm userspace: 10.0.0 packages (
libamdhip64.so.7.15.26333) amd-metrics-exporterrunning on the host as shipped with the image (/usr/local/bin/amd-metrics-exporter -bind 127.0.0.1). It periodically runsrocpctl, which enables performance counters and so becomes KFD'sprofiler_process.
The two lock orders
A. profiler_lock, then the DQM lock (teardown of a process that enabled perf counters). amd/amdkfd/kfd_process.c:
static void kfd_process_profiler_release(struct kfd_process *p, struct kfd_process_device *pdd)
{
mutex_lock(&pdd->dev->kfd->profiler_lock);
if (pdd->dev->kfd->profiler_process == p) {
pdd->qpd.dqm->ops.set_perfcount(pdd->qpd.dqm, 0);
pdd->dev->kfd->profiler_process = NULL;
}
mutex_unlock(&pdd->dev->kfd->profiler_lock);
}
and set_perfcount() in kfd_device_queue_manager.c takes dqm_lock(dqm) to walk the queues.
B. the DQM lock, then profiler_lock (queue creation). create_queue_cpsch() in kfd_device_queue_manager.c calls mqd_mgr->init_mqd(...) between dqm_lock(dqm) and dqm_unlock(dqm), and init_mqd() in kfd_mqd_manager_v9.c does:
mutex_lock(&mm->dev->kfd->profiler_lock);
if (mm->dev->kfd->profiler_process != NULL)
m->compute_perfcount_enable = 1;
mutex_unlock(&mm->dev->kfd->profiler_lock);
The same block is in kfd_mqd_manager_v10.c, _v11.c, _v12.c and _vi.c.
So when a rocpctl process is torn down (A) while another process creates a compute queue on the same device (B), each holds the lock the other wants.
Kernel log
The first hung task the kernel reported is side A, on the release workqueue:
INFO: task kworker/u385:7:2793338 blocked for more than 122 seconds.
Tainted: G OE 6.8.0-147-generic
task:kworker/u385:7 state:D
Workqueue: kfd_process_wq kfd_process_wq_release [amdgpu]
Call Trace:
__schedule+0x27c/0x6b0
schedule+0x33/0x110
schedule_preempt_disabled+0x15/0x30
__mutex_lock.constprop.0+0x47f/0x790
__mutex_lock_slowpath+0x13/0x20
mutex_lock+0x3c/0x50
set_perfcount+0x7c/0x140 [amdgpu]
kfd_process_destroy_pdds+0x23f/0x2d0 [amdgpu]
kfd_process_wq_release+0x494/0x640 [amdgpu]
process_one_work+0x181/0x3a0
worker_thread+0x18b/0x330
kthread+0xef/0x120
The other tasks in the log are victims waiting for the DQM lock, for example on process exit:
INFO: task python:3045132 blocked for more than 122 seconds.
mutex_lock+0x3c/0x50
process_termination_cpsch+0x45/0x4b0 [amdgpu]
kfd_process_dequeue_from_device+0x3d/0xd0 [amdgpu]
kfd_process_dequeue_from_all_devices+0x36/0x70 [amdgpu]
kfd_process_notifier_release_internal+0xb8/0x310 [amdgpu]
kfd_process_notifier_release+0x1b/0x40 [amdgpu]
__mmu_notifier_release+0x7b/0x200
exit_mmap+0x3a2/0x3e0
and in kfd_ioctl_destroy_queue → pqm_destroy_queue, and amdgpu_amdkfd_evict_userptr → evict_process_queues_cpsch.
Side B was seen live in /proc/<pid>/stack of one process (create_queue_cpsch → init_mqd → mutex_lock), but I did not save that output and the kernel prints only the first ten hung tasks, so it is not in the log. The source above shows the order.
State when it happened
- 223 tasks in state
D: 218 user processes, 4rocpctl, onekfd_process_wqkworker. Load average about 224 with idle CPUs. - New HIP processes blocked in
kfd_ioctl_runtime_enableor on opening/dev/kfd. - SIGKILL had no effect on the blocked tasks.
How it was triggered
24 concurrent shell loops, each starting a short Python process that opens the GPU, creates queues, runs for about a second and exits (a test loop for an unrelated hang), spread over four of the eight GPUs, while the host's amd-metrics-exporter kept running rocpctl on its schedule. It had run for some time at 12 loops without the deadlock and hit it a few minutes after going to 24. I have not triggered it again on purpose, since it costs a node reboot, so I have no rate for it.
It needs only two things to coincide: a process that owns profiler_process exiting, and any other process creating a queue. Heavy process churn just makes the window likely.
Suggested direction
init_mqd() only reads whether a profiler process is set. Reading profiler_process without profiler_lock there (for example READ_ONCE), or deciding compute_perfcount_enable before dqm_lock is taken in create_queue_cpsch(), would remove order B. Alternatively kfd_process_profiler_release() could clear profiler_process under profiler_lock and call set_perfcount() after dropping it. I have not tested a patch.
Impact
Any node that runs the metrics exporter's profiler next to workloads that start and stop GPU processes often (CI, test suites, short jobs, sandboxes) can lose all its GPUs until reboot.
Workaround
Not running rocpctl/the exporter's profiler metrics on such nodes should avoid it, since profiler_process is then never set. I have not verified that.
The diagnosis was done with Claude Code on the affected node. The source excerpts and the log above are copied from that node's DKMS source tree and kernel journal.
- Lingua principale
- C
- Stelle
- 472
- Fork
- 153
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ROCm/amdgpu
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Issue simili
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Life-Framework/Life-Framework#5378 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug status: planned ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ChupathingyCE/chupathingyce#2126 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue simulation
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
MarcosAsh/Lattice_Fluid_Dynamics#270 ·
I maintainer di solito rispondono entro 1 giorno
-
needs-kind
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
falcosecurity/libs#3173 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno