Skip to content

Commit

Permalink
fix(qrm): align the core num reserved for reclaim to numa total count
Browse files Browse the repository at this point in the history
  • Loading branch information
luomingmeng committed Nov 1, 2024
1 parent 46e968b commit c570333
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions pkg/util/machine/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ func getCPUInstructionInfo(cpuInfo string) sets.String {

// GetCoreNumReservedForReclaim generates per numa reserved for reclaim resource value map.
// per numa reserved resource is taken in a fair way with even step, e.g.
// 4 -> 1 1 1 1; 2 -> 1 0 1 0
// 4 -> 1 1 1 1; 2 -> 1 1 1 1; 8 -> 2 2 2 2;
func GetCoreNumReservedForReclaim(numReservedCores, numNumaNodes int) map[int]int {
if numReservedCores <= 0 {
numReservedCores = 1
}
if numNumaNodes <= 0 {
numNumaNodes = 1
}

if numReservedCores < numNumaNodes {
numReservedCores = numNumaNodes
}

reservedPerNuma := numReservedCores / numNumaNodes
step := numNumaNodes / numReservedCores

Expand Down
12 changes: 9 additions & 3 deletions pkg/util/machine/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGetCoreNumReservedForReclaim(t *testing.T) {
name: "reserve 2",
numReservedCores: 2,
numNumaNodes: 4,
want: map[int]int{0: 1, 1: 0, 2: 1, 3: 0},
want: map[int]int{0: 1, 1: 1, 2: 1, 3: 1},
},
{
name: "reserve 3",
Expand All @@ -53,13 +53,19 @@ func TestGetCoreNumReservedForReclaim(t *testing.T) {
name: "reserve 0",
numReservedCores: 0,
numNumaNodes: 4,
want: map[int]int{0: 1, 1: 0, 2: 0, 3: 0},
want: map[int]int{0: 1, 1: 1, 2: 1, 3: 1},
},
{
name: "reserve 1",
numReservedCores: 1,
numNumaNodes: 4,
want: map[int]int{0: 1, 1: 0, 2: 0, 3: 0},
want: map[int]int{0: 1, 1: 1, 2: 1, 3: 1},
},
{
name: "reserve 8",
numReservedCores: 8,
numNumaNodes: 4,
want: map[int]int{0: 2, 1: 2, 2: 2, 3: 2},
},
}

Expand Down

0 comments on commit c570333

Please sign in to comment.