diff --git a/crates/ctl/src/cli/cpu_topology.rs b/crates/ctl/src/cli/cpu_topology.rs index 3bc61fb..12b77fd 100644 --- a/crates/ctl/src/cli/cpu_topology.rs +++ b/crates/ctl/src/cli/cpu_topology.rs @@ -29,8 +29,7 @@ impl CpuTopologyCommand { .await? .into_inner(); - let mut i = 0; - for cpu in response.cpus { + for (i, cpu) in response.cpus.iter().enumerate() { println!( "{0:<10} {1:<10} {2:<10} {3:<10} {4:<10} {5:<10}", i, @@ -40,7 +39,6 @@ impl CpuTopologyCommand { cpu.thread, class_to_str(cpu.class) ); - i += 1; } Ok(()) diff --git a/crates/daemon/bin/daemon.rs b/crates/daemon/bin/daemon.rs index c9b9ebd..6c2cb26 100644 --- a/crates/daemon/bin/daemon.rs +++ b/crates/daemon/bin/daemon.rs @@ -20,20 +20,10 @@ async fn main() -> Result<()> { .filter(Some("backhand::filesystem::writer"), LevelFilter::Warn); if let Ok(f_addr) = std::env::var("KRATA_FLUENT_ADDR") { - println!("KRATA_FLUENT_ADDR set to {f_addr}"); let target = SocketAddr::from_str(f_addr.as_str())?; builder.target(Target::Pipe(Box::new(TcpStream::connect(target)?))); } - let ev = std::env::vars() - .into_iter() - .fold(String::new(), |mut acc, (k, v)| { - acc.push_str(&format!("{k}={v}\n")); - acc - }); - - std::fs::write("/var/log/krata/ev", ev)?; - builder.init(); mask_sighup()?; diff --git a/crates/loopdev/src/lib.rs b/crates/loopdev/src/lib.rs index c642b07..77b7486 100644 --- a/crates/loopdev/src/lib.rs +++ b/crates/loopdev/src/lib.rs @@ -223,7 +223,6 @@ impl LoopDevice { self.device .metadata() .map(|m| unsafe { libc::major(m.rdev()) }) - .map(|m| m as u32) } /// Return the minor device node number. @@ -231,7 +230,6 @@ impl LoopDevice { self.device .metadata() .map(|m| unsafe { libc::minor(m.rdev()) }) - .map(|m| m as u32) } } @@ -327,11 +325,7 @@ impl AttachOptions<'_> { } pub fn direct_io(&self) -> bool { - if (self.info.lo_flags & LO_FLAGS_DIRECT_IO) == LO_FLAGS_DIRECT_IO { - true - } else { - false - } + (self.info.lo_flags & LO_FLAGS_DIRECT_IO) == LO_FLAGS_DIRECT_IO } pub fn attach(&self, backing_file: impl AsRef) -> io::Result<()> { diff --git a/crates/runtime/src/power.rs b/crates/runtime/src/power.rs index 3f92375..fa3299c 100644 --- a/crates/runtime/src/power.rs +++ b/crates/runtime/src/power.rs @@ -42,6 +42,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec { class: CpuClass::Standard, }], ); + last = Some(*item); continue; } @@ -73,6 +74,13 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec { pe_cores = true; } else if pe_cores && last.map(|last| item.core == last.core + 1).unwrap_or(false) { // detect efficiency cores if P/E cores are in use. + if let Some(last) = last { + if let Some(list) = cores.get_mut(&(last.core, last.socket, last.node)) { + for other in list { + other.class = CpuClass::Efficiency; + } + } + } let list = cores .entry((item.core, item.socket, item.node)) .or_default(); @@ -108,7 +116,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec { }); } } - last = Some(item.clone()); + last = Some(*item); } for threads in cores.values_mut() { @@ -117,11 +125,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec { } } - cores - .into_values() - .into_iter() - .flatten() - .collect::>() + cores.into_values().flatten().collect::>() } impl PowerManagementContext { diff --git a/crates/xen/xencall/examples/cputopo.rs b/crates/xen/xencall/examples/cputopo.rs new file mode 100644 index 0000000..716ac77 --- /dev/null +++ b/crates/xen/xencall/examples/cputopo.rs @@ -0,0 +1,19 @@ +use xencall::error::Result; +use xencall::sys::CpuId; +use xencall::XenCall; + +#[tokio::main] +async fn main() -> Result<()> { + env_logger::init(); + + let call = XenCall::open(0)?; + let physinfo = call.phys_info().await?; + println!("{:?}", physinfo); + let topology = call.cpu_topology().await?; + println!("{:?}", topology); + call.set_cpufreq_gov(CpuId::All, "performance").await?; + call.set_cpufreq_gov(CpuId::Single(0), "performance") + .await?; + call.set_turbo_mode(CpuId::All, true).await?; + Ok(()) +}