Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layered: actually get slice_ns and max_exec_ns from CO:RE #1034

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions scheds/rust/scx_layered/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,15 @@ lazy_static! {
#[command(verbatim_doc_comment)]
struct Opts {
/// Scheduling slice duration in microseconds.
#[clap(short = 's', long, default_value = "20000")]
slice_us: u64,
#[clap(short = 's', long)]
slice_us: Option<u64>,

/// Maximum consecutive execution time in microseconds. A task may be
/// allowed to keep executing on a CPU for this long. Note that this is
/// the upper limit and a task may have to moved off the CPU earlier. 0
/// indicates default - 20 * slice_us.
#[clap(short = 'M', long, default_value = "0")]
max_exec_us: u64,
#[clap(short = 'M', long)]
max_exec_us: Option<u64>,

/// Scheduling interval in seconds.
#[clap(short = 'i', long, default_value = "0.1")]
Expand Down Expand Up @@ -1165,11 +1165,7 @@ impl<'a> Scheduler<'a> {
..
} = spec.kind.common();

layer.slice_ns = if *slice_us > 0 {
*slice_us * 1000
} else {
opts.slice_us * 1000
};
layer.slice_ns = *slice_us * 1000;
layer.min_exec_ns = min_exec_us * 1000;
layer.yield_step_ns = if *yield_ignore > 0.999 {
0
Expand Down Expand Up @@ -1552,8 +1548,6 @@ impl<'a> Scheduler<'a> {
skel_builder.obj_builder.debug(opts.verbose > 1);
init_libbpf_logging(None);
let mut skel = scx_ops_open!(skel_builder, open_object, layered)?;
skel.maps.rodata_data.slice_ns = scx_enums.SCX_SLICE_DFL;
skel.maps.rodata_data.max_exec_ns = 20 * scx_enums.SCX_SLICE_DFL;

// Initialize skel according to @opts.
skel.struct_ops.layered_mut().exit_dump_len = opts.exit_dump_len;
Expand All @@ -1562,12 +1556,14 @@ impl<'a> Scheduler<'a> {
// Running scx_layered inside a PID namespace would break the
// following.
skel.maps.rodata_data.layered_tgid = std::process::id() as i32;
skel.maps.rodata_data.slice_ns = opts.slice_us * 1000;
skel.maps.rodata_data.max_exec_ns = if opts.max_exec_us > 0 {
opts.max_exec_us * 1000
} else {
opts.slice_us * 1000 * 20
};

let slice_ns = opts
.slice_us
.map(|us| us * 1000)
.unwrap_or(scx_enums.SCX_SLICE_DFL);
skel.maps.rodata_data.slice_ns = slice_ns;
skel.maps.rodata_data.max_exec_ns = opts.max_exec_ns.unwrap_or(20 * slice_ns);

skel.maps.rodata_data.nr_possible_cpus = *NR_CPUS_POSSIBLE as u32;
skel.maps.rodata_data.smt_enabled = cpu_pool.nr_cpus > cpu_pool.nr_cores;
skel.maps.rodata_data.has_little_cores = topo.has_little_cores();
Expand Down
Loading