Skip to content

Commit b1e3b3b

Browse files
authored
Merge pull request raspberrypi#26 from sched-ext/whole-to-core
SCX: Use "idle core" instead of "whole cpu"
2 parents 1700712 + cb4315d commit b1e3b3b

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

kernel/sched/ext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ static s32 scx_pick_idle_cpu(const struct cpumask *cpus_allowed, u64 flags)
19581958
if (cpu < nr_cpu_ids)
19591959
goto found;
19601960

1961-
if (flags & SCX_PICK_IDLE_CPU_WHOLE)
1961+
if (flags & SCX_PICK_IDLE_CORE)
19621962
return -EBUSY;
19631963
}
19641964

@@ -2009,7 +2009,7 @@ static s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flag
20092009
return prev_cpu;
20102010
}
20112011

2012-
cpu = scx_pick_idle_cpu(p->cpus_ptr, SCX_PICK_IDLE_CPU_WHOLE);
2012+
cpu = scx_pick_idle_cpu(p->cpus_ptr, SCX_PICK_IDLE_CORE);
20132013
if (cpu >= 0) {
20142014
p->scx.flags |= SCX_TASK_ENQ_LOCAL;
20152015
return cpu;

kernel/sched/ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ enum scx_kick_flags {
9292
};
9393

9494
enum scx_pick_idle_cpu_flags {
95-
SCX_PICK_IDLE_CPU_WHOLE = 1LLU << 0, /* pick a CPU whose SMT siblings are also idle */
95+
SCX_PICK_IDLE_CORE = 1LLU << 0, /* pick a CPU whose SMT siblings are also idle */
9696
};
9797

9898
#ifdef CONFIG_SCHED_CLASS_EXT

tools/sched_ext/atropos/src/bpf/atropos.bpf.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
277277
struct task_ctx *task_ctx;
278278
struct bpf_cpumask *p_cpumask;
279279
pid_t pid = p->pid;
280-
bool prev_domestic, has_idle_wholes;
280+
bool prev_domestic, has_idle_cores;
281281
s32 cpu;
282282

283283
refresh_tune_params();
@@ -344,7 +344,7 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
344344
goto direct;
345345
}
346346

347-
has_idle_wholes = !bpf_cpumask_empty(idle_smtmask);
347+
has_idle_cores = !bpf_cpumask_empty(idle_smtmask);
348348

349349
/* did @p get pulled out to a foreign domain by e.g. greedy execution? */
350350
prev_domestic = bpf_cpumask_test_cpu(prev_cpu,
@@ -385,19 +385,19 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
385385
* domestic CPU and then move onto foreign.
386386
*/
387387

388-
/* If there is a domestic whole idle CPU, dispatch directly */
389-
if (has_idle_wholes) {
388+
/* If there is a domestic idle core, dispatch directly */
389+
if (has_idle_cores) {
390390
cpu = scx_bpf_pick_idle_cpu((const struct cpumask *)p_cpumask,
391-
SCX_PICK_IDLE_CPU_WHOLE);
391+
SCX_PICK_IDLE_CORE);
392392
if (cpu >= 0) {
393393
stat_add(ATROPOS_STAT_DIRECT_DISPATCH, 1);
394394
goto direct;
395395
}
396396
}
397397

398398
/*
399-
* If @prev_cpu was domestic and is idle itself even though the whole
400-
* core isn't, picking @prev_cpu may improve L1/2 locality.
399+
* If @prev_cpu was domestic and is idle itself even though the core
400+
* isn't, picking @prev_cpu may improve L1/2 locality.
401401
*/
402402
if (prev_domestic && scx_bpf_test_and_clear_cpu_idle(prev_cpu)) {
403403
stat_add(ATROPOS_STAT_DIRECT_DISPATCH, 1);
@@ -415,7 +415,7 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
415415
/*
416416
* Domestic domain is fully booked. If there are CPUs which are idle and
417417
* under-utilized, ignore domain boundaries and push the task there. Try
418-
* to find a whole idle CPU first.
418+
* to find an idle core first.
419419
*/
420420
if (task_ctx->all_cpus && direct_greedy_cpumask &&
421421
!bpf_cpumask_empty((const struct cpumask *)direct_greedy_cpumask)) {
@@ -427,15 +427,12 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
427427
goto enoent;
428428
}
429429

430-
/*
431-
* Try to find a whole idle CPU in the previous foreign and then
432-
* any domain.
433-
*/
434-
if (has_idle_wholes) {
430+
/* Try to find an idle core in the previous and then any domain */
431+
if (has_idle_cores) {
435432
if (domc->direct_greedy_cpumask) {
436433
cpu = scx_bpf_pick_idle_cpu((const struct cpumask *)
437434
domc->direct_greedy_cpumask,
438-
SCX_PICK_IDLE_CPU_WHOLE);
435+
SCX_PICK_IDLE_CORE);
439436
if (cpu >= 0) {
440437
stat_add(ATROPOS_STAT_DIRECT_GREEDY, 1);
441438
goto direct;
@@ -445,7 +442,7 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
445442
if (direct_greedy_cpumask) {
446443
cpu = scx_bpf_pick_idle_cpu((const struct cpumask *)
447444
direct_greedy_cpumask,
448-
SCX_PICK_IDLE_CPU_WHOLE);
445+
SCX_PICK_IDLE_CORE);
449446
if (cpu >= 0) {
450447
stat_add(ATROPOS_STAT_DIRECT_GREEDY_FAR, 1);
451448
goto direct;
@@ -454,7 +451,7 @@ s32 BPF_STRUCT_OPS(atropos_select_cpu, struct task_struct *p, s32 prev_cpu,
454451
}
455452

456453
/*
457-
* No whole idle CPU. Is there any idle CPU?
454+
* No idle core. Is there any idle CPU?
458455
*/
459456
if (domc->direct_greedy_cpumask) {
460457
cpu = scx_bpf_pick_idle_cpu((const struct cpumask *)

0 commit comments

Comments
 (0)