-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: main
Are you sure you want to change the base?
Conversation
Add thread hinting to scx_layered. Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
@@ -162,4 +163,8 @@ struct layer { | |||
unsigned int perf; | |||
}; | |||
|
|||
struct user_ctx { | |||
u64 task_overrides[MAX_LAYER_OVERRIDES]; | |||
u32 nr_overrides; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
.
788d1d4
to
6a2938a
Compare
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. |
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>
6a2938a
to
174ec5b
Compare
This will likely need to support pid namespaces, which will be... fun |
|
||
// 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) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.