mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: raise the (v)CPU limit on kvm/x86_64
Raise the max number of supported (v)CPUs on kvm x86_64 hosts to 8192 (the max allowed value of CONFIG_NR_CPUS in the Linux kernel). Other platfroms keep their existing CPU limits pending further development and testing. The change has been tested on Intel and AMD hosts. Signed-off-by: Barret Rhoden <brho@google.com> Signed-off-by: Neel Natu <neelnatu@google.com> Signed-off-by: Ofir Weisse <oweisse@google.com> Signed-off-by: Peter Oskolkov <posk@google.com>
This commit is contained in:
+23
-9
@@ -26,7 +26,7 @@ pub(crate) trait ApplyLandlock {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct CpuAffinity {
|
||||
pub vcpu: u8,
|
||||
pub vcpu: u32,
|
||||
pub host_cpus: Vec<usize>,
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ pub struct CpuFeatures {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct CpuTopology {
|
||||
pub threads_per_core: u8,
|
||||
pub cores_per_die: u8,
|
||||
pub dies_per_package: u8,
|
||||
pub packages: u8,
|
||||
pub threads_per_core: u16,
|
||||
pub cores_per_die: u16,
|
||||
pub dies_per_package: u16,
|
||||
pub packages: u16,
|
||||
}
|
||||
|
||||
// When booting with PVH boot the maximum physical addressable size
|
||||
@@ -56,8 +56,8 @@ pub fn default_cpuconfig_max_phys_bits() -> u8 {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct CpusConfig {
|
||||
pub boot_vcpus: u8,
|
||||
pub max_vcpus: u8,
|
||||
pub boot_vcpus: u32,
|
||||
pub max_vcpus: u32,
|
||||
#[serde(default)]
|
||||
pub topology: Option<CpuTopology>,
|
||||
#[serde(default)]
|
||||
@@ -70,7 +70,7 @@ pub struct CpusConfig {
|
||||
pub features: CpuFeatures,
|
||||
}
|
||||
|
||||
pub const DEFAULT_VCPUS: u8 = 1;
|
||||
pub const DEFAULT_VCPUS: u32 = 1;
|
||||
|
||||
impl Default for CpusConfig {
|
||||
fn default() -> Self {
|
||||
@@ -684,7 +684,7 @@ pub struct NumaConfig {
|
||||
#[serde(default)]
|
||||
pub guest_numa_id: u32,
|
||||
#[serde(default)]
|
||||
pub cpus: Option<Vec<u8>>,
|
||||
pub cpus: Option<Vec<u32>>,
|
||||
#[serde(default)]
|
||||
pub distances: Option<Vec<NumaDistance>>,
|
||||
#[serde(default)]
|
||||
@@ -1035,4 +1035,18 @@ impl VmConfig {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
pub(crate) fn max_apic_id(&self) -> u32 {
|
||||
if let Some(topology) = &self.cpus.topology {
|
||||
arch::x86_64::get_max_x2apic_id((
|
||||
topology.threads_per_core,
|
||||
topology.cores_per_die,
|
||||
topology.dies_per_package,
|
||||
topology.packages,
|
||||
))
|
||||
} else {
|
||||
self.cpus.max_vcpus
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user