[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 がすでに取り組んでいます。
2026年11月24日 から。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C
- スター
- 472
- フォーク
- 153
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ROCm/amdgpu のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
似ている issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Life-Framework/Life-Framework#5378 ·
メンテナーはふだん 1 日以内に返信
-
Bug Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug status: planned ui
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ChupathingyCE/chupathingyce#2126 ·
メンテナーはふだん 1 日以内に返信
-
good first issue simulation
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
MarcosAsh/Lattice_Fluid_Dynamics#270 ·
メンテナーはふだん 1 日以内に返信
-
needs-kind
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
falcosecurity/libs#3173 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信