mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
fix(runtime): cpu topology corrections
This commit is contained in:
parent
15e57f9055
commit
399df91170
@ -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(())
|
||||
|
@ -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()?;
|
||||
|
@ -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<Path>) -> io::Result<()> {
|
||||
|
@ -42,6 +42,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
|
||||
class: CpuClass::Standard,
|
||||
}],
|
||||
);
|
||||
last = Some(*item);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -73,6 +74,13 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
|
||||
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<CpuTopologyInfo> {
|
||||
});
|
||||
}
|
||||
}
|
||||
last = Some(item.clone());
|
||||
last = Some(*item);
|
||||
}
|
||||
|
||||
for threads in cores.values_mut() {
|
||||
@ -117,11 +125,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
cores
|
||||
.into_values()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect::<Vec<_>>()
|
||||
cores.into_values().flatten().collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
impl PowerManagementContext {
|
||||
|
19
crates/xen/xencall/examples/cputopo.rs
Normal file
19
crates/xen/xencall/examples/cputopo.rs
Normal file
@ -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(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user