mshv: Fix CPU topology detection - #7576
Conversation
de3313b to
314f6de
Compare
| const HV_PARTITION_PROPERTY_PROCESSORS_PER_SOCKET: u32 = 0x00050003; | ||
|
|
||
| let threads_per_core = if let Some(ref topology) = self.config.topology { | ||
| topology.threads_per_core as u64 | ||
| } else { | ||
| 1u64 | ||
| }; | ||
|
|
||
| if let Some(mshv_vm) = self.vm.as_any().downcast_ref::<hypervisor::mshv::MshvVm>() { |
There was a problem hiding this comment.
I believe this should be included to the downcast if statement too - particularly we are releasing binaries that have both mshv and kvm feature flags enabled.
There was a problem hiding this comment.
Why don't we add an API to hypervisor/vm.rs and make nothing for kvm and mshv implements.
There was a problem hiding this comment.
I moved all the related stuff into the downcast if block now.
With the Vm trait suggestion - while it would eliminate the downcast, this is MSHV specific. The current approach keeps it out of the public API. Both work technically, of course.
Thanks
| const HV_PARTITION_PROPERTY_PROCESSORS_PER_SOCKET: u32 = 0x00050003; | ||
|
|
||
| let threads_per_core = if let Some(ref topology) = self.config.topology { | ||
| topology.threads_per_core as u64 | ||
| } else { | ||
| 1u64 | ||
| }; | ||
|
|
||
| if let Some(mshv_vm) = self.vm.as_any().downcast_ref::<hypervisor::mshv::MshvVm>() { |
There was a problem hiding this comment.
Why don't we add an API to hypervisor/vm.rs and make nothing for kvm and mshv implements.
5bdef61 to
326e57e
Compare
Fixes: cloud-hypervisor#7433 Signed-off-by: Anatol Belski <[email protected]>
326e57e to
092ef38
Compare
On MSHV, exposing multithreaded CPU topologies requires setting the PROCESSORS_PER_SOCKET partition property so that CPUID.0xB reports correct logical processor counts and topology levels to the guest. This property must be set after all vCPUs are configured, as the hypervisor uses the complete vCPU layout to derive and report CPU topology information. Signed-off-by: Anatol Belski <[email protected]>
092ef38 to
d0385ec
Compare
|
Regarding to possible moving some of this to the mshv crate - IMO it's not necessary. The mshv crates provide the primitives, but this specific workaround for CPU topology is cloud-hypervisor specific. The logic how to apply it belongs here in the VMM. Thanks |
|
LGTM |
3657db7
This PR enables proper CPU topology detection on MSHV with multithreaded configurations. The
PROCESSORS_PER_SOCKETpartition property has to be set after vCPU configuration for correct threads-per-core reporting inCPUID.0xB EBX.Fixes: #7433