Skip to content

Commit df45505

Browse files
authored
Merge pull request #656 from cheney-lin/fix/pool_size
fix(sysadvisor): fix isolacted size calculated incorrectly
2 parents d5ebb56 + 0807cf1 commit df45505

File tree

2 files changed

+83
-4
lines changed

2 files changed

+83
-4
lines changed

pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,24 @@ func (pa *ProvisionAssemblerCommon) AssembleProvision() (types.InternalCPUCalcul
171171
// If there is a SNB pool with the same NUMA ID, it will be calculated while processing the SNB pool.
172172
if shareRegions := pa.regionHelper.GetRegions(regionNuma, configapi.QoSRegionTypeShare); len(shareRegions) == 0 {
173173
calculationResult.SetPoolEntry(r.Name(), regionNuma, int(controlKnob[configapi.ControlKnobNonReclaimedCPURequirementUpper].Value))
174+
175+
_, ok := calculationResult.GetPoolEntry(state.PoolNameReclaim, regionNuma)
176+
if !ok {
177+
available := getNUMAsResource(*pa.numaAvailable, r.GetBindingNumas())
178+
reservedForReclaim := getNUMAsResource(*pa.reservedForReclaim, r.GetBindingNumas())
179+
180+
isolationRegions := pa.regionHelper.GetRegions(regionNuma, configapi.QoSRegionTypeIsolation)
181+
isolationSizes := 0
182+
for _, ir := range isolationRegions {
183+
ck, err := ir.GetProvision()
184+
if err != nil {
185+
return types.InternalCPUCalculationResult{}, err
186+
}
187+
isolationSizes += int(ck[configapi.ControlKnobNonReclaimedCPURequirementUpper].Value)
188+
}
189+
reclaimedCoresSize := general.Max(available-isolationSizes, 0) + reservedForReclaim
190+
calculationResult.SetPoolEntry(state.PoolNameReclaim, regionNuma, reclaimedCoresSize)
191+
}
174192
}
175193
} else {
176194
// save limits and requests for isolated region
@@ -242,12 +260,17 @@ func (pa *ProvisionAssemblerCommon) AssembleProvision() (types.InternalCPUCalcul
242260

243261
var reclaimPoolSizeOfNonBindingNUMAs int
244262
if *pa.allowSharedCoresOverlapReclaimedCores {
245-
isolated := shareAndIsolatedPoolAvailable
263+
isolated := 0
246264
sharePoolSizes := make(map[string]int)
247-
for poolName := range sharePoolRequirements {
248-
sharePoolSizes[poolName] = shareAndIsolatePoolSizes[poolName]
249-
isolated -= shareAndIsolatePoolSizes[poolName]
265+
for poolName, size := range shareAndIsolatePoolSizes {
266+
_, ok := sharePoolRequirements[poolName]
267+
if ok {
268+
sharePoolSizes[poolName] = shareAndIsolatePoolSizes[poolName]
269+
} else {
270+
isolated += size
271+
}
250272
}
273+
251274
reclaimPoolSizeOfNonBindingNUMAs = general.Max(pa.getNumasReservedForReclaim(*pa.nonBindingNumas), shareAndIsolatedPoolAvailable-isolated-general.SumUpMapValues(sharePoolRequirements))
252275
if !nodeEnableReclaim {
253276
reclaimPoolSizeOfNonBindingNUMAs = pa.getNumasReservedForReclaim(*pa.nonBindingNumas)

pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,20 @@ func TestAssembleProvision(t *testing.T) {
810810
"reclaim": {-1: map[string]int{"share": 18}, 1: map[string]int{"share-NUMA1": 4}},
811811
},
812812
},
813+
{
814+
name: "no share pool and isolated pool, allow shared_cores overlap reclaimed_cores",
815+
enableReclaimed: true,
816+
allowSharedCoresOverlapReclaimedCores: true,
817+
poolInfos: []testCasePoolConfig{},
818+
expectPoolEntries: map[string]map[int]int{
819+
"reserve": {
820+
-1: 0,
821+
},
822+
"reclaim": {
823+
-1: 48,
824+
},
825+
},
826+
},
813827
{
814828
name: "share and isolated pool not throttled, overlap reclaimed cores, reclaim disabled",
815829
enableReclaimed: false,
@@ -879,6 +893,48 @@ func TestAssembleProvision(t *testing.T) {
879893
"reclaim": {-1: map[string]int{"share": 4}, 1: map[string]int{"share-NUMA1": 4}},
880894
},
881895
},
896+
{
897+
name: "isolated pools only, with numa binding",
898+
enableReclaimed: true,
899+
allowSharedCoresOverlapReclaimedCores: true,
900+
poolInfos: []testCasePoolConfig{
901+
{
902+
poolName: "isolation-NUMA1",
903+
poolType: configapi.QoSRegionTypeIsolation,
904+
numa: machine.NewCPUSet(1),
905+
isNumaBinding: true,
906+
provision: types.ControlKnob{
907+
configapi.ControlKnobNonReclaimedCPURequirementUpper: {Value: 8},
908+
configapi.ControlKnobNonReclaimedCPURequirementLower: {Value: 4},
909+
},
910+
},
911+
{
912+
poolName: "isolation-NUMA1-pod2",
913+
poolType: configapi.QoSRegionTypeIsolation,
914+
numa: machine.NewCPUSet(1),
915+
isNumaBinding: true,
916+
provision: types.ControlKnob{
917+
configapi.ControlKnobNonReclaimedCPURequirementUpper: {Value: 8},
918+
configapi.ControlKnobNonReclaimedCPURequirementLower: {Value: 4},
919+
},
920+
},
921+
},
922+
expectPoolEntries: map[string]map[int]int{
923+
"isolation-NUMA1": {
924+
1: 8,
925+
},
926+
"isolation-NUMA1-pod2": {
927+
1: 8,
928+
},
929+
"reserve": {
930+
-1: 0,
931+
},
932+
"reclaim": {
933+
1: 8,
934+
-1: 24,
935+
},
936+
},
937+
},
882938
{
883939
name: "share and bach pool non binding NUMAs, overlap reclaimed cores",
884940
enableReclaimed: true,

0 commit comments

Comments
 (0)