mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 05:10:55 +00:00
fix(runtime): cpu topology corrections
This commit is contained in:
parent
15e57f9055
commit
399df91170
@ -29,8 +29,7 @@ impl CpuTopologyCommand {
|
|||||||
.await?
|
.await?
|
||||||
.into_inner();
|
.into_inner();
|
||||||
|
|
||||||
let mut i = 0;
|
for (i, cpu) in response.cpus.iter().enumerate() {
|
||||||
for cpu in response.cpus {
|
|
||||||
println!(
|
println!(
|
||||||
"{0:<10} {1:<10} {2:<10} {3:<10} {4:<10} {5:<10}",
|
"{0:<10} {1:<10} {2:<10} {3:<10} {4:<10} {5:<10}",
|
||||||
i,
|
i,
|
||||||
@ -40,7 +39,6 @@ impl CpuTopologyCommand {
|
|||||||
cpu.thread,
|
cpu.thread,
|
||||||
class_to_str(cpu.class)
|
class_to_str(cpu.class)
|
||||||
);
|
);
|
||||||
i += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -20,20 +20,10 @@ async fn main() -> Result<()> {
|
|||||||
.filter(Some("backhand::filesystem::writer"), LevelFilter::Warn);
|
.filter(Some("backhand::filesystem::writer"), LevelFilter::Warn);
|
||||||
|
|
||||||
if let Ok(f_addr) = std::env::var("KRATA_FLUENT_ADDR") {
|
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())?;
|
let target = SocketAddr::from_str(f_addr.as_str())?;
|
||||||
builder.target(Target::Pipe(Box::new(TcpStream::connect(target)?)));
|
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();
|
builder.init();
|
||||||
|
|
||||||
mask_sighup()?;
|
mask_sighup()?;
|
||||||
|
@ -223,7 +223,6 @@ impl LoopDevice {
|
|||||||
self.device
|
self.device
|
||||||
.metadata()
|
.metadata()
|
||||||
.map(|m| unsafe { libc::major(m.rdev()) })
|
.map(|m| unsafe { libc::major(m.rdev()) })
|
||||||
.map(|m| m as u32)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the minor device node number.
|
/// Return the minor device node number.
|
||||||
@ -231,7 +230,6 @@ impl LoopDevice {
|
|||||||
self.device
|
self.device
|
||||||
.metadata()
|
.metadata()
|
||||||
.map(|m| unsafe { libc::minor(m.rdev()) })
|
.map(|m| unsafe { libc::minor(m.rdev()) })
|
||||||
.map(|m| m as u32)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,11 +325,7 @@ impl AttachOptions<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn direct_io(&self) -> bool {
|
pub fn direct_io(&self) -> bool {
|
||||||
if (self.info.lo_flags & LO_FLAGS_DIRECT_IO) == LO_FLAGS_DIRECT_IO {
|
(self.info.lo_flags & LO_FLAGS_DIRECT_IO) == LO_FLAGS_DIRECT_IO
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attach(&self, backing_file: impl AsRef<Path>) -> io::Result<()> {
|
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,
|
class: CpuClass::Standard,
|
||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
|
last = Some(*item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +74,13 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
|
|||||||
pe_cores = true;
|
pe_cores = true;
|
||||||
} else if pe_cores && last.map(|last| item.core == last.core + 1).unwrap_or(false) {
|
} 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.
|
// 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
|
let list = cores
|
||||||
.entry((item.core, item.socket, item.node))
|
.entry((item.core, item.socket, item.node))
|
||||||
.or_default();
|
.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() {
|
for threads in cores.values_mut() {
|
||||||
@ -117,11 +125,7 @@ fn labelled_topo(input: &[SysctlCputopo]) -> Vec<CpuTopologyInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cores
|
cores.into_values().flatten().collect::<Vec<_>>()
|
||||||
.into_values()
|
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PowerManagementContext {
|
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