mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: store CPU affinity lists as slices
Each affinity host CPU list is copied from configuration. It is only iterated afterwards, so a boxed slice is enough. On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Rob Bradford
parent
74392eccae
commit
29e2319247
@@ -719,7 +719,7 @@ impl CpusConfig {
|
|||||||
v.0.iter()
|
v.0.iter()
|
||||||
.map(|(e1, e2)| CpuAffinity {
|
.map(|(e1, e2)| CpuAffinity {
|
||||||
vcpu: *e1,
|
vcpu: *e1,
|
||||||
host_cpus: e2.clone(),
|
host_cpus: e2.clone().into_boxed_slice(),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
});
|
});
|
||||||
@@ -3694,16 +3694,16 @@ mod unit_tests {
|
|||||||
CpusConfig {
|
CpusConfig {
|
||||||
boot_vcpus: 2,
|
boot_vcpus: 2,
|
||||||
max_vcpus: 2,
|
max_vcpus: 2,
|
||||||
affinity: Some(vec![
|
affinity: Some(Box::new([
|
||||||
CpuAffinity {
|
CpuAffinity {
|
||||||
vcpu: 0,
|
vcpu: 0,
|
||||||
host_cpus: vec![0, 2],
|
host_cpus: Box::new([0, 2]),
|
||||||
},
|
},
|
||||||
CpuAffinity {
|
CpuAffinity {
|
||||||
vcpu: 1,
|
vcpu: 1,
|
||||||
host_cpus: vec![1, 3],
|
host_cpus: Box::new([1, 3]),
|
||||||
}
|
}
|
||||||
]),
|
])),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ pub struct CpuManager {
|
|||||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||||
acpi_address: Option<GuestAddress>,
|
acpi_address: Option<GuestAddress>,
|
||||||
proximity_domain_per_cpu: BTreeMap<u32, u32>,
|
proximity_domain_per_cpu: BTreeMap<u32, u32>,
|
||||||
affinity: BTreeMap<u32, Vec<usize>>,
|
affinity: BTreeMap<u32, Box<[usize]>>,
|
||||||
dynamic: bool,
|
dynamic: bool,
|
||||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||||
#[cfg(feature = "sev_snp")]
|
#[cfg(feature = "sev_snp")]
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub(crate) trait ApplyLandlock {
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub struct CpuAffinity {
|
pub struct CpuAffinity {
|
||||||
pub vcpu: u32,
|
pub vcpu: u32,
|
||||||
pub host_cpus: Vec<usize>,
|
pub host_cpus: Box<[usize]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
@@ -76,7 +76,7 @@ pub struct CpusConfig {
|
|||||||
#[serde(default = "default_cpuconfig_max_phys_bits")]
|
#[serde(default = "default_cpuconfig_max_phys_bits")]
|
||||||
pub max_phys_bits: u8,
|
pub max_phys_bits: u8,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub affinity: Option<Vec<CpuAffinity>>,
|
pub affinity: Option<Box<[CpuAffinity]>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub features: CpuFeatures,
|
pub features: CpuFeatures,
|
||||||
#[serde(default = "default_cpusconfig_nested")]
|
#[serde(default = "default_cpusconfig_nested")]
|
||||||
|
|||||||
Reference in New Issue
Block a user