Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topology-aware: exclude isolated CPUs from policy-picked reserved cpusets. #474

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions cmd/plugins/topology-aware/policy/topology-aware-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,17 @@ func (p *policy) checkConstraints() error {
"part of the online allowed cpuset (%s)", p.reserved,
p.reserved.Difference(p.allowed), p.allowed)
}
// check that none of the reserved CPUs are isolated
if !p.reserved.Intersection(p.isolated).IsEmpty() {
return policyError("invalid reserved cpuset %s, some CPUs (%s) are also isolated",
p.reserved.Intersection(p.isolated))
// check that if any reserved CPUs are isolated, it is the sole reserved CPU
if isolated := p.reserved.Intersection(p.isolated); !isolated.IsEmpty() {
if !p.reserved.Equals(isolated) {
return policyError("invalid reserved cpuset %s, mixes isolated (%s) and normal (%s)",
p.reserved, isolated, p.reserved.Difference(isolated))
}
if isolated.Size() > 1 {
return policyError("invalid reserved cpuset %s, multiple isolated CPUs (%s)",
p.reserved, isolated)
}
log.Warnf("reserved CPU %s is isolated", p.reserved)
}

case cfgapi.AmountQuantity:
Expand All @@ -570,11 +577,11 @@ func (p *policy) checkConstraints() error {
}

p.reserveCnt = (int(qty.MilliValue()) + 999) / 1000
// Use CpuAllocator to pick reserved CPUs among
// allowed ones. Because using those CPUs is allowed,
// they remain (they are put back) in the allowed set.
cset, err := p.cpuAllocator.AllocateCpus(&p.allowed, p.reserveCnt, normalPrio.Option())
p.allowed = p.allowed.Union(cset)
// Use CpuAllocator to pick reserved CPUs from the allowed ones but
// avoiding isolated CPUs. The picked CPUs are not removed from the
// allowed set.
from := p.allowed.Difference(p.isolated)
cset, err := p.cpuAllocator.AllocateCpus(&from, p.reserveCnt, normalPrio.Option())
if err != nil {
log.Fatal("cannot reserve %dm CPUs for ReservedResources from AvailableResources: %s", qty.MilliValue(), err)
}
Expand All @@ -585,6 +592,8 @@ func (p *policy) checkConstraints() error {
return policyError("cannot start without CPU reservation")
}

log.Infof("using reserved cpuset %s", p.reserved)

return nil
}

Expand Down
Loading