mod bpf_skel; use benchmark::BenchmarkScheduler; pub use bpf_skel::*; pub mod bpf_intf; mod benchmark; mod core_selector; mod energy; mod freq; mod model; mod scheduler; mod socket; #[rustfmt::skip] #[allow(clippy::unwrap_or_default)] #[allow(clippy::useless_asref)] #[allow(clippy::single_match)] #[allow(clippy::needless_lifetimes)] mod bpf; use anyhow::Result; use clap::{Arg, ArgAction, Command}; use scheduler::Scheduler; use std::mem::MaybeUninit; type Pid = i32; fn main() -> Result<()> { let matches = Command::new("Energy User Space Scheduler") .arg( Arg::new("perf") .short('p') .long("perf") .help("Use this flag to switch between the kernel module and perf") .action(ArgAction::SetTrue) .required(false), ) .arg( Arg::new("benchmark") .short('b') .long("benchmark") .help("Enable benchmarking mode.") .required(false) .action(ArgAction::SetTrue), ) .get_matches(); let use_perf = matches.get_flag("perf"); let benchmark = matches.get_flag("benchmark"); // Initialize and load the scheduler. let mut open_object = MaybeUninit::uninit(); let log_path = "/tmp/logs.csv"; if benchmark { let mut sched = BenchmarkScheduler::init(&mut open_object, log_path)?; sched.run()?; return Ok(()); } loop { let mut sched = Scheduler::init(&mut open_object, use_perf)?; if !sched.run()?.should_restart() { break; } } Ok(()) }