diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-05-01 00:04:45 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-01 00:04:45 +0000 |
commit | 06740c05f24df9464bca0e67baebc2fb917d6826 (patch) | |
tree | 006956bdc1b6a7961b06049fdd7f4f72dd348a1a | |
parent | 360f1c75ed90c10367cd183d84efef6643e4dd1d (diff) | |
parent | f6a502d760c7eb53111d82bf36b6bcf88cab7712 (diff) | |
download | crosvm-master.tar.gz |
Merge "UPSTREAM: Revert "aarch64: Use cpu_capacity to determine clustering instead"" into mainHEADmastermain
-rw-r--r-- | aarch64/src/lib.rs | 14 | ||||
-rw-r--r-- | base/src/lib.rs | 1 | ||||
-rw-r--r-- | base/src/sys/linux/mod.rs | 5 |
3 files changed, 8 insertions, 12 deletions
diff --git a/aarch64/src/lib.rs b/aarch64/src/lib.rs index 9bf32115b..f7de776be 100644 --- a/aarch64/src/lib.rs +++ b/aarch64/src/lib.rs @@ -886,18 +886,8 @@ impl arch::LinuxArch for AArch64 { // Creates CPU cluster mask for each CPU in the host system. fn get_host_cpu_clusters() -> std::result::Result<Vec<CpuSet>, Self::Error> { - let cpu_capacities = - Self::collect_for_each_cpu(base::logical_core_capacity).map_err(Error::CpuTopology)?; - let mut unique_caps = Vec::new(); - let mut cluster_ids = Vec::new(); - for capacity in cpu_capacities { - if !unique_caps.contains(&capacity) { - unique_caps.push(capacity); - } - let idx = unique_caps.iter().position(|&r| r == capacity).unwrap(); - cluster_ids.push(idx); - } - + let cluster_ids = Self::collect_for_each_cpu(base::logical_core_cluster_id) + .map_err(Error::CpuTopology)?; let mut unique_clusters: Vec<CpuSet> = cluster_ids .iter() .map(|&vcpu_cluster_id| { diff --git a/base/src/lib.rs b/base/src/lib.rs index e7b77f9c9..2b2151477 100644 --- a/base/src/lib.rs +++ b/base/src/lib.rs @@ -110,6 +110,7 @@ cfg_if::cfg_if! { pub use linux::{getegid, geteuid}; pub use linux::{gettid, kill_process_group, reap_child}; pub use linux::logical_core_capacity; + pub use linux::logical_core_cluster_id; pub use linux::logical_core_frequencies_khz; pub use linux::sched_attr; pub use linux::sched_setattr; diff --git a/base/src/sys/linux/mod.rs b/base/src/sys/linux/mod.rs index fd7e77356..aa91e6086 100644 --- a/base/src/sys/linux/mod.rs +++ b/base/src/sys/linux/mod.rs @@ -630,6 +630,11 @@ pub fn logical_core_capacity(cpu_id: usize) -> Result<u32> { } } +/// Returns the cluster ID of a given logical core. +pub fn logical_core_cluster_id(cpu_id: usize) -> Result<u32> { + parse_sysfs_cpu_info(cpu_id, "topology/physical_package_id") +} + /// Returns the maximum frequency (in kHz) of a given logical core. fn logical_core_max_freq_khz(cpu_id: usize) -> Result<u32> { parse_sysfs_cpu_info(cpu_id, "cpufreq/cpuinfo_max_freq") |