I’m testing sched_ext, and wanted to see if I could automatically switch between schedulers using a systemd service. The idea would be that a short script checks for something, e.g. battery or AC power, then overrides the environment variable to switch to the desired scheduler for that condition.
According to scx/services/README.md at bb34775f978fe4e8d04737f1d44c0e52e5949b04 · sched-ext/scx · GitHub there are two systemd environment variables, SCX_FLAGS_OVERRIDE
and SCX_SCHEDULER_OVERRIDE
, but it seems like the NixOS scx.service doesn’t recognise these. I haven’t tested on a different distro, so I could be wrong about how this is meant to function.
If I set the following in my config:
services.scx = {
enable = true;
scheduler = "scx_lavd";
extraArgs = [ "--autopower" ];
};
and then use:
$ sudo systemctl set-environment SCX_SCHEDULER_OVERRIDE=scx_flash
$ sudo systemctl set-environment SCX_FLAGS_OVERRIDE=""
$ sudo systemctl restart scx
$ systemctl status scx
it looks like scx_lavd
is still the scheduler being used – from my understanding it should have switched to scx_flash
.