Skip to content

Commit

Permalink
layered: Fix init_task
Browse files Browse the repository at this point in the history
When I transitioned layered to using task local storage, I messed up
initializing the task ctx, not realizing we previously had a separate
variable that was initializing the hasmap entry. We need to initialize
the task's layer to -11, and also set refresh_layer to 1.

Signed-off-by: David Vernet <[email protected]>
  • Loading branch information
Byte-Lab committed Apr 18, 2024
1 parent 34b330c commit 5f1eac8
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions scheds/rust/scx_layered/src/bpf/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,21 +825,8 @@ void BPF_STRUCT_OPS(layered_set_cpumask, struct task_struct *p,
s32 BPF_STRUCT_OPS(layered_init_task, struct task_struct *p,
struct scx_init_task_args *args)
{
struct task_ctx tctx_init = {
.pid = p->pid,
.layer = -1,
.refresh_layer = true,
};
struct task_ctx *tctx;
struct bpf_cpumask *cpumask;
s32 pid = p->pid;
s32 ret;

if (all_cpumask)
tctx_init.all_cpus_allowed =
bpf_cpumask_subset((const struct cpumask *)all_cpumask, p->cpus_ptr);
else
scx_bpf_error("missing all_cpumask");

/*
* XXX - We want BPF_NOEXIST but bpf_map_delete_elem() in .disable() may
Expand All @@ -864,6 +851,16 @@ s32 BPF_STRUCT_OPS(layered_init_task, struct task_struct *p,
return -EINVAL;
}

tctx->pid = p->pid;
tctx->layer = -1;
tctx->refresh_layer = true;

if (all_cpumask)
tctx->all_cpus_allowed =
bpf_cpumask_subset((const struct cpumask *)all_cpumask, p->cpus_ptr);
else
scx_bpf_error("missing all_cpumask");

/*
* We are matching cgroup hierarchy path directly rather than the CPU
* controller path. As the former isn't available during the scheduler
Expand Down

0 comments on commit 5f1eac8

Please sign in to comment.