Repository navigation
Conversation
A VMM with VFIO devices releases them on its way out, and the host driver is slower at that when many guests go down at once. The grace after SIGTERM was fixed, so deleting 16 or more vGPU guests together hard-killed them mid-release and then failed most of the deletes about a second before the VMMs were gone, leaving the instances for a retry. The grace now grows by one second for every other VFIO teardown in flight, up to a minute. A guest terminated alone waits as before.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deleting 16 or more vGPU guests on one host at the same moment failed most of the deletes with a 500, about a second before their VMMs had exited. The grace a VMM with VFIO devices gets after SIGTERM now grows with the number of such teardowns in flight.
Why it happened
A delete asks the guest to shut down and waits up to 5 s, then sends the VMM SIGTERM and waits 5 s, then SIGKILL and two waits of 2 s. A VMM with VFIO devices releases them on its way out, and the host driver is slower at that when many go at once. On a host with two L40S, with 6 GB guests on a 3 GB vGPU profile, on a build of #552, which does not change how a delete stops the VMM:
SIGTERM goes out 5 s in, so the VMMs needed up to 10 s after it. SIGKILL followed at 10 s and the request gave up at 14 s. Kernel stacks sampled while they waited were in the vGPU driver, under
nv_vgpu_vfio_migration_set_stateandnv_vgpu_vfio_close; the kernel log showed no errors.Every failed delete succeeded on retry and no device was left behind. But 42 VMMs across the two forked batches were hard-killed while they were releasing their device, which is what the SIGTERM grace is there to prevent.
What changes
terminateThenKillcounts the VFIO teardowns in flight. The wait after SIGTERM is the configured grace plus one second for every other teardown in flight, capped at one minute, and it is re-evaluated while it waits, so a VMM that started exiting alone still gets the time when others join it. A guest terminated alone waits exactly as before. The SIGKILL waits are unchanged.Testing
TestKillHypervisorWaitsLongerWhileOtherVFIOTeardownsAreInFlight: a process that takes 0.6 s to exit after SIGTERM is hard-killed when it is alone with a 100 ms grace and exits cleanly when two other teardowns are in flight.TestKillHypervisorCountsVFIOTeardownsInFlight: two real teardowns, where the second one only gets its time because the first is counted. Four mutants (no allowance, an allowance when alone, a teardown that never joins the count, one that never leaves it) each fail one of them.No VMM was hard-killed and no device was left behind.
Not covered