mshv: Enable SMT for guests with threads_per_core > 1 by weltling · Pull Request #7668 · cloud-hypervisor/cloud-hypervisor · GitHub
Skip to content

mshv: Enable SMT for guests with threads_per_core > 1#7668

Merged
rbradford merged 2 commits intocloud-hypervisor:mainfrom
weltling:mshv-smt-enabled-guest
Feb 7, 2026
Merged

mshv: Enable SMT for guests with threads_per_core > 1#7668
rbradford merged 2 commits intocloud-hypervisor:mainfrom
weltling:mshv-smt-enabled-guest

Conversation

@weltling
Copy link
Copy Markdown
Member

@weltling weltling commented Feb 5, 2026

Set HV_PARTITION_CREATION_FLAG_SMT_ENABLED_GUEST when the guest topology
has more than one thread per core. This allows the hypervisor to schedule
guest VPs correctly on SMT-enabled hosts.

Without this flag, the hypervisor schedules guest VPs incorrectly,
causing SMT unusable.

Includes also the updated MSHV crates as a dependency.

This complements #7576 by ensuring SMT is enabled when the topology configured accordingly.

@weltling weltling requested a review from a team as a code owner February 5, 2026 11:10
@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 5617fe2 to 03ba4e8 Compare February 5, 2026 11:44
Copy link
Copy Markdown
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One remark tho

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it is no longer unused, please rename _config to config

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. There are some other struct members hanging on it, too. I made a dedicated commit, it doesn't seem to deserve a dedicated PR.

Thanks

Comment thread Cargo.toml
linux-loader = "0.13.1"
mshv-bindings = "0.6.6"
mshv-ioctls = "0.6.6"
mshv-bindings = "0.6.7"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see 👍 but you need to check in the Cargo.lock with it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks for the hint.

Release notes: rust-vmm/mshv#307

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 03ba4e8 to 712665c Compare February 5, 2026 13:48
@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 712665c to 0fd3e09 Compare February 5, 2026 13:53
@rbradford rbradford enabled auto-merge February 5, 2026 13:54
auto-merge was automatically disabled February 5, 2026 13:55

Head branch was pushed to by a user without write access

@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 0fd3e09 to e058a96 Compare February 5, 2026 13:55
Comment thread hypervisor/src/mshv/mod.rs Outdated
/// let vm = hypervisor.create_vm(config).unwrap();
/// ```
fn create_vm(&self, _config: HypervisorVmConfig) -> hypervisor::Result<Arc<dyn vm::Vm>> {
fn create_vm(&self, config: HypervisorVmConfig) -> hypervisor::Result<Arc<dyn vm::Vm>> {
Copy link
Copy Markdown
Member

@phip1611 phip1611 Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah shoot, clippy is failing as with some cargo feature configurations, this variable is unused 🙄

Hm..... yes, than maybe sticking to _config might be the pragmatic solution, although it isn't very nice

Copy link
Copy Markdown
Member

@rbradford rbradford Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weltling Do you want to just drop the the last commit then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with this, but otherwise seems no ideal solution to this.

#[cfg(any(feature = "sev_snp", target_arch = "x86_64"))] config: HypervisorVmConfig,
#[cfg(not(any(feature = "sev_snp", target_arch = "x86_64")))] _config: HypervisorVmConfig,

If this doesn't work out, I'll drop the last commit then.

Thanks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like clippy is happy with that :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for investigating! I think keeping _config is the lesser evil here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I dropped that. The compiler seems also to handle it correctly disreganding _. Thanks

@weltling weltling force-pushed the mshv-smt-enabled-guest branch from e058a96 to a11eed7 Compare February 5, 2026 18:49
@weltling
Copy link
Copy Markdown
Member Author

weltling commented Feb 5, 2026

Hmm, looks like the MSHV CI runner might not have an updated host kernel version. Looking at what it says:

VmCreate(Kernel returned errno: Invalid argument (os error 22)) at vmm/src/vm.rs:1150

this likely means tests test_cpu_topology_262 and test_cpu_topology_421 are failing due to smt_enabled = true. @anirudhrb could you please confirm CI is using the latest kernel version?

Thanks!

@weltling weltling force-pushed the mshv-smt-enabled-guest branch from a11eed7 to 34565ab Compare February 5, 2026 22:26
Copy link
Copy Markdown
Contributor

@russell-islam russell-islam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 34565ab to 134480a Compare February 6, 2026 11:30
Set HV_PARTITION_CREATION_FLAG_SMT_ENABLED_GUEST when the guest
topology has more than one thread per core. This allows the
hypervisor to schedule guest VPs correctly on SMT-enabled hosts.

Without this flag, the hypervisor schedules guest VPs incorrectly,
causing SMT unusable.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
@weltling weltling force-pushed the mshv-smt-enabled-guest branch from 134480a to 1d5d8fd Compare February 6, 2026 17:26
@weltling
Copy link
Copy Markdown
Member Author

weltling commented Feb 6, 2026

@rbradford rbradford added this pull request to the merge queue Feb 7, 2026
Merged via the queue into cloud-hypervisor:main with commit a00189c Feb 7, 2026
45 checks passed
@weltling weltling deleted the mshv-smt-enabled-guest branch February 8, 2026 18:48
@likebreath likebreath added the mshv Affects mshv only label Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mshv Affects mshv only

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants