Skip to content

Commit 33cb330

Browse files
committed
layered: cpuset support, rename and bugfix
1 parent a3e086a commit 33cb330

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

scheds/rust/scx_layered/examples/cpuset.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"matches": [
66
[
77
{
8-
"CommPrefix": "geekbench"
8+
"CgroupPrefix": "system.slice/docker"
99
}
1010
]
1111
],

scheds/rust/scx_layered/src/bpf/intf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum consts {
3030
MAX_TASKS = 131072,
3131
MAX_PATH = 4096,
3232
MAX_NUMA_NODES = 64,
33-
MAX_CONTAINERS = 64,
33+
MAX_CPUSETS = 64,
3434
MAX_LLCS = 64,
3535
MAX_COMM = 16,
3636
MAX_LAYER_MATCH_ORS = 32,

scheds/rust/scx_layered/src/bpf/main.bpf.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ const volatile u64 numa_cpumasks[MAX_NUMA_NODES][MAX_CPUS / 64];
3434
const volatile u32 llc_numa_id_map[MAX_LLCS];
3535
const volatile u32 cpu_llc_id_map[MAX_CPUS];
3636
const volatile u32 nr_layers = 1;
37-
const volatile u32 nr_containers = 1;
37+
const volatile u32 nr_cpusets = 1;
3838
const volatile u32 nr_nodes = 32; /* !0 for veristat, set during init */
3939
const volatile u32 nr_llcs = 32; /* !0 for veristat, set during init */
4040
const volatile bool smt_enabled = true;
41-
const volatile bool enable_container = true;
41+
const volatile bool enable_cpuset = true;
4242
const volatile bool has_little_cores = true;
4343
const volatile bool xnuma_preemption = false;
4444
const volatile s32 __sibling_cpu[MAX_CPUS];
@@ -55,7 +55,7 @@ const volatile u64 lo_fb_wait_ns = 5000000; /* !0 for veristat */
5555
const volatile u32 lo_fb_share_ppk = 128; /* !0 for veristat */
5656
const volatile bool percpu_kthread_preempt = true;
5757
volatile u64 layer_refresh_seq_avgruntime;
58-
const volatile u64 cpuset_fakemasks[MAX_CONTAINERS][MAX_CPUS / 64];
58+
const volatile u64 cpuset_fakemasks[MAX_CPUSETS][MAX_CPUS / 64];
5959

6060
/* Flag to enable or disable antistall feature */
6161
const volatile bool enable_antistall = true;
@@ -82,7 +82,7 @@ struct cpumask_box {
8282

8383
struct {
8484
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
85-
__uint(max_entries, MAX_CONTAINERS);
85+
__uint(max_entries, MAX_CPUSETS);
8686
__type(key, u32);
8787
__type(value, struct cpumask_box);
8888
} cpuset_cpumask SEC(".maps");
@@ -1375,10 +1375,10 @@ void BPF_STRUCT_OPS(layered_enqueue, struct task_struct *p, u64 enq_flags)
13751375
* without making the whole scheduler node aware and should only be used
13761376
* with open layers on non-saturated machines to avoid possible stalls.
13771377
*/
1378-
if ((!taskc->all_cpus_allowed &&
1379-
!(layer->allow_node_aligned && taskc->cpus_node_aligned)) ||
1380-
!(enable_container && taskc->cpus_cpuset_aligned) ||
1381-
!layer->nr_cpus) {
1378+
if ((!taskc->all_cpus_allowed &&
1379+
!((layer->allow_node_aligned && taskc->cpus_node_aligned) ||
1380+
(enable_cpuset && taskc->cpus_cpuset_aligned)))
1381+
|| !layer->nr_cpus) {
13821382

13831383
taskc->dsq_id = task_cpuc->lo_fb_dsq_id;
13841384
/*
@@ -2665,8 +2665,8 @@ static void refresh_cpus_flags(struct task_ctx *taskc,
26652665
break;
26662666
}
26672667
}
2668-
if (enable_container) {
2669-
bpf_for(container_id, 0, nr_containers) {
2668+
if (enable_cpuset) {
2669+
bpf_for(container_id, 0, nr_cpusets) {
26702670
struct cpumask_box* box;
26712671
box = bpf_map_lookup_elem(&cpuset_cpumask, &container_id);
26722672
if (!box || !box->mask) {
@@ -3394,8 +3394,8 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
33943394

33953395

33963396

3397-
if (enable_container) {
3398-
bpf_for(i, 0, nr_containers) {
3397+
if (enable_cpuset) {
3398+
bpf_for(i, 0, nr_cpusets) {
33993399
cpumask = bpf_cpumask_create();
34003400

34013401
if (!cpumask)
@@ -3404,7 +3404,7 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
34043404

34053405
bpf_for(j, 0, MAX_CPUS/64) {
34063406
// verifier
3407-
if (i < 0 || i >= MAX_CONTAINERS || j < 0 || j >= (MAX_CPUS / 64)) {
3407+
if (i < 0 || i >= MAX_CPUSETS || j < 0 || j >= (MAX_CPUS / 64)) {
34083408
bpf_cpumask_release(cpumask);
34093409
return -1;
34103410
}
@@ -3426,7 +3426,7 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
34263426
if (tmp_cpuset_cpumask)
34273427
bpf_cpumask_release(tmp_cpuset_cpumask);
34283428
scx_bpf_error("cpumask is null");
3429-
return -1;
3429+
return -1;
34303430
}
34313431
bpf_cpumask_copy(tmp_cpuset_cpumask, cast_mask(cpumask));
34323432

scheds/rust/scx_layered/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ struct Opts {
591591
#[clap(long, default_value = "false")]
592592
disable_antistall: bool,
593593

594-
/// Enable container support
594+
/// Enable cpuset support
595595
#[clap(long, default_value = "false")]
596-
enable_container: bool,
596+
enable_cpuset: bool,
597597

598598
/// Maximum task runnable_at delay (in seconds) before antistall turns on
599599
#[clap(long, default_value = "3")]
@@ -1433,7 +1433,7 @@ impl<'a> Scheduler<'a> {
14331433
let cpuset_cpumask_slice = &mut skel.maps.rodata_data.cpuset_fakemasks[i];
14341434
cpuset_cpumask_slice.copy_from_slice(&cpumask_bitvec);
14351435
}
1436-
skel.maps.rodata_data.nr_containers = cpusets.len() as u32;
1436+
skel.maps.rodata_data.nr_cpusets = cpusets.len() as u32;
14371437
Ok(())
14381438
}
14391439

@@ -1877,7 +1877,7 @@ impl<'a> Scheduler<'a> {
18771877
skel.maps.rodata_data.lo_fb_wait_ns = opts.lo_fb_wait_us * 1000;
18781878
skel.maps.rodata_data.lo_fb_share_ppk = ((opts.lo_fb_share * 1024.0) as u32).clamp(1, 1024);
18791879
skel.maps.rodata_data.enable_antistall = !opts.disable_antistall;
1880-
skel.maps.rodata_data.enable_container = opts.enable_container;
1880+
skel.maps.rodata_data.enable_cpuset = opts.enable_cpuset;
18811881
skel.maps.rodata_data.enable_gpu_support = opts.enable_gpu_support;
18821882

18831883
for (cpu, sib) in topo.sibling_cpus().iter().enumerate() {
@@ -1946,7 +1946,7 @@ impl<'a> Scheduler<'a> {
19461946
Self::init_layers(&mut skel, &layer_specs, &topo)?;
19471947
Self::init_nodes(&mut skel, opts, &topo);
19481948

1949-
if opts.enable_container {
1949+
if opts.enable_cpuset {
19501950
Self::init_cpusets(&mut skel, &topo)?;
19511951
}
19521952

0 commit comments

Comments
 (0)