Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release CPUs reminders #475

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ private List<List<VM>> groupVms(List<VM> vms, SchedulingContext context) {
// Create individual VmGroups for the rest of VMs that are not in affinity groups
vmsById.values().forEach(vm -> vmGroups.add(Collections.singletonList(vm)));

vmGroups.forEach(vmGroup -> vmGroup.sort(new VmsCpuPinningPolicyComparator().reversed()));

return vmGroups;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public List<VdsCpuUnit> allocateManualCpus(List<VdsCpuUnit> cpuTopology, VM vm)
}

private List<VdsCpuUnit> allocateDedicatedCpus(List<VdsCpuUnit> cpuTopology, VM vm, Guid hostId) {
// We can assume that a valid pinning exists here (because the host was filtered beforehand).
List<VdsCpuUnit> cpusToBeAllocated = new ArrayList<>();
int socketsLeft = vm.getNumOfSockets();
int onlineSockets = getOnlineSockets(cpuTopology).size();
Expand Down Expand Up @@ -197,7 +196,8 @@ private List<VdsCpuUnit> allocateDedicatedCpus(List<VdsCpuUnit> cpuTopology, VM
int coresReminder = coreCount % vm.getCpuPerSocket();
for (int i = 0; i < coresReminder * vm.getThreadsPerCpu(); i++) {
if (!cpusToBeAllocated.isEmpty()) {
cpusToBeAllocated.remove(cpusToBeAllocated.size() - 1);
VdsCpuUnit releasedCpu = cpusToBeAllocated.remove(cpusToBeAllocated.size() - 1);
releasedCpu.unPinVm(vm.getId());
}
}

Expand Down