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_flatcg: Keep cgroup rb nodes stashed #33

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

davemarchevsky
Copy link
Contributor

The flatcg scheduler uses a rb_node type - struct cgv_node - to keep track of vtime. On cgroup init, a cgv_node is created and stashed in a hashmap - cgv_node_stash - for later use. In cgroup_enqueued and try_pick_next_cgroup, the node is inserted into the rbtree, which required removing it from the stash before this patch's changes.

This patch makes cgv_node refcounted, which allows keeping it in the stash for the entirety of the cgroup's lifetime. Unnecessary bpf_kptr_xchg's and other boilerplate can be removed as a result.

Note that in addition to bpf_refcount patches, which have been upstream for quite some time, this change depends on a more recent series 0.

@davemarchevsky
Copy link
Contributor Author

Note: I have validated this against an older sched_ext repo, not this new repo w/ schedulers and tools. Will figure out how to test against this repo and add a new comment when it's validated.

@htejun
Copy link
Contributor

htejun commented Dec 14, 2023

LGTM, please merge once tested. Thanks.

@davemarchevsky
Copy link
Contributor Author

Note that in addition to bpf_refcount patches, which have been upstream for quite some time, this change depends on a more recent series 0.

This PR has been sitting as the series it depends on didn't make it into 6.7. It's in 6.8-rcs, so we'll be able to land this once there's a non-rc 6.8

The flatcg scheduler uses a rb_node type - struct cgv_node - to keep
track of vtime. On cgroup init, a cgv_node is created and stashed in a
hashmap - cgv_node_stash - for later use. In cgroup_enqueued and
try_pick_next_cgroup, the node is inserted into the rbtree, which
required removing it from the stash before this patch's changes.

This patch makes cgv_node refcounted, which allows keeping it in the
stash for the entirety of the cgroup's lifetime. Unnecessary
bpf_kptr_xchg's and other boilerplate can be removed as a result.

Note that in addition to bpf_refcount patches, which have been upstream
for quite some time, this change depends on a more recent series [0].

  [0]: https://lore.kernel.org/bpf/20231107085639.3016113-1-davemarchevsky@fb.com/

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
@davemarchevsky
Copy link
Contributor Author

6.8 has been cut, rebased + addressed nit. Think this is good-to-go

@htejun
Copy link
Contributor

htejun commented Mar 11, 2024

Would this work with the currently packaged kernels on arch and ubuntu?

@davemarchevsky
Copy link
Contributor Author

davemarchevsky commented Mar 11, 2024

@htejun Looks like @arighi 's ubuntu kernel has backported the necessary series - it contains kptr_pointee_btf_record fn in verifier.c, which the series added. For arch, the CachyOS kernels are based off of 6.7.9, so no luck there yet.

Since 6.8 has only been out for a day, shall we wait a bit for CachyOS folks to update before poking / trying to submit a PR?

@htejun
Copy link
Contributor

htejun commented Mar 11, 2024

Yeah, let's wait a bit more so that the released kernels have the support. @jordalgo, how about fedora? What's the version situation there?

@jordalgo
Copy link
Contributor

@htejun Still working on both the c-schedulers package and I plan on starting on the actual kernel changes this week or next.

@ptr1337
Copy link
Contributor

ptr1337 commented Mar 12, 2024

@htejun Looks like @arighi 's ubuntu kernel has backported the necessary series - it contains kptr_pointee_btf_record fn in verifier.c, which the series added. For arch, the CachyOS kernels are based off of 6.7.9, so no luck there yet.

Since 6.8 has only been out for a day, shall we wait a bit for CachyOS folks to update before poking / trying to submit a PR?

6.8 will land on 13.03.2024 from our side. Everything seems fine so far.

@htejun
Copy link
Contributor

htejun commented Mar 13, 2024

Looks like the packaged kernels should be ready by the time scx is packaged the next time. Merging now. Thanks.

@htejun htejun merged commit a71a40c into sched-ext:main Mar 13, 2024
1 check passed
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.

None yet

5 participants