Skip to content

Conversation

@likewhatevs
Copy link
Contributor

use default args when argument parsing fails. update log initialization code to make this work well. error log the offending arg/error and defaults used when this occurs.

no arg

❯ sudo ./target/release/scx_mitosis
15:10:40 [INFO] Running scx_mitosis (build ID: 0.0.14-g6e363670 x86_64-unknown-linux-gnu)
15:10:40 [WARN] libbpf: map 'mitosis': BPF map skeleton link is uninitialized

15:10:40 [INFO] Mitosis Scheduler Attached. Run `scx_mitosis --monitor` for metrics.
^C15:10:42 [INFO] Unregister scx_mitosis scheduler
EXIT: unregistered from user space

valid arg

❯ sudo ./target/release/scx_mitosis --exit-dump-len 2048
15:11:04 [INFO] Running scx_mitosis (build ID: 0.0.14-g6e363670 x86_64-unknown-linux-gnu)
15:11:04 [WARN] libbpf: map 'mitosis': BPF map skeleton link is uninitialized

15:11:04 [INFO] Mitosis Scheduler Attached. Run `scx_mitosis --monitor` for metrics.
^C15:11:06 [INFO] Unregister scx_mitosis scheduler
EXIT: unregistered from user space

invalid arg

❯ sudo ./target/release/scx_mitosis --asdasdas
15:11:17 [ERROR] Failed to parse args: error: unexpected argument '--asdasdas' found
15:11:17 [ERROR] Using default arg values: Opts { verbose: 0, exit_dump_len: 0, reconfiguration_interval_s: 10, rebalance_cpus_interval_s: 5, monitor_interval_s: 1, monitor: None, version: false, debug_events: false, exiting_task_workaround: true, libbpf: LibbpfOpts { relaxed_maps: None, pin_root_path: None, kconfig: None, btf_custom_path: None, bpf_token_path: None } }
15:11:17 [INFO] Running scx_mitosis (build ID: 0.0.14-g6e363670 x86_64-unknown-linux-gnu)
15:11:17 [WARN] libbpf: map 'mitosis': BPF map skeleton link is uninitialized

15:11:17 [INFO] Mitosis Scheduler Attached. Run `scx_mitosis --monitor` for metrics.
^C15:11:20 [INFO] Unregister scx_mitosis scheduler
EXIT: unregistered from user space

invalid arg value

❯ sudo ./target/release/scx_mitosis --exit-dump-len 11111111111111111111111111111111
15:11:34 [ERROR] Failed to parse args: error: invalid value '11111111111111111111111111111111' for '--exit-dump-len <EXIT_DUMP_LEN>': number too large to fit in target type
15:11:34 [ERROR] Using default arg values: Opts { verbose: 0, exit_dump_len: 0, reconfiguration_interval_s: 10, rebalance_cpus_interval_s: 5, monitor_interval_s: 1, monitor: None, version: false, debug_events: false, exiting_task_workaround: true, libbpf: LibbpfOpts { relaxed_maps: None, pin_root_path: None, kconfig: None, btf_custom_path: None, bpf_token_path: None } }
15:11:34 [INFO] Running scx_mitosis (build ID: 0.0.14-g6e363670 x86_64-unknown-linux-gnu)
15:11:34 [WARN] libbpf: map 'mitosis': BPF map skeleton link is uninitialized

15:11:34 [INFO] Mitosis Scheduler Attached. Run `scx_mitosis --monitor` for metrics.
^C15:11:37 [INFO] Unregister scx_mitosis scheduler
EXIT: unregistered from user space

version

❯ sudo ./target/release/scx_mitosis --version
scx_mitosis 0.0.14-g6e363670 x86_64-unknown-linux-gnu

help

❯ sudo ./target/release/scx_mitosis --help | head -n 10
scx_mitosis: A dynamic affinity scheduler

Cgroups are assigned to a dynamic number of Cells which are assigned to a dynamic set of CPUs. The BPF part does simple vtime scheduling for each cell.

Userspace makes the dynamic decisions of which Cells should be merged or split and which CPUs they should be assigned to.

Usage: scx_mitosis [OPTIONS]

Options:
  -v, --verbose...

debug

❯ sudo ./target/release/scx_mitosis --verbose 2>&1 | head -n 10
15:13:13 [DEBUG] opts=Opts { verbose: 1, exit_dump_len: 0, reconfiguration_interval_s: 10, rebalance_cpus_interval_s: 5, monitor_interval_s: 1, monitor: None, version: false, debug_events: false, exiting_task_workaround: true, libbpf: LibbpfOpts { relaxed_maps: None, pin_root_path: None, kconfig: None, btf_custom_path: None, bpf_token_path: None } }
15:13:13 [INFO] Running scx_mitosis (build ID: 0.0.14-g6e363670 x86_64-unknown-linux-gnu)
15:13:13 [DEBUG] libbpf: loaded kernel BTF from '/sys/kernel/btf/vmlinux'

15:13:13 [DEBUG] libbpf: loading object 'bpf_bpf' from buffer

15:13:13 [DEBUG] libbpf: elf: section(2) .symtab, size 5352, link 1, flags 0, type=2

15:13:13 [DEBUG] libbpf: elf: section(3) .text, size 7840, link 0, flags 6, type=1

^C^C

use default args when argument parsing fails. update log initialization
code to make this work well. error log the offending arg/error and
defaults used when this occurs.

Signed-off-by: Pat Somaru <[email protected]>
@dforsyth
Copy link
Contributor

dforsyth commented Oct 31, 2025

Can we specify a set of flags we want to eat errors on, rather than falling back to default for any failure (similar to undefok in gflags)?

@likewhatevs
Copy link
Contributor Author

Can we specify a set of flags we want to eat errors on, rather than falling back to default for any failure (similar to undefok in gflags)?

Yes, but not practically.

@tommy-u
Copy link
Contributor

tommy-u commented Nov 1, 2025

I think the goal of relaxing strictness around parsing is to make sure we can send the same set of new flags to multiple versions of the scheduler, without the older schedulers barfing. But we still need any of the compatible flags to apply for the old schedulers.

So if I correctly understand the logic, this PR says "if we encounter any unknown flags -> run the sched with default flags"

for each flag:
  if (the sched doesn't know the flag)
    apply default args
    return 
apply the flags 

We actually want:

for each flag:
  if (the sched knows the flag)
    apply the flag

@likewhatevs
Copy link
Contributor Author

if we encounter any unknown flags -> run the sched with default flags

Correct.

But we still need any of the compatible flags to apply for the old schedulers

I don't think that's a need, I think that's a nice to have. That would probably require changing to a different CLI library and keeping things similar-enough to layered/the other scheds while doing that. I'm not sure that's worth doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants