Repository navigation
vmspawn: let SetMemory() report progress with 'more' - #44403
katexochen wants to merge 2 commits into
Conversation
|
Reviewed 6797b73 (architecture, correctness, lifetimes, security, style, tests). Suggestions
Nits
|
With the 'more' flag, SetMemory() notifies the caller whenever the guest's balloon moves and replies once the guest reached the target, or once the size did not change for five seconds, since partial convergence is normal. A newer request ends a pending call with the new Superseded error. The reply now also carries the effective target and the current size. Signed-off-by: Paul Meyer <katexochen0@gmail.com>
Wait for convergence through SetMemory() with 'more' instead of polling Describe(), except for the first shrink, where the guest may not have loaded its balloon driver yet. Also check that a newer request ends a pending call with Superseded. Signed-off-by: Paul Meyer <katexochen0@gmail.com>
d491f8a to
6797b73
Compare
| /* Also end the call once the guest moves away from the target, e.g. on deflate-on-oom, so that | ||
| * a guest moving its balloon back and forth cannot hold it open forever. */ | ||
| if (actual == m->target || | ||
| (previous > 0 && ABS_DIFF(actual, m->target) >= ABS_DIFF(previous, m->target))) { |
There was a problem hiding this comment.
Claude: suggestion: previous is from before the new target. If a 'more' call reverses direction while the guest is still moving toward the old target, the next BALLOON_CHANGE can still be a step away from the new one: an in-flight balloon batch, or an event QEMU throttled up to 1s. The call then ends at once, short of the target. Only run the moved-away check after a first step toward the new target.
There was a problem hiding this comment.
valid, but let's rather try to keep the mechanism simple for now. I think there are a lot of corner cases here, but I want to postpone handling every single one to the point where the code is a bit more stable. Ending the more call early isn't that bad of a failure mode for something experimental.
Follow-up to #44318, as suggested in its review: instead of polling
Describe() to see whether the guest followed a SetMemory() request,
callers can now pass 'more' and get a notification whenever the
guest's balloon moves, then a final reply once it reached the target.
Partial convergence is normal (unmovable pages, deflate-on-oom), so a
call also ends with a final reply once the size did not change for
five seconds; the caller compares targetBytes and actualBytes. A newer
request ends a still pending call with the new Superseded error.
Without 'more' the call behaves as before, but its reply now carries
the effective target and the current size, since vmspawn rounds the
requested size up to 64 KiB.
TEST-97 now waits through 'more' and covers the Superseded path, using
a paused VM so the pending call cannot complete first.