Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions scheds/rust-user/scx_rusty/src/bpf/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,18 +425,21 @@ s32 BPF_STRUCT_OPS(rusty_select_cpu, struct task_struct *p, s32 prev_cpu,
if (!(taskc = lookup_task_ctx(p)) || !(p_cpumask = taskc->cpumask))
goto enoent;

if (kthreads_local &&
(p->flags & PF_KTHREAD) && p->nr_cpus_allowed == 1) {
if (p->nr_cpus_allowed == 1) {
cpu = prev_cpu;
stat_add(RUSTY_STAT_DIRECT_DISPATCH, 1);
if (kthreads_local && (p->flags & PF_KTHREAD)) {
stat_add(RUSTY_STAT_DIRECT_DISPATCH, 1);
} else {
stat_add(RUSTY_STAT_PINNED, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify the if on line 442 by removing the first p->nr_cpus_allowed > 1 clause, which should always be true now that we're always doing local dispatching if p->nr_cpus_allowed == 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Will fix.

goto direct;
}

/*
* If WAKE_SYNC and the machine isn't fully saturated, wake up @p to the
* local dsq of the waker.
*/
if (p->nr_cpus_allowed > 1 && (wake_flags & SCX_WAKE_SYNC)) {
if (wake_flags & SCX_WAKE_SYNC) {
struct task_struct *current = (void *)bpf_get_current_task();

if (!(BPF_CORE_READ(current, flags) & PF_EXITING) &&
Expand Down Expand Up @@ -475,13 +478,6 @@ s32 BPF_STRUCT_OPS(rusty_select_cpu, struct task_struct *p, s32 prev_cpu,
}
}

/* If only one CPU is allowed, dispatch */
if (p->nr_cpus_allowed == 1) {
stat_add(RUSTY_STAT_PINNED, 1);
cpu = prev_cpu;
goto direct;
}

has_idle_cores = !bpf_cpumask_empty(idle_smtmask);

/* did @p get pulled out to a foreign domain by e.g. greedy execution? */
Expand Down