-
Notifications
You must be signed in to change notification settings - Fork 1.3k
kvm: FIX cpucorespersocket is not working on KVM #4497
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2302,14 +2302,7 @@ public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) { | |
| if (vmTO.getType() == VirtualMachine.Type.User) { | ||
| cmd.setFeatures(_cpuFeatures); | ||
| } | ||
| // multi cores per socket, for larger core configs | ||
| if (vcpus % 6 == 0) { | ||
| final int sockets = vcpus / 6; | ||
| cmd.setTopology(6, sockets); | ||
| } else if (vcpus % 4 == 0) { | ||
| final int sockets = vcpus / 4; | ||
| cmd.setTopology(4, sockets); | ||
| } | ||
| setCpuTopology(cmd, vcpus, vmTO.getDetails()); | ||
| vm.addComp(cmd); | ||
| } | ||
|
|
||
|
|
@@ -4230,4 +4223,26 @@ public boolean isSecureMode(String bootMode) { | |
|
|
||
| return false; | ||
| } | ||
|
|
||
| private void setCpuTopology(CpuModeDef cmd, int vcpus, Map<String, String> details) { | ||
| // multi cores per socket, for larger core configs | ||
| int numCoresPerSocket = -1; | ||
| if (details != null) { | ||
| final String coresPerSocket = details.get(VmDetailConstants.CPU_CORE_PER_SOCKET); | ||
| final int intCoresPerSocket = NumbersUtil.parseInt(coresPerSocket, numCoresPerSocket); | ||
| if (intCoresPerSocket > 0 && vcpus % intCoresPerSocket == 0) { | ||
| numCoresPerSocket = intCoresPerSocket; | ||
| } | ||
| } | ||
| if (numCoresPerSocket <= 0) { | ||
| if (vcpus % 6 == 0) { | ||
| numCoresPerSocket = 6; | ||
| } else if (vcpus % 4 == 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when vcpus are 8, it is considered as 4 cores per socket here, instead 8 cores.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sureshanaparti this is the current behavior.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
agree, any plan to address here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sureshanaparti you mean change the current behavior ? No. I am not going to change it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ok @weizhouapache so no change in the behavior. thanks. |
||
| numCoresPerSocket = 4; | ||
| } else { | ||
| numCoresPerSocket = 1; | ||
| } | ||
| } | ||
| cmd.setTopology(numCoresPerSocket, vcpus / numCoresPerSocket); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ustcweizhou possible to pass coresPerSocket here, instead complete VM details here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti
I was thinking about it. at the end I decided to pass vm details based on two reasons
(1) setCpuTopology is a complete function now. if pass coresPerSocket , we need to get coresPerSocket out of the method.
(2) it is better if add more cpu settings , for example the pr #4178
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok @weizhouapache so going forward, cpu hyperthreading detail mentioned in PR #4178 will be added to this method, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti yes. but I need to discuss with @div8cn about some details. it will be an improvement in 4.16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Pls update details here. As this PR is targeted for 4.14.1.0, the proposed changes with cpu hyperthreading detail will be targeted for 4.16, Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti yes, this is a bug which should be fixed in 4.14 and 4.15.
the other pr is an improvement. it will not impact this pr.