Skip to content

Commit 495915d

Browse files
committed
layered: cpuset support, rename and bugfix
1 parent 8dd4e4d commit 495915d

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];
@@ -54,7 +54,7 @@ const volatile u64 min_open_layer_disallow_preempt_after_ns;
5454
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;
57-
const volatile u64 cpuset_fakemasks[MAX_CONTAINERS][MAX_CPUS / 64];
57+
const volatile u64 cpuset_fakemasks[MAX_CPUSETS][MAX_CPUS / 64];
5858

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

8282
struct {
8383
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
84-
__uint(max_entries, MAX_CONTAINERS);
84+
__uint(max_entries, MAX_CPUSETS);
8585
__type(key, u32);
8686
__type(value, struct cpumask_box);
8787
} cpuset_cpumask SEC(".maps");
@@ -1349,10 +1349,10 @@ void BPF_STRUCT_OPS(layered_enqueue, struct task_struct *p, u64 enq_flags)
13491349
* without making the whole scheduler node aware and should only be used
13501350
* with open layers on non-saturated machines to avoid possible stalls.
13511351
*/
1352-
if ((!taskc->all_cpus_allowed &&
1353-
!(layer->allow_node_aligned && taskc->cpus_node_aligned)) ||
1354-
!(enable_container && taskc->cpus_cpuset_aligned) ||
1355-
!layer->nr_cpus) {
1352+
if ((!taskc->all_cpus_allowed &&
1353+
!((layer->allow_node_aligned && taskc->cpus_node_aligned) ||
1354+
(enable_cpuset && taskc->cpus_cpuset_aligned)))
1355+
|| !layer->nr_cpus) {
13561356

13571357
taskc->dsq_id = task_cpuc->lo_fb_dsq_id;
13581358
/*
@@ -2617,8 +2617,8 @@ static void refresh_cpus_flags(struct task_ctx *taskc,
26172617
break;
26182618
}
26192619
}
2620-
if (enable_container) {
2621-
bpf_for(container_id, 0, nr_containers) {
2620+
if (enable_cpuset) {
2621+
bpf_for(container_id, 0, nr_cpusets) {
26222622
struct cpumask_box* box;
26232623
box = bpf_map_lookup_elem(&cpuset_cpumask, &container_id);
26242624
if (!box || !box->mask) {
@@ -3338,8 +3338,8 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
33383338

33393339

33403340

3341-
if (enable_container) {
3342-
bpf_for(i, 0, nr_containers) {
3341+
if (enable_cpuset) {
3342+
bpf_for(i, 0, nr_cpusets) {
33433343
cpumask = bpf_cpumask_create();
33443344

33453345
if (!cpumask)
@@ -3348,7 +3348,7 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
33483348

33493349
bpf_for(j, 0, MAX_CPUS/64) {
33503350
// verifier
3351-
if (i < 0 || i >= MAX_CONTAINERS || j < 0 || j >= (MAX_CPUS / 64)) {
3351+
if (i < 0 || i >= MAX_CPUSETS || j < 0 || j >= (MAX_CPUS / 64)) {
33523352
bpf_cpumask_release(cpumask);
33533353
return -1;
33543354
}
@@ -3370,7 +3370,7 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(layered_init)
33703370
if (tmp_cpuset_cpumask)
33713371
bpf_cpumask_release(tmp_cpuset_cpumask);
33723372
scx_bpf_error("cpumask is null");
3373-
return -1;
3373+
return -1;
33743374
}
33753375
bpf_cpumask_copy(tmp_cpuset_cpumask, cast_mask(cpumask));
33763376

scheds/rust/scx_layered/src/main.rs

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

587-
/// Enable container support
587+
/// Enable cpuset support
588588
#[clap(long, default_value = "false")]
589-
enable_container: bool,
589+
enable_cpuset: bool,
590590

591591
/// Maximum task runnable_at delay (in seconds) before antistall turns on
592592
#[clap(long, default_value = "3")]
@@ -1407,7 +1407,7 @@ impl<'a> Scheduler<'a> {
14071407
let cpuset_cpumask_slice = &mut skel.maps.rodata_data.cpuset_fakemasks[i];
14081408
cpuset_cpumask_slice.copy_from_slice(&cpumask_bitvec);
14091409
}
1410-
skel.maps.rodata_data.nr_containers = cpusets.len() as u32;
1410+
skel.maps.rodata_data.nr_cpusets = cpusets.len() as u32;
14111411
Ok(())
14121412
}
14131413

@@ -1851,7 +1851,7 @@ impl<'a> Scheduler<'a> {
18511851
skel.maps.rodata_data.lo_fb_wait_ns = opts.lo_fb_wait_us * 1000;
18521852
skel.maps.rodata_data.lo_fb_share_ppk = ((opts.lo_fb_share * 1024.0) as u32).clamp(1, 1024);
18531853
skel.maps.rodata_data.enable_antistall = !opts.disable_antistall;
1854-
skel.maps.rodata_data.enable_container = opts.enable_container;
1854+
skel.maps.rodata_data.enable_cpuset = opts.enable_cpuset;
18551855
skel.maps.rodata_data.enable_gpu_support = opts.enable_gpu_support;
18561856

18571857
for (cpu, sib) in topo.sibling_cpus().iter().enumerate() {
@@ -1920,7 +1920,7 @@ impl<'a> Scheduler<'a> {
19201920
Self::init_layers(&mut skel, &layer_specs, &topo)?;
19211921
Self::init_nodes(&mut skel, opts, &topo);
19221922

1923-
if opts.enable_container {
1923+
if opts.enable_cpuset {
19241924
Self::init_cpusets(&mut skel, &topo)?;
19251925
}
19261926

0 commit comments

Comments
 (0)