Skip to content

Commit dbbcb7d

Browse files
authored
Merge pull request #1717 from multics69/utils-hotfix
scx_utils: Fix incorrect handling of CPU IDs on multi-NUMA machines.
2 parents e817d63 + ee11657 commit dbbcb7d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

rust/scx_utils/src/topology.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,27 @@ 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())?;
788790
let big_little = has_big_little().unwrap_or(false);
789791
let capacity_src = cpu_capacity_source();
790792
let avg_cpu_freq = avg_cpu_freq();
791-
let cpu_ids = read_cpu_ids()?;
792-
for cpu_id in cpu_ids.iter() {
793+
let mut cpu_ids = vec![];
794+
for cpu_path in cpu_paths.filter_map(Result::ok) {
795+
let cpu_str = cpu_path.to_str().unwrap().trim();
796+
let cpu_id = match sscanf!(cpu_str, "/sys/devices/system/node/node{usize}/cpu{usize}") {
797+
Ok((_, val)) => val,
798+
Err(_) => {
799+
bail!("Failed to parse cpu ID {}", cpu_str);
800+
}
801+
};
802+
cpu_ids.push(cpu_id);
803+
}
804+
cpu_ids.sort();
805+
806+
for cpu_id in cpu_ids {
793807
create_insert_cpu(
794-
*cpu_id,
808+
cpu_id,
795809
&mut node,
796810
online_mask,
797811
topo_ctx,

0 commit comments

Comments
 (0)