mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #74859 from ahadas/static_policy
kubelet/cm: code optimization for the static policy
This commit is contained in:
commit
a5a70b4de3
@ -158,25 +158,31 @@ func takeByTopology(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, num
|
|||||||
// Algorithm: topology-aware best-fit
|
// Algorithm: topology-aware best-fit
|
||||||
// 1. Acquire whole sockets, if available and the container requires at
|
// 1. Acquire whole sockets, if available and the container requires at
|
||||||
// least a socket's-worth of CPUs.
|
// least a socket's-worth of CPUs.
|
||||||
for _, s := range acc.freeSockets() {
|
|
||||||
if acc.needs(acc.topo.CPUsPerSocket()) {
|
if acc.needs(acc.topo.CPUsPerSocket()) {
|
||||||
|
for _, s := range acc.freeSockets() {
|
||||||
klog.V(4).Infof("[cpumanager] takeByTopology: claiming socket [%d]", s)
|
klog.V(4).Infof("[cpumanager] takeByTopology: claiming socket [%d]", s)
|
||||||
acc.take(acc.details.CPUsInSocket(s))
|
acc.take(acc.details.CPUsInSocket(s))
|
||||||
if acc.isSatisfied() {
|
if acc.isSatisfied() {
|
||||||
return acc.result, nil
|
return acc.result, nil
|
||||||
}
|
}
|
||||||
|
if !acc.needs(acc.topo.CPUsPerSocket()) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Acquire whole cores, if available and the container requires at least
|
// 2. Acquire whole cores, if available and the container requires at least
|
||||||
// a core's-worth of CPUs.
|
// a core's-worth of CPUs.
|
||||||
for _, c := range acc.freeCores() {
|
|
||||||
if acc.needs(acc.topo.CPUsPerCore()) {
|
if acc.needs(acc.topo.CPUsPerCore()) {
|
||||||
|
for _, c := range acc.freeCores() {
|
||||||
klog.V(4).Infof("[cpumanager] takeByTopology: claiming core [%d]", c)
|
klog.V(4).Infof("[cpumanager] takeByTopology: claiming core [%d]", c)
|
||||||
acc.take(acc.details.CPUsInCore(c))
|
acc.take(acc.details.CPUsInCore(c))
|
||||||
if acc.isSatisfied() {
|
if acc.isSatisfied() {
|
||||||
return acc.result, nil
|
return acc.result, nil
|
||||||
}
|
}
|
||||||
|
if !acc.needs(acc.topo.CPUsPerCore()) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ func TestTakeByTopology(t *testing.T) {
|
|||||||
cpuset.NewCPUSet(2, 6),
|
cpuset.NewCPUSet(2, 6),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"take three cpus from dual socket with HT - core from Socket 0",
|
"take one cpu from dual socket with HT - core from Socket 0",
|
||||||
topoDualSocketHT,
|
topoDualSocketHT,
|
||||||
cpuset.NewCPUSet(1, 2, 3, 4, 5, 7, 8, 9, 10, 11),
|
cpuset.NewCPUSet(1, 2, 3, 4, 5, 7, 8, 9, 10, 11),
|
||||||
1,
|
1,
|
||||||
|
Loading…
Reference in New Issue
Block a user