Commit c9c809f4 authored by Tejun Heo's avatar Tejun Heo

scx_flatcg: Use a user DSQ for fallback instead of SCX_DSQ_GLOBAL

scx_flatcg was using SCX_DSQ_GLOBAL for fallback handling. However, it is
assuming that SCX_DSQ_GLOBAL isn't automatically consumed, which was true a
while ago but is no longer the case. Also, there are further changes planned
for SCX_DSQ_GLOBAL which will disallow explicit consumption from it. Switch
to a user DSQ for fallback.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarDavid Vernet <void@manifault.com>
parent a748db0c
...@@ -49,7 +49,10 @@ ...@@ -49,7 +49,10 @@
/* /*
* Maximum amount of retries to find a valid cgroup. * Maximum amount of retries to find a valid cgroup.
*/ */
#define CGROUP_MAX_RETRIES 1024 enum {
FALLBACK_DSQ = 0,
CGROUP_MAX_RETRIES = 1024,
};
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
...@@ -377,7 +380,7 @@ void BPF_STRUCT_OPS(fcg_enqueue, struct task_struct *p, u64 enq_flags) ...@@ -377,7 +380,7 @@ void BPF_STRUCT_OPS(fcg_enqueue, struct task_struct *p, u64 enq_flags)
scx_bpf_dispatch(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, enq_flags); scx_bpf_dispatch(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, enq_flags);
} else { } else {
stat_inc(FCG_STAT_GLOBAL); stat_inc(FCG_STAT_GLOBAL);
scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); scx_bpf_dispatch(p, FALLBACK_DSQ, SCX_SLICE_DFL, enq_flags);
} }
return; return;
} }
...@@ -780,7 +783,7 @@ void BPF_STRUCT_OPS(fcg_dispatch, s32 cpu, struct task_struct *prev) ...@@ -780,7 +783,7 @@ void BPF_STRUCT_OPS(fcg_dispatch, s32 cpu, struct task_struct *prev)
pick_next_cgroup: pick_next_cgroup:
cpuc->cur_at = now; cpuc->cur_at = now;
if (scx_bpf_consume(SCX_DSQ_GLOBAL)) { if (scx_bpf_consume(FALLBACK_DSQ)) {
cpuc->cur_cgid = 0; cpuc->cur_cgid = 0;
return; return;
} }
...@@ -837,7 +840,7 @@ int BPF_STRUCT_OPS_SLEEPABLE(fcg_cgroup_init, struct cgroup *cgrp, ...@@ -837,7 +840,7 @@ int BPF_STRUCT_OPS_SLEEPABLE(fcg_cgroup_init, struct cgroup *cgrp,
int ret; int ret;
/* /*
* Technically incorrect as cgroup ID is full 64bit while dq ID is * Technically incorrect as cgroup ID is full 64bit while dsq ID is
* 63bit. Should not be a problem in practice and easy to spot in the * 63bit. Should not be a problem in practice and easy to spot in the
* unlikely case that it breaks. * unlikely case that it breaks.
*/ */
...@@ -925,6 +928,11 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p, ...@@ -925,6 +928,11 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
p->scx.dsq_vtime = to_cgc->tvtime_now + vtime_delta; p->scx.dsq_vtime = to_cgc->tvtime_now + vtime_delta;
} }
s32 BPF_STRUCT_OPS_SLEEPABLE(fcg_init)
{
return scx_bpf_create_dsq(FALLBACK_DSQ, -1);
}
void BPF_STRUCT_OPS(fcg_exit, struct scx_exit_info *ei) void BPF_STRUCT_OPS(fcg_exit, struct scx_exit_info *ei)
{ {
UEI_RECORD(uei, ei); UEI_RECORD(uei, ei);
...@@ -943,6 +951,7 @@ SCX_OPS_DEFINE(flatcg_ops, ...@@ -943,6 +951,7 @@ SCX_OPS_DEFINE(flatcg_ops,
.cgroup_init = (void *)fcg_cgroup_init, .cgroup_init = (void *)fcg_cgroup_init,
.cgroup_exit = (void *)fcg_cgroup_exit, .cgroup_exit = (void *)fcg_cgroup_exit,
.cgroup_move = (void *)fcg_cgroup_move, .cgroup_move = (void *)fcg_cgroup_move,
.init = (void *)fcg_init,
.exit = (void *)fcg_exit, .exit = (void *)fcg_exit,
.flags = SCX_OPS_HAS_CGROUP_WEIGHT | SCX_OPS_ENQ_EXITING, .flags = SCX_OPS_HAS_CGROUP_WEIGHT | SCX_OPS_ENQ_EXITING,
.name = "flatcg"); .name = "flatcg");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment