Skip to content
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

scx_layered: Add override context for layer hinting #587

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hodgesds
Copy link
Contributor

Add thread hinting to scx_layered by a user mappable map that allows for overriding layers for a pid. There's no locking or safety ☠️ yet.

Add thread hinting to scx_layered.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
@hodgesds hodgesds requested a review from htejun August 29, 2024 19:26
@@ -162,4 +163,8 @@ struct layer {
unsigned int perf;
};

struct user_ctx {
u64 task_overrides[MAX_LAYER_OVERRIDES];
u32 nr_overrides;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this have a generation number so that it doesn't have to be walked every time?

@@ -314,6 +323,7 @@ struct task_ctx {
struct bpf_cpumask __kptr *layered_cpumask;

bool all_cpus_allowed;
bool is_override;
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 this can be the copy of the generation number where it's only effective if it matches the current gen.

@@ -162,4 +163,8 @@ struct layer {
unsigned int perf;
};

struct user_ctx {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we have uid matches, user may be a bit confusing? How about just override_ctx or overrides.

@hodgesds
Copy link
Contributor Author

Updated with a some better names and some poor synchronization. There's now a way to yield tasks back to the scheduler which should be interesting. There's certainly some vruntime error introduced with user overrides though.

@hodgesds hodgesds requested a review from htejun August 30, 2024 13:16
Rename user_ctx to override_ctx and add a generation per layer. This
should allow a rough synchronization with userspace.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
@hodgesds
Copy link
Contributor Author

This will likely need to support pid namespaces, which will be... fun

@hodgesds hodgesds changed the title scx_layered: Add user context for layer hinting scx_layered: Add override context for layer hinting Aug 30, 2024

// To yield control back to the BPF scheduler userspace is
// allowed to yield a task. Reset all the yielded tasks.
bpf_for(i, 0, octx->nr_yields) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When override gen changes, wouldn't that automatically revoke overrides of all tasks that aren't anymore in the current generation? ie. maybe_refresh_layer() can test whether its gen is behind the global gen and if so, revert back to the original layer and then clear the gen number to indicate that the situation has been dealt with.

* p->scx.dsq_vtime = layer->vtime_now;
*
*/
tctx->layer = layer_idx;
Copy link
Contributor

Choose a reason for hiding this comment

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

So, the way to do this, I think, is just updating the generation numbers here and what the target index should be and let maybe_refresh_layer() do the actual update. That way, it'll update in a synchronized manner and vtime will be taken care of too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that makes sense... keep the updates in one place.

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