Skip to content

layered: improve compat of excl fixes on older kernels #1933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2025

Conversation

likewhatevs
Copy link
Contributor

improve compat of excl fixes on older kernels

older verifiers need the extra check on prev_layer and pulling out sib_keep_idle to reduce complexity (instruction count).

@likewhatevs likewhatevs requested review from htejun and etsal May 20, 2025 16:33
@@ -1856,27 +1856,20 @@ bool try_consume_layers(u32 *layer_order, u32 nr, u32 exclude_layer_id,
return false;
}

void BPF_STRUCT_OPS(layered_dispatch, s32 cpu, struct task_struct *prev)
int sib_keep_idle(s32 cpu, struct task_struct *prev __arg_trusted)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make it return bool and also take cpuc?


/* !NULL prev_taskc indicates runnable prev */
if (prev && (prev->scx.flags & SCX_TASK_QUEUED)) {
if (!(prev_taskc = lookup_task_ctx(prev)) ||
!(prev_layer = lookup_layer(prev_taskc->layer_id)))
return;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't really matter but let's return false here, just so that the default return is a more passive one.

@likewhatevs likewhatevs enabled auto-merge May 20, 2025 21:56
@likewhatevs likewhatevs added this pull request to the merge queue May 20, 2025
Merged via the queue into sched-ext:main with commit c91d28b May 20, 2025
16 checks passed
@likewhatevs likewhatevs deleted the layered-excl-fixes-cleanup branch May 20, 2025 22:16
@@ -1890,9 +1879,31 @@ void BPF_STRUCT_OPS(layered_dispatch, s32 cpu, struct task_struct *prev)
if ((sib = sibling_cpu(cpu)) >= 0 && (sib_cpuc = lookup_cpu_ctx(sib)) &&
(sib_cpuc->current_excl || sib_cpuc->next_excl)) {
gstat_inc(GSTAT_EXCL_IDLE, cpuc);
return;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

So, this should be true.

}
}

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

and then false.

if (antistall_consume(cpuc))
return;

if (prev && !sib_keep_idle(cpu, prev, cpuc))
Copy link
Contributor

Choose a reason for hiding this comment

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

without !. Otherwise, it's really confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants