Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Allow clean exits from the scheduler with scx_bpf_exit() #166

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

Byte-Lab
Copy link
Collaborator

There may be cases where a scheduler wants to cause itself to exit under
normal circumstances. For example, if a scheduler does not support
hotplug, it may want to exit to user space if a CPU is hotplugged or
unplugged to let it know that it should restart itself.

To enable this, we implement a new kfunc called scx_bpf_exit_bstr().
This kfunc shares a good amount of logic with scx_bpf_error_bstr(), as
both of them can plumb an exit message from BPF to user space. In
addition, we also augment struct scx_exit_info to include an exit code
field.

@Byte-Lab Byte-Lab requested a review from htejun March 28, 2024 06:10
@Byte-Lab
Copy link
Collaborator Author

Spoke offline with Tejun. Going to change a few things around and send a v2

@Byte-Lab
Copy link
Collaborator Author

Oops, missed fixing up scx_ops_exit_kind(). Will resend another patch shortly

There may be cases where a scheduler wants to cause itself to exit under
normal circumstances. For example, if a scheduler does not support
hotplug, it may want to exit to user space if a CPU is hotplugged or
unplugged to let it know that it should restart itself.

To enable this, we implement a new kfunc called scx_bpf_exit_bstr().
This kfunc shares a good amount of logic with scx_bpf_error_bstr(), as
both of them can plumb an exit message from BPF to user space. In
addition, we also augment struct scx_exit_info to include an exit code
field.

Signed-off-by: David Vernet <void@manifault.com>
As with scx_bpf_error(), we want schedulers to have an ergonomic API for
exiting execution. Let's add an scx_bpf_exit() macro wrapper that does
nearly the same thing as scx_bpf_error(), but invokes
scx_bpf_exit_bstr() instead of scx_bpf_error_bstr().

Signed-off-by: David Vernet <void@manifault.com>
We no longer have scx_bpf_switch_all(). Let's update the test to use
__COMPAT_SCX_OPS_SWITCH_PARTIAL. Along the way, make it less flaky.

Signed-off-by: David Vernet <void@manifault.com>
Let's add a selftest that verifies us using scx_bpf_exit() to exit from
various callbacks in the program.

Signed-off-by: David Vernet <void@manifault.com>
@Byte-Lab
Copy link
Collaborator Author

@htejun, this should be ready for another look

@Byte-Lab Byte-Lab merged commit 27688fa into sched_ext Mar 28, 2024
1 check passed
@Byte-Lab Byte-Lab deleted the clean_exit_bpf branch March 28, 2024 23:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants