Enhance isolcpus support in Kubernetes to allocate isolated SMT
siblings to the same container when SMT/HT is enabled on the host.
As it stands, the device manager code in Kubernetes is not SMT-aware
(since normally it doesn't deal with CPUs). However, StarlingX
exposes isolated CPUs as devices and if possible we want to allocate
all SMT siblings from a CPU core to the same container in order to
minimize cross- container interference due to resource contention
within the CPU core.
The solution is basically to take the list of isolated CPUs and
re-order it so that the SMT siblings are next to each other. That
way the existing resource selection code will allocate the siblings
together. As an optimization, if it is known that an odd number
of isolated CPUs are desired, a singleton SMT sibling will be
inserted into the list to avoid breaking up sibling pairs.
Test Plan:
Tested with AIO-SX HT enabled and disabled (disabled will not
run the code). Test results below are with HT enabled.
Platform cpu layout:
Socket 0 Socket 1
-------- --------
Core 0 [0, 16] [8, 24]
Core 1 [1, 17] [9, 25]
Core 2 [2, 18] [10, 26]
Core 3 [3, 19] [11, 27]
Core 4 [4, 20] [12, 28]
Core 5 [5, 21] [13, 29]
Core 6 [6, 22] [14, 30]
Core 7 [7, 23] [15, 31]
isolcpus=2-3,8-9,18-19,24-25
Ct: container
InCt: initcontainer
U: isolcpus
Test command in pod:cat /sys/fs/cgroup/cpuset/cpuset.cpus
Case 1: 1Ct_3U,got [2-3,19],Passed
Case 2: Keep case 1;create 1Ct_2U,got [9,25],Passed
Case 3: Keep case 1,2;create 1Ct_1U got[18],
create another 1Ct_2U got [8,24],Passed
Case 4: Reboot after case 3;Pods keep cpu as above.Passed
Case 5: Clean All;create 2Ct_3U by one replicaset,pod_1[8-9,24],
pod_2[3,18-19],Passed
Case 6: Keep case 5;create 1Ct_2U,got [2,25],[2,25] is the last
two non-siblings isocpus,as expected,Passed
Case 7: Clean All;create 2InCt_1Ct_2U,InCt_1 got[2,18],
InCt_2 got[2,18],Pod got [2,18],Passed
Case 8: Clean All;create 2InCt_2Ct_2U, Pod1_InCt_1 got[3,19],
Pod1_InCt_2 got[3,19], Pod1 got [3,19],Pod2_InCt_1 got[2,18],
Pod2_InCt_2 got[2,18], Pod2 got [2,18],Cpu in initcontainer
is tested by write file to pvc,Passed
Story: 2008760
Task: 44190
Change-Id: I8bd03352cc395bada9126fb0fce8ed268ac36456
Signed-off-by: Tao Wang <tao.wang@windriver.com>
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
5.6 KiB
5.6 KiB