Skip to content

Commit f83bac6

Browse files
tedyuyutedz
authored andcommitted
Obtain unsorted slice in cpuAccumulator#freeCores
1 parent 1608578 commit f83bac6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/kubelet/cm/cpumanager/cpu_assignment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (a *cpuAccumulator) freeSockets() []int {
6969
// - socket ID, ascending
7070
// - core ID, ascending
7171
func (a *cpuAccumulator) freeCores() []int {
72-
socketIDs := a.details.Sockets().ToSlice()
72+
socketIDs := a.details.Sockets().ToSliceNoSort()
7373
sort.Slice(socketIDs,
7474
func(i, j int) bool {
7575
iCores := a.details.CoresInSocket(socketIDs[i]).Filter(a.isCoreFree)

pkg/kubelet/cm/cpuset/cpuset.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ func (s CPUSet) ToSlice() []int {
172172
return result
173173
}
174174

175+
// ToSliceNoSort returns a slice of integers that contains all elements from
176+
// this set.
177+
func (s CPUSet) ToSliceNoSort() []int {
178+
result := []int{}
179+
for cpu := range s.elems {
180+
result = append(result, cpu)
181+
}
182+
return result
183+
}
184+
175185
// String returns a new string representation of the elements in this CPU set
176186
// in canonical linux CPU list format.
177187
//

0 commit comments

Comments
 (0)