rusty: Use built-in exit code for restarting

Now that the kernel exports the SCX_ECODE_ACT_RESTART exit code, we can
remove the custom hotplug logic from scx_rusty, and instead rely on the
built-in logic from the kernel. There's still a corner case that we're not
honoring: when a hotplug event happens on the init path. A future change will
address this as well.

Signed-off-by: David Vernet <void@manifault.com>
This commit is contained in:
David Vernet 2024-05-15 13:33:53 -05:00
parent c6cc59e8b4
commit 34818de54d
No known key found for this signature in database
GPG Key ID: 59E4B86965C4F364
4 changed files with 5 additions and 19 deletions

View File

@ -34,6 +34,7 @@ pub enum ScxExitKind {
Done = bindings::scx_exit_kind_SCX_EXIT_DONE as isize,
Unreg = bindings::scx_exit_kind_SCX_EXIT_UNREG as isize,
UnregBPF = bindings::scx_exit_kind_SCX_EXIT_UNREG_BPF as isize,
UnregKern = bindings::scx_exit_kind_SCX_EXIT_UNREG_KERN as isize,
SysRq = bindings::scx_exit_kind_SCX_EXIT_SYSRQ as isize,
Error = bindings::scx_exit_kind_SCX_EXIT_ERROR as isize,
ErrorBPF = bindings::scx_exit_kind_SCX_EXIT_ERROR_BPF as isize,
@ -205,7 +206,7 @@ impl UserExitInfo {
_ => "<UNKNOWN>".into(),
};
if self.kind <= ScxExitKind::UnregBPF as i32 {
if self.kind <= ScxExitKind::UnregKern as i32 {
eprintln!("{}", why);
Ok(())
} else {
@ -217,7 +218,7 @@ impl UserExitInfo {
/// only applies when the BPF scheduler exits with scx_bpf_exit(), i.e. kind
/// ScxExitKind::UnregBPF.
pub fn exit_code(&self) -> Option<i64> {
if self.kind == ScxExitKind::UnregBPF as i32 {
if self.kind == ScxExitKind::UnregBPF as i32 || self.kind == ScxExitKind::UnregKern as i32 {
Some(self.exit_code)
} else {
None

View File

@ -61,10 +61,6 @@ enum consts {
MAX_DOM_ACTIVE_PIDS = 1024,
};
enum rusty_exit_codes {
RUSTY_EXIT_HOTPLUG,
};
/* Statistics */
enum stat_idx {
/* The following fields add up to all dispatched tasks */

View File

@ -1743,16 +1743,6 @@ static s32 initialize_cpu(s32 cpu)
return 0;
}
void BPF_STRUCT_OPS(rusty_cpu_online, s32 cpu)
{
__COMPAT_scx_bpf_exit(RUSTY_EXIT_HOTPLUG, "CPU %d went online", cpu);
}
void BPF_STRUCT_OPS(rusty_cpu_offline, s32 cpu)
{
__COMPAT_scx_bpf_exit(RUSTY_EXIT_HOTPLUG, "CPU %d went offline", cpu);
}
s32 BPF_STRUCT_OPS_SLEEPABLE(rusty_init)
{
s32 i, ret;
@ -1812,8 +1802,6 @@ SCX_OPS_DEFINE(rusty,
.set_cpumask = (void *)rusty_set_cpumask,
.init_task = (void *)rusty_init_task,
.exit_task = (void *)rusty_exit_task,
.cpu_online = (void *)rusty_cpu_online,
.cpu_offline = (void *)rusty_cpu_offline,
.init = (void *)rusty_init,
.exit = (void *)rusty_exit,
.timeout_ms = 10000,

View File

@ -40,6 +40,7 @@ use scx_utils::scx_ops_attach;
use scx_utils::scx_ops_load;
use scx_utils::uei_exited;
use scx_utils::uei_read;
use scx_utils::SCX_ECODE_ACT_RESTART;
use scx_utils::Cpumask;
use scx_utils::Topology;
use scx_utils::UserExitInfo;
@ -620,7 +621,7 @@ fn main() -> Result<()> {
let uei = sched.run(shutdown.clone())?;
if let Some(exit_code) = uei.exit_code() {
if exit_code == bpf_intf::rusty_exit_codes_RUSTY_EXIT_HOTPLUG as i64 {
if (exit_code & *SCX_ECODE_ACT_RESTART as i64) != 0 {
continue;
}
}