Skip to content

Commit

Permalink
feat(qrm): allowSharedCoresOverlapReclaimedCores is true, take all no…
Browse files Browse the repository at this point in the history
…nBindingAvailableCPUs for pools
  • Loading branch information
csfldf committed Jun 29, 2024
1 parent ee0c3b8 commit f2c9b72
Showing 1 changed file with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1168,18 +1168,38 @@ func (p *DynamicPolicy) generatePoolsAndIsolation(poolsQuantityMap map[string]ma
return
}

nonBindingAvailableCPUs, tErr = p.takeCPUsForPoolsInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)
if tErr != nil {
err = fmt.Errorf("allocate cpus for pools failed with error: %v", tErr)
return
if !p.state.GetAllowSharedCoresOverlapReclaimedCores() {
nonBindingAvailableCPUs, tErr = p.takeCPUsForPoolsInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)
if tErr != nil {
err = fmt.Errorf("allocate cpus for pools failed with error: %v", tErr)
return
}
} else {
general.Infof("allowSharedCoresOverlapReclaimedCores is true, take all nonBindingAvailableCPUs for pools")
nonBindingAvailableCPUs, tErr = p.generateProportionalPoolsCPUSetInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)

if tErr != nil {
err = fmt.Errorf("generateProportionalPoolsCPUSetInPlace pools failed with error: %v", tErr)
return
}
}
} else if nonBindingPoolsTotalQuantity <= nonBindingAvailableSize {
general.Infof("all pools could be allocated, all isolated containers would be put to pools")

nonBindingAvailableCPUs, tErr = p.takeCPUsForPoolsInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)
if tErr != nil {
err = fmt.Errorf("allocate cpus for pools failed with error: %v", tErr)
return
if !p.state.GetAllowSharedCoresOverlapReclaimedCores() {
nonBindingAvailableCPUs, tErr = p.takeCPUsForPoolsInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)
if tErr != nil {
err = fmt.Errorf("allocate cpus for pools failed with error: %v", tErr)
return
}
} else {
general.Infof("allowSharedCoresOverlapReclaimedCores is true, take all nonBindingAvailableCPUs for pools")
nonBindingAvailableCPUs, tErr = p.generateProportionalPoolsCPUSetInPlace(nonBindingPoolsQuantityMap, poolsCPUSet, nonBindingAvailableCPUs)

if tErr != nil {
err = fmt.Errorf("generateProportionalPoolsCPUSetInPlace pools failed with error: %v", tErr)
return
}
}
} else if nonBindingPoolsTotalQuantity > 0 {
general.Infof("can't allocate for all pools")
Expand Down Expand Up @@ -1207,19 +1227,6 @@ func (p *DynamicPolicy) generatePoolsAndIsolation(poolsQuantityMap map[string]ma
poolsCPUSet[state.PoolNameReclaim] = poolsCPUSet[state.PoolNameReclaim].Union(availableCPUs)

if !p.state.GetAllowSharedCoresOverlapReclaimedCores() {
if poolsCPUSet[state.PoolNameReclaim].IsEmpty() {
// for reclaimed pool, we must make them exist when the node isn't in hybrid mode even if cause overlap
allAvailableCPUs := p.machineInfo.CPUDetails.CPUs().Difference(p.reservedCPUs)
reclaimedCPUSet, _, tErr := calculator.TakeByNUMABalance(p.machineInfo, allAvailableCPUs, reservedReclaimedCPUsSize)
if tErr != nil {
err = fmt.Errorf("fallback takeByNUMABalance faild in generatePoolsAndIsolation for reclaimedCPUSet with error: %v", tErr)
return
}

general.Infof("fallback takeByNUMABalance in generatePoolsAndIsolation for reclaimedCPUSet: %s", reclaimedCPUSet.String())
poolsCPUSet[state.PoolNameReclaim] = reclaimedCPUSet
}

enableReclaim := p.dynamicConfig.GetDynamicConfiguration().EnableReclaim
if !enableReclaim && poolsCPUSet[state.PoolNameReclaim].Size() > reservedReclaimedCPUsSize {
poolsCPUSet[state.PoolNameReclaim] = p.apportionReclaimedPool(
Expand Down Expand Up @@ -1249,6 +1256,19 @@ func (p *DynamicPolicy) generatePoolsAndIsolation(poolsQuantityMap map[string]ma
}
}

if poolsCPUSet[state.PoolNameReclaim].IsEmpty() {
// for reclaimed pool, we must make them exist when the node isn't in hybrid mode even if cause overlap
allAvailableCPUs := p.machineInfo.CPUDetails.CPUs().Difference(p.reservedCPUs)
reclaimedCPUSet, _, tErr := calculator.TakeByNUMABalance(p.machineInfo, allAvailableCPUs, reservedReclaimedCPUsSize)
if tErr != nil {
err = fmt.Errorf("fallback takeByNUMABalance faild in generatePoolsAndIsolation for reclaimedCPUSet with error: %v", tErr)
return
}

general.Infof("fallback takeByNUMABalance in generatePoolsAndIsolation for reclaimedCPUSet: %s", reclaimedCPUSet.String())
poolsCPUSet[state.PoolNameReclaim] = reclaimedCPUSet
}

return
}

Expand Down

0 comments on commit f2c9b72

Please sign in to comment.