scx_rlfifo: user-space idle CPU selection

Select an idle CPU from user-space, instead of always dispatching on the
first CPU available.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
This commit is contained in:
Andrea Righi 2024-08-24 21:11:39 +02:00
parent 568e292a24
commit be7ef1009b

View File

@ -54,8 +54,14 @@ impl<'a> Scheduler<'a> {
Ok(Some(task)) => {
let mut dispatched_task = DispatchedTask::new(&task);
// Allow to dispatch on the first CPU available.
dispatched_task.flags |= RL_CPU_ANY;
// Try to pick an idle CPU for the task.
let cpu = self.bpf.select_cpu(dispatched_task.pid, dispatched_task.cpu, 0);
if cpu >= 0 {
dispatched_task.cpu = cpu;
} else {
// Dispatch task on the first CPU available.
dispatched_task.flags |= RL_CPU_ANY;
}
let _ = self.bpf.dispatch_task(&dispatched_task);