Repository navigation
fix(sched/credit2): check the cap before changing the weight - #122
Merged
Merged
Conversation
alexandermerritt
requested review from
azenla,
bleggett,
kaniini,
sveith and
tycho
as code owners
November 19, 2026 17:57
alexandermerritt
marked this pull request as draft
November 19, 2026 17:59
XEN_DOMCTL_SCHEDOP_putinfo set the domain's weight first and only then checked the cap against 100 * nr_units. A request with a nonzero weight and a cap that is too high returned -EINVAL after the weight had changed, so a refused request still changed the domain. A caller cannot tell that from the error, and cannot retry without knowing the old weight. Check the cap before any change, under the same lock the check already took, so a refused request leaves the domain as it was. Signed-off-by: Alexander M. Merritt <[email protected]>
alexandermerritt
force-pushed
the
alexm/credit2-check-cap-first
branch
from
November 19, 2026 18:03
64067f9 to
aff2a02
Compare
alexandermerritt
marked this pull request as ready for review
November 19, 2026 18:03
antoineco
previously approved these changes
Nov 19, 2026
There was a problem hiding this comment.
PR Review
Reviewed at 3cb0d0e.
A refused credit2 putinfo now leaves the weight alone, and the hoisted check cannot fire when cap is 0, so weight-only requests and cap removal are unaffected. The new XTF test would fail against the old ordering. Nothing concerning.
Test Coverage
Reviewed at 3cb0d0e.
The new sched-credit2-cap-refused XTF test runs on the shipped x86_64 build as a PV and a PVH dom0 under credit2. It fails if a putinfo refused for its cap leaves dom0 at the new weight, and if the same request without a cap does not change it.
azenla
previously approved these changes
Nov 19, 2026
Nothing on a pull request issues XEN_DOMCTL_scheduler_op, so a putinfo that returns -EINVAL after it changed the domain's weight would reach a release unnoticed, as it did before the previous commit. Add an XTF test that sends dom0 a putinfo with a new weight and a cap no vCPU count can allow, and checks that it fails and that getinfo still reports the old weight. The same request with no cap must then change the weight, so a getinfo that never changes cannot pass. The test skips on a hypervisor that does not run credit2. XTF has no domctl header at the pinned commit, so the test defines the few structures it needs, as gnttab-copy-ops does. It runs as a PV and as a PVH dom0. Signed-off-by: Alexander M. Merritt <[email protected]>
alexandermerritt
dismissed stale reviews from azenla and antoineco
via
November 19, 2026 18:25
3cb0d0e
Contributor
Author
|
added a unit test in xtf |
bleggett
approved these changes
Nov 19, 2026
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.
part of ENG-172
Bug fix: scheduler parameter mutation happened before validating all parameters. The weight was updated prior to validating the cap value. We move the cap check ahead of the mutation.
We avoided this bug because our tooling validated the inputs first.
Supports https://github.com/edera-dev/protect/pull/5068