Skip to content

Commit

Permalink
core: don't use vdsm core for isolate threads
Browse files Browse the repository at this point in the history
When allocating CPUs for isolate threads we use the maximum freed
socket. This socket is already without pinned CPUs. With that, isolate
threads thinks these cores are free to use, while they are not.

This patch changes the maximum freed socket to contain every CPU within
it, without dropping taken CPUs.

Change-Id: Ic81d93ecd830cea689a8eea4579d6e728c5b2e04
Bug-Url: https://bugzilla.redhat.com/2094415
Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Jun 13, 2022
1 parent db6458e commit 869910a
Showing 1 changed file with 10 additions and 13 deletions.
Expand Up @@ -165,7 +165,7 @@ private List<VdsCpuUnit> allocateDedicatedCpus(List<VdsCpuUnit> cpuTopology, VM
int onlineSockets = getOnlineSockets(cpuTopology).size();
int numOfAllocatedCPUs = 0;
while (onlineSockets > 0 && socketsLeft > 0) {
List<VdsCpuUnit> cpusInChosenSocket = getMaxFreedSocket(cpuTopology);
List<VdsCpuUnit> cpusInChosenSocket = getCoresInSocket(cpuTopology, getMaxFreedSocket(cpuTopology));
if (cpusInChosenSocket.isEmpty()) {
break;
}
Expand Down Expand Up @@ -291,11 +291,6 @@ public int countUnavailableCpus(List<VdsCpuUnit> cpuTopology, boolean countThrea
}
}

public int getDedicatedCount(Guid vdsId) {
return (int) resourceManager.getVdsManager(vdsId).getCpuTopology().stream()
.filter(VdsCpuUnit::isExclusive).count();
}

private List<Integer> getOnlineSockets(List<VdsCpuUnit> cpuTopology) {
return cpuTopology.stream().map(VdsCpuUnit::getSocket).distinct().collect(Collectors.toList());
}
Expand All @@ -308,16 +303,18 @@ private List<Integer> getOnlineCores(List<VdsCpuUnit> cpuTopology) {
return cpuTopology.stream().map(VdsCpuUnit::getCore).distinct().collect(Collectors.toList());
}

private List<VdsCpuUnit> getMaxFreedSocket(List<VdsCpuUnit> cpuTopology) {
private int getMaxFreedSocket(List<VdsCpuUnit> cpuTopology) {
List<VdsCpuUnit> chosenSocket = Collections.emptyList();
List<VdsCpuUnit> temp;
for (int socket : getOnlineSockets(cpuTopology)) {
temp = getFreeCpusInSocket(cpuTopology, socket);
if (temp.size() > chosenSocket.size()) {
chosenSocket = temp;
List<Integer> onlineSocketIds = getOnlineSockets(cpuTopology);
int chosenSocketId = onlineSocketIds.get(0);
for (int socket : onlineSocketIds) {
List<VdsCpuUnit> freeCpusInSocket = getFreeCpusInSocket(cpuTopology, socket);
if (freeCpusInSocket.size() > chosenSocket.size()) {
chosenSocket = freeCpusInSocket;
chosenSocketId = socket;
}
}
return chosenSocket;
return chosenSocketId;
}

private int getAvailableCores(List<VdsCpuUnit> cpuTopology, int socket, int vThreads) {
Expand Down

0 comments on commit 869910a

Please sign in to comment.