drm/amdgpu: add amdgpu_vm_update_leaves()
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Olivier,
Quoted 25 lines · Olivier Kaloudoff
Hi Christian,
Quoted 7 lines · Christian König
thanks for the testing, but you are looking at outdated code.
I was initially only testing with 2MiB pages and didn't see that issue, it is already fixed in what I've send out on Friday.
Can you give that version another round of testing? The would be great.
Makes sense — with 2MiB mappings the leaf-level writes dominate and the non-leaf gap slot case barely gets exercised. Our SVM workload (eviction/restore churn under memory pressure) hits it reliably because it creates exactly the pattern that breaks: an unmapped gap followed by still-linked sibling subtrees in the same parent PD.
I just read the v2 series (the 9-patch set from the 28th) — the reworked
amdgpu_vm_pt_leaves()in patch 4/9 looks right: walking forward and accumulating only consecutive entries that have no leaf in the same parent is strictly better than the one-entry clamp we used locally, since it still batches genuine gaps. And patch 2/9 explains the other half of what we observed in RAM — the PDE_PTE-only marker (0x40000000000000) in the clobbered slots lines up with the cleared-flag generation fix.
Quoted 4 lines
Happy to re-test. I'll apply the 9-patch series on top of our 7.2.6 tree and re-run the reproducer (vLLM/ROCm checkpoint staging on the MI50 — previously a deterministic fault at the same stage on every run). Will report back on the new thread.
I'm about to send out v3 of the series which can also be found here: https://gitlab.freedesktop.org/ckoenig/linux-drm/-/commits/amd-vm-svm
It's based on the latest amd-staging-drm-next development branch. I have no idea if that will even apply to 7.2.6.
Quoted 7 lines
Two unrelated findings from the same debugging session, FYI — I'll send them as separate mails rather than polluting this thread:
*
amdgpu_vm_finiNULL pointer dereference when the eGPU is surprise- removed while a compute VM is being torn down (TB3 link drop under load). Sibling of ateardown_processesNULL deref we already patched locally.
Interesting, we should have test cases for that since that is a rather common use case now.
If you could give a bit more data (e.g. what timing) then Vitaly will probably be able to create a CI test case for that.
Quoted 2 lines
* (older, on vanilla kernels too) the SVM restore-worker livelock under sustained reclaim — separate mail already in preparation.
Yeah that is already very well known problem.
The old KFD SVM code has a whole bunch of design bugs. Because of that we are working on completely replacing that with a new implementation based on the drm_gpusvm component.
This patch set here is a per-requisite to that which fixes only one bug in the existing KFD implementation.
Regards,
Christian.
Quoted 3 lines
Regards,
Olivier
Olivier Kaloudoff
Tested-byHi Christian,
Quoted 2 lines
It's based on the latest amd-staging-drm-next development branch. I have no idea if that will even apply to 7.2.6.
It did, with a small compat layer (begin/end_critical naming, hmm_range field plumbing, trace arg order, NUM_LEVELS). Re-test results on gfx906 (MI50 32GB, Vega 20, TB3 eGPU), kernel 7.2.6 + your Sep-30 8-patch set including amdgpu_vm_pt_leaves() v3:
- The gap-slot overshoot regression I reported on 06/13 is gone.
- The previously *deterministic* reproducer (vLLM/ROCm staging a 10-shard GLM-4-9B, i.e. heavy SVM map/unmap/evict/restore churn) now runs to completion.
- Sustained sessions with llama.cpp (qwen3-32b, 2 parallel slots) plus batch inference workers: zero "STALE PDE", zero bo_update failures, zero MMHUB faults.
So for the series:
The one remaining crash signature we've seen since is unrelated to the VM rework: the TB3 link drops under sustained ~100 degC junction load (Razer Core X thermal/electrical marginality), which is the surprise removal path below.
Quoted 2 lines
If you could give a bit more data (e.g. what timing) then Vitaly will probably be able to create a CI test case for that.
Here is a captured timeline (EFI pstore, 7.2.6-k726). Two independent drops produced byte-identical stack shapes; this is the cleaner one:
t+0.000 amdgpu 05:00.0: Failed to send message 0x19, response 0xffffffff
(SMU already gone - link electrically dead)
t+0.001 thunderbolt 0-2: device disconnected t+0.11 "finishing device", amdgpu_job_timedout skips recovery t+0.44 thunderbolt 0-2: Razer Core X found again (link flapped) t+1.21 thunderbolt 0-2: device disconnected (gone for good) t+9.38 qcm fence wait timeout -> GPU reset begin ->
"device lost from bus!", reset ret -19
t+9.63 ring kiq test fails; WARNING in kfd DQM uninitialize
(queues still attached to the dead device)
t+9.63 kgd2kfd_device_exit() frees adev->kfd.dev
<- amdgpu_amdkfd_device_fini_sw
<- amdgpu_device_fini_hw <- pciehp_unconfigure_device <- pciehp_disable_slot <- pciehp_ist (irq/39-pciehp)
t+9.64 BUG: NULL deref at 0x1b4, kgd2kfd_teardown_processes+0xde
same pciehp_ist thread, ~3ms after kfd.dev was freed.
So no race is needed for CI: within amdgpu_device_fini_hw(), device_fini_sw runs kgd2kfd_device_exit() (which releases kfd.dev) *before* amdgpu_amdkfd_teardown_processes() runs - it dereferences the already-freed pointer unconditionally when KFD processes are attached. An igt-side equivalent would be: open KFD queues on a device, hot-unplug the parent (or kset unregister), expect teardown_processes on a live kfd.dev. In our case llama-server/vLLM held the queues.
Local workaround we carry (happy to post properly if useful):
guard adev->kfd.dev for NULL in kgd2kfd_teardown_processes() and bound the "wait for process count" loop (30s) so pciehp can't wedge forever on a dead device. Same spirit in the userptr/VM update paths: fail fast with -ENODEV once the device is unplugged.
Quoted 4 lines
Yeah that is already very well known problem. The old KFD SVM code has a whole bunch of design bugs. Because of that we are working on completely replacing that with a new implementation based on the
drm_gpusvmcomponent.
Acknowledged, that matches what we see. Happy to keep exercising the interim fixes on gfx906 and to run the drm_gpusvm series once it's usable - this machine produces SVM invalidation churn (evict/restore under real memory pressure) more reliably than anything else I have.
Regards,
Olivier