diff --git a/rust/scx_utils/src/bpf_builder.rs b/rust/scx_utils/src/bpf_builder.rs index 34905004f..7e8a13c9d 100644 --- a/rust/scx_utils/src/bpf_builder.rs +++ b/rust/scx_utils/src/bpf_builder.rs @@ -590,8 +590,6 @@ mod tests { println!("vmlinux.h: ver={:?}", &ver); - assert!(regex::Regex::new(r"^[a-f0-9]{7}$") - .unwrap() - .is_match(&ver)); + assert!(regex::Regex::new(r"^[a-f0-9]{7}$").unwrap().is_match(&ver)); } } diff --git a/rust/scx_utils/src/user_exit_info.rs b/rust/scx_utils/src/user_exit_info.rs index f31fe9220..79017bcf1 100644 --- a/rust/scx_utils/src/user_exit_info.rs +++ b/rust/scx_utils/src/user_exit_info.rs @@ -120,10 +120,10 @@ macro_rules! uei_report { #[derive(Debug, Default)] pub struct UserExitInfo { r#type: i32, -// exit_code: i64, + // exit_code: i64, reason: Option, msg: Option, -// dump: Option, + // dump: Option, } impl UserExitInfo { @@ -164,24 +164,24 @@ impl UserExitInfo { .filter(|s| !s.is_empty()), ); - // let dump = if dump_ptr.is_null() { - // None - // } else { - // Some( - // unsafe { CStr::from_ptr(dump_ptr) } - // .to_str() - // .expect("Failed to convert msg to string") - // .to_string(), - // ) - // .filter(|s| !s.is_empty()) - // }; + // let dump = if dump_ptr.is_null() { + // None + // } else { + // Some( + // unsafe { CStr::from_ptr(dump_ptr) } + // .to_str() + // .expect("Failed to convert msg to string") + // .to_string(), + // ) + // .filter(|s| !s.is_empty()) + // }; Self { r#type, // exit_code, reason, msg, - // dump, + // dump, } } @@ -193,22 +193,22 @@ impl UserExitInfo { return Ok(()); } - // if let Some(dump) = &self.dump { - // eprintln!("\nDEBUG DUMP"); - // eprintln!("================================================================================\n"); - // eprintln!("{}", dump); - // eprintln!("================================================================================\n"); - // } + // if let Some(dump) = &self.dump { + // eprintln!("\nDEBUG DUMP"); + // eprintln!("================================================================================\n"); + // eprintln!("{}", dump); + // eprintln!("================================================================================\n"); + // } - let why = match (&self.reason, &self.msg) { - (Some(reason), None) => format!("EXIT: {}", reason), - (Some(reason), Some(msg)) => format!("EXIT: {} ({})", reason, msg), - _ => "".into(), - }; + let why = match (&self.reason, &self.msg) { + (Some(reason), None) => format!("EXIT: {}", reason), + (Some(reason), Some(msg)) => format!("EXIT: {} ({})", reason, msg), + _ => "".into(), + }; - if why != ""{ + if why != "" { eprintln!("{}", why); - } + } // if self.kind <= ScxExitKind::UnregKern as i32 { // eprintln!("{}", why); diff --git a/scheds/rust/scx_layered/src/main.rs b/scheds/rust/scx_layered/src/main.rs index 685688614..82e7f8e3d 100644 --- a/scheds/rust/scx_layered/src/main.rs +++ b/scheds/rust/scx_layered/src/main.rs @@ -3,10 +3,11 @@ // This software may be used and distributed according to the terms of the // GNU General Public License version 2. // mod bpf_skel; -mod stats; pub mod bpf_skel; +mod stats; pub use bpf_skel::*; pub mod bpf_intf; +use core::ffi::CStr; use stats::LayerStats; use stats::StatsReq; use stats::StatsRes; @@ -15,7 +16,6 @@ use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::HashMap; use std::ffi::CString; -use core::ffi::CStr; use std::fs; use std::io::Read; use std::io::Write; @@ -457,7 +457,9 @@ enum LayerGrowthAlgo { } impl Default for LayerGrowthAlgo { - fn default() -> Self { LayerGrowthAlgo::Sticky } + fn default() -> Self { + LayerGrowthAlgo::Sticky + } } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -888,7 +890,6 @@ impl Stats { } } - #[derive(Debug, Default)] struct UserExitInfo { kind: i32, @@ -1152,11 +1153,7 @@ impl CpuPool { } } -fn layer_core_order( - growth_algo: LayerGrowthAlgo, - layer_idx: usize, - topo: &Topology - ) -> Vec { +fn layer_core_order(growth_algo: LayerGrowthAlgo, layer_idx: usize, topo: &Topology) -> Vec { let mut core_order = vec![]; match growth_algo { LayerGrowthAlgo::Sticky => { @@ -1262,8 +1259,18 @@ impl Layer { bail!("invalid util_range {:?}", util_range); } } - LayerKind::Grouped { growth_algo, nodes, llcs, .. } | - LayerKind::Open { growth_algo, nodes, llcs, .. } => { + LayerKind::Grouped { + growth_algo, + nodes, + llcs, + .. + } + | LayerKind::Open { + growth_algo, + nodes, + llcs, + .. + } => { layer_growth_algo = growth_algo.clone(); if nodes.len() == 0 && llcs.len() == 0 { allowed_cpus.fill(true); @@ -1686,7 +1693,9 @@ impl<'a, 'b> Scheduler<'a, 'b> { let mut skel_builder = BpfSkelBuilder::default(); skel_builder.obj_builder.debug(opts.verbose > 1); init_libbpf_logging(None); - let mut skel = skel_builder.open(open_object).context("failed to open BPF program")?; + let mut skel = skel_builder + .open(open_object) + .context("failed to open BPF program")?; // scheduler_tick() got renamed to sched_tick() during v6.10-rc. let sched_tick_name = match compat::ksym_exists("sched_tick")? { @@ -1768,9 +1777,9 @@ impl<'a, 'b> Scheduler<'a, 'b> { }; sched - .skel - .attach() - .context("Failed to attach BPF program")?; + .skel + .attach() + .context("Failed to attach BPF program")?; sched.struct_ops = Some( sched @@ -1909,7 +1918,9 @@ impl<'a, 'b> Scheduler<'a, 'b> { let mut next_sched_at = Instant::now() + self.sched_intv; let mut cpus_ranges = HashMap::>::new(); - while !shutdown.load(Ordering::Relaxed) && !UserExitInfo::exited(&self.skel.maps.bss_data.uei)? { + while !shutdown.load(Ordering::Relaxed) + && !UserExitInfo::exited(&self.skel.maps.bss_data.uei)? + { let now = Instant::now(); if now >= next_sched_at { @@ -2162,4 +2173,3 @@ fn main() -> Result<()> { let mut sched = Scheduler::init(&opts, &layer_config.specs, &mut open_object)?; sched.run(shutdown.clone()) } - diff --git a/scheds/rust/scx_layered/src/stats.rs b/scheds/rust/scx_layered/src/stats.rs index 5a70fcfbb..c293a3309 100644 --- a/scheds/rust/scx_layered/src/stats.rs +++ b/scheds/rust/scx_layered/src/stats.rs @@ -150,7 +150,11 @@ impl LayerStats { } }; let calc_frac = |a, b| { - if b != 0.0 { a / b * 100.0 } else { 0.0 } + if b != 0.0 { + a / b * 100.0 + } else { + 0.0 + } }; let is_excl = match &layer.kind { diff --git a/scheds/rust/scx_rusty/src/main.rs b/scheds/rust/scx_rusty/src/main.rs index 2eb46cd56..13661c5a7 100644 --- a/scheds/rust/scx_rusty/src/main.rs +++ b/scheds/rust/scx_rusty/src/main.rs @@ -16,7 +16,9 @@ pub mod load_balance; use load_balance::LoadBalancer; mod stats; +use core::ffi::CStr; use std::collections::BTreeMap; +use std::ffi::CString; use std::mem::MaybeUninit; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; @@ -25,8 +27,6 @@ use std::time::Duration; use std::time::Instant; use std::time::SystemTime; use std::time::UNIX_EPOCH; -use std::ffi::CString; -use core::ffi::CStr; use stats::ClusterStats; use stats::NodeStats; @@ -575,7 +575,9 @@ impl<'a> Scheduler<'a> { self.skel.maps.stats.value_size() as usize; - while !shutdown.load(Ordering::Relaxed) && !UserExitInfo::exited(&self.skel.maps.bss_data.uei)? { + while !shutdown.load(Ordering::Relaxed) + && !UserExitInfo::exited(&self.skel.maps.bss_data.uei)? + { let now = Instant::now(); if now >= next_tune_at { @@ -733,4 +735,3 @@ impl UserExitInfo { } } } -