Skip to content

Commit 98f24ea

Browse files
author
Changwoo Min
committed
scx_utils: Create Cpus in a numerical order.
Previously, the CPUs are created in CPU id's lexicographical order (e.g., 1 -> 10 -> 11 -> 2), so core ids are assigned following the lexicographical ordering. There is nothing wrong with it, but it is unintuitive. Thus, let's iterate and create CPUs in numerical order, so assign core id in an intuitive order. Signed-off-by: Changwoo Min <[email protected]>
1 parent 9984f4f commit 98f24ea

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

rust/scx_utils/src/topology.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -785,22 +785,13 @@ fn create_numa_nodes(
785785
}
786786
}
787787

788-
let cpu_pattern = numa_path.join("cpu[0-9]*");
789-
let cpu_paths = glob(cpu_pattern.to_string_lossy().as_ref())?;
790788
let big_little = has_big_little().unwrap_or(false);
791789
let capacity_src = cpu_capacity_source();
792790
let avg_cpu_freq = avg_cpu_freq();
793-
for cpu_path in cpu_paths.filter_map(Result::ok) {
794-
let cpu_str = cpu_path.to_str().unwrap().trim();
795-
let cpu_id = match sscanf!(cpu_str, "/sys/devices/system/node/node{usize}/cpu{usize}") {
796-
Ok((_, val)) => val,
797-
Err(_) => {
798-
bail!("Failed to parse cpu ID {}", cpu_str);
799-
}
800-
};
801-
791+
let cpu_ids = read_cpu_ids()?;
792+
for cpu_id in cpu_ids.iter() {
802793
create_insert_cpu(
803-
cpu_id,
794+
*cpu_id,
804795
&mut node,
805796
online_mask,
806797
topo_ctx,

0 commit comments

Comments
 (0)