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

scx_layered: Fix idle core selection #696

Merged
merged 1 commit into from
Sep 26, 2024
Merged
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
25 changes: 17 additions & 8 deletions scheds/rust/scx_layered/src/bpf/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ s32 pick_idle_cpu(struct task_struct *p, s32 prev_cpu,
bpf_cpumask_copy(pref_idle_cpumask, idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, cache_cpumask, pref_idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, layer_cpumask, pref_idle_cpumask);
trace("pick_idle: llc idle_cpumask=%p", pref_idle_cpumask);
if ((cpu = pick_idle_cpu_from(cache_cpumask, prev_cpu, pref_idle_cpumask)) >= 0)
if ((cpu = pick_idle_cpu_from(pref_idle_cpumask, prev_cpu,
idle_cpumask)) >= 0)
goto out_put;

/*
Expand All @@ -628,13 +628,22 @@ s32 pick_idle_cpu(struct task_struct *p, s32 prev_cpu,
goto out_put;
}
bpf_cpumask_copy(pref_idle_cpumask, idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, node_cpumask, pref_idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, layer_cpumask, pref_idle_cpumask);
trace("pick_idle: node node_cpumask=%p", pref_idle_cpumask);
if ((cpu = pick_idle_cpu_from(node_cpumask, prev_cpu,
pref_idle_cpumask)) >= 0)
goto out_put;
bpf_cpumask_and(pref_idle_cpumask, node_cpumask,
pref_idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, layer_cpumask,
pref_idle_cpumask);
if ((cpu = pick_idle_cpu_from(pref_idle_cpumask, prev_cpu,
idle_cpumask)) >= 0)
goto out_put;
}
/*
* At this point try the whole machine
*/
bpf_cpumask_copy(pref_idle_cpumask, idle_cpumask);
bpf_cpumask_and(pref_idle_cpumask, layer_cpumask, pref_idle_cpumask);
if ((cpu = pick_idle_cpu_from(pref_idle_cpumask, prev_cpu,
idle_cpumask)) >= 0)
goto out_put;
}

/*
Expand Down
Loading