mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-28 21:50:23 +00:00
scx_lavd: add a fastpath in ops.select_cpu() for a sharply pinned task
If a task can be run only on a single cpu, we don't need to go through all the steps in ops.select_cpu(). Instread, we simply check if a task is still pinned on the prev_cpu and go. Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
parent
b54fc202b8
commit
a89a56dba4
@ -1356,11 +1356,23 @@ static s32 pick_idle_cpu(struct task_struct *p, struct task_ctx *taskc,
|
|||||||
struct bpf_cpumask *active, *ovrflw, *big, *little, *cpdom_mask_prev;
|
struct bpf_cpumask *active, *ovrflw, *big, *little, *cpdom_mask_prev;
|
||||||
s32 cpu_id;
|
s32 cpu_id;
|
||||||
|
|
||||||
bpf_rcu_read_lock();
|
/*
|
||||||
|
* If a task can run only on a single CPU (e.g., per-CPU kworker), we
|
||||||
|
* simply check if a task is still pinned on the prev_cpu and go.
|
||||||
|
*/
|
||||||
|
if (p->nr_cpus_allowed == 1 &&
|
||||||
|
bpf_cpumask_test_cpu(prev_cpu, p->cpus_ptr)) {
|
||||||
|
if (scx_bpf_test_and_clear_cpu_idle(prev_cpu))
|
||||||
|
*is_idle = true;
|
||||||
|
cpu_id = prev_cpu;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare cpumaks.
|
* Prepare cpumaks.
|
||||||
*/
|
*/
|
||||||
|
bpf_rcu_read_lock();
|
||||||
|
|
||||||
cpuc = get_cpu_ctx();
|
cpuc = get_cpu_ctx();
|
||||||
cpuc_prev = get_cpu_ctx_id(prev_cpu);
|
cpuc_prev = get_cpu_ctx_id(prev_cpu);
|
||||||
if (!cpuc || !cpuc_prev || !taskc) {
|
if (!cpuc || !cpuc_prev || !taskc) {
|
||||||
@ -1515,6 +1527,7 @@ start_any_mask:
|
|||||||
*/
|
*/
|
||||||
unlock_out:
|
unlock_out:
|
||||||
bpf_rcu_read_unlock();
|
bpf_rcu_read_unlock();
|
||||||
|
out:
|
||||||
return cpu_id;
|
return cpu_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user