Skip to content

Commit

Permalink
Merge pull request nokyan#210 from nokyan/multi-socket-cpu-fix
Browse files Browse the repository at this point in the history
Fix logical CPUs being wrong for multi socket systems
  • Loading branch information
nokyan authored Apr 20, 2024
2 parents 3a6aaf0 + 0b70642 commit eebded5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 123 deletions.
133 changes: 19 additions & 114 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ regex = "1.10.2"
sysconf = "0.3.4"
nvml-wrapper = "0.10.0"
unescape = "0.1.0"
nix = { version = "0.28", features = ["signal"] }
nix = { version = "0.28", default_features = false, features = ["signal"] }
plotters = { version = "0.3.5", default_features = false, features = [
"area_series",
] }
Expand Down
1 change: 1 addition & 0 deletions lib/process_data/src/pci_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl PciSlot {
}

#[derive(Debug)]
#[allow(dead_code)]
pub struct ParseError(String);

impl Error for ParseError {
Expand Down
13 changes: 5 additions & 8 deletions src/utils/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,16 @@ pub fn cpu_info() -> Result<CpuInfo> {
});

let logical_cpus = RE_LSCPU_CPUS.captures(&lscpu_output).and_then(|captures| {
captures.get(1).and_then(|capture| {
capture
.as_str()
.parse::<usize>()
.ok()
.map(|int| int * sockets.unwrap_or(1))
})
captures
.get(1)
.and_then(|capture| capture.as_str().parse().ok())
});

let physical_cpus = RE_LSCPU_CORES.captures(&lscpu_output).and_then(|captures| {
captures
.get(1)
.and_then(|capture| capture.as_str().parse().ok())
.and_then(|capture| capture.as_str().parse::<usize>().ok())
.map(|int| int * sockets.unwrap_or(1))
});

let virtualization = RE_LSCPU_VIRTUALIZATION
Expand Down

0 comments on commit eebded5

Please sign in to comment.