Commit 8195136
committed
sched_ext: Add cgroup support
Add sched_ext_ops operations to init/exit cgroups, and track task migrations
and config changes. A BPF scheduler may not implement or implement only
subset of cgroup features. The implemented features can be indicated using
%SCX_OPS_HAS_CGOUP_* flags. If cgroup configuration makes use of features
that are not implemented, a warning is triggered.
While a BPF scheduler is being enabled and disabled, relevant cgroup
operations are locked out using scx_cgroup_rwsem. This avoids situations
like task prep taking place while the task is being moved across cgroups,
making things easier for BPF schedulers.
v7: - cgroup interface file visibility toggling is dropped in favor just
warning messages. Dynamically changing interface visiblity caused more
confusion than helping.
v6: - Updated to reflect the removal of SCX_KF_SLEEPABLE.
- Updated to use CONFIG_GROUP_SCHED_WEIGHT and fixes for
!CONFIG_FAIR_GROUP_SCHED && CONFIG_EXT_GROUP_SCHED.
v5: - Flipped the locking order between scx_cgroup_rwsem and
cpus_read_lock() to avoid locking order conflict w/ cpuset. Better
documentation around locking.
- sched_move_task() takes an early exit if the source and destination
are identical. This triggered the warning in scx_cgroup_can_attach()
as it left p->scx.cgrp_moving_from uncleared. Updated the cgroup
migration path so that ops.cgroup_prep_move() is skipped for identity
migrations so that its invocations always match ops.cgroup_move()
one-to-one.
v4: - Example schedulers moved into their own patches.
- Fix build failure when !CONFIG_CGROUP_SCHED, reported by Andrea Righi.
v3: - Make scx_example_pair switch all tasks by default.
- Convert to BPF inline iterators.
- scx_bpf_task_cgroup() is added to determine the current cgroup from
CPU controller's POV. This allows BPF schedulers to accurately track
CPU cgroup membership.
- scx_example_flatcg added. This demonstrates flattened hierarchy
implementation of CPU cgroup control and shows significant performance
improvement when cgroups which are nested multiple levels are under
competition.
v2: - Build fixes for different CONFIG combinations.
Signed-off-by: Tejun Heo <[email protected]>
Reviewed-by: David Vernet <[email protected]>
Acked-by: Josh Don <[email protected]>
Acked-by: Hao Luo <[email protected]>
Acked-by: Barret Rhoden <[email protected]>
Reported-by: kernel test robot <[email protected]>
Cc: Andrea Righi <[email protected]>1 parent e179e80 commit 8195136
File tree
8 files changed
+636
-19
lines changed- include/linux/sched
- init
- kernel/sched
- tools
- sched_ext/include/scx
- testing/selftests/sched_ext
8 files changed
+636
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1055 | 1055 | | |
1056 | 1056 | | |
1057 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1058 | 1064 | | |
1059 | 1065 | | |
1060 | 1066 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8364 | 8364 | | |
8365 | 8365 | | |
8366 | 8366 | | |
| 8367 | + | |
| 8368 | + | |
| 8369 | + | |
8367 | 8370 | | |
8368 | 8371 | | |
8369 | 8372 | | |
| |||
8801 | 8804 | | |
8802 | 8805 | | |
8803 | 8806 | | |
| 8807 | + | |
8804 | 8808 | | |
8805 | 8809 | | |
8806 | 8810 | | |
| |||
8928 | 8932 | | |
8929 | 8933 | | |
8930 | 8934 | | |
| 8935 | + | |
8931 | 8936 | | |
8932 | 8937 | | |
8933 | 8938 | | |
| |||
8965 | 8970 | | |
8966 | 8971 | | |
8967 | 8972 | | |
| 8973 | + | |
| 8974 | + | |
| 8975 | + | |
| 8976 | + | |
| 8977 | + | |
8968 | 8978 | | |
8969 | 8979 | | |
8970 | 8980 | | |
| |||
8979 | 8989 | | |
8980 | 8990 | | |
8981 | 8991 | | |
| 8992 | + | |
| 8993 | + | |
| 8994 | + | |
| 8995 | + | |
| 8996 | + | |
| 8997 | + | |
| 8998 | + | |
8982 | 8999 | | |
8983 | 9000 | | |
8984 | 9001 | | |
| |||
8996 | 9013 | | |
8997 | 9014 | | |
8998 | 9015 | | |
8999 | | - | |
9000 | 9016 | | |
9001 | 9017 | | |
| 9018 | + | |
9002 | 9019 | | |
9003 | 9020 | | |
9004 | 9021 | | |
9005 | 9022 | | |
9006 | 9023 | | |
9007 | 9024 | | |
9008 | 9025 | | |
9009 | | - | |
9010 | | - | |
9011 | 9026 | | |
| 9027 | + | |
| 9028 | + | |
9012 | 9029 | | |
9013 | 9030 | | |
9014 | 9031 | | |
| |||
9017 | 9034 | | |
9018 | 9035 | | |
9019 | 9036 | | |
| 9037 | + | |
| 9038 | + | |
| 9039 | + | |
| 9040 | + | |
| 9041 | + | |
| 9042 | + | |
| 9043 | + | |
9020 | 9044 | | |
9021 | 9045 | | |
9022 | 9046 | | |
| |||
9196 | 9220 | | |
9197 | 9221 | | |
9198 | 9222 | | |
| 9223 | + | |
9199 | 9224 | | |
| 9225 | + | |
| 9226 | + | |
| 9227 | + | |
9200 | 9228 | | |
9201 | 9229 | | |
9202 | 9230 | | |
9203 | 9231 | | |
9204 | 9232 | | |
| 9233 | + | |
| 9234 | + | |
9205 | 9235 | | |
9206 | 9236 | | |
9207 | | - | |
| 9237 | + | |
| 9238 | + | |
| 9239 | + | |
| 9240 | + | |
| 9241 | + | |
9208 | 9242 | | |
9209 | 9243 | | |
9210 | 9244 | | |
| |||
9595 | 9629 | | |
9596 | 9630 | | |
9597 | 9631 | | |
9598 | | - | |
| 9632 | + | |
| 9633 | + | |
| 9634 | + | |
| 9635 | + | |
| 9636 | + | |
| 9637 | + | |
9599 | 9638 | | |
9600 | 9639 | | |
9601 | 9640 | | |
| |||
9722 | 9761 | | |
9723 | 9762 | | |
9724 | 9763 | | |
| 9764 | + | |
9725 | 9765 | | |
9726 | 9766 | | |
9727 | 9767 | | |
9728 | 9768 | | |
9729 | 9769 | | |
9730 | 9770 | | |
9731 | | - | |
| 9771 | + | |
| 9772 | + | |
| 9773 | + | |
| 9774 | + | |
9732 | 9775 | | |
9733 | 9776 | | |
9734 | 9777 | | |
| |||
9753 | 9796 | | |
9754 | 9797 | | |
9755 | 9798 | | |
9756 | | - | |
| 9799 | + | |
9757 | 9800 | | |
9758 | 9801 | | |
9759 | 9802 | | |
| |||
9762 | 9805 | | |
9763 | 9806 | | |
9764 | 9807 | | |
9765 | | - | |
| 9808 | + | |
| 9809 | + | |
| 9810 | + | |
| 9811 | + | |
| 9812 | + | |
9766 | 9813 | | |
9767 | 9814 | | |
9768 | 9815 | | |
| |||
9878 | 9925 | | |
9879 | 9926 | | |
9880 | 9927 | | |
| 9928 | + | |
9881 | 9929 | | |
9882 | 9930 | | |
9883 | 9931 | | |
9884 | 9932 | | |
9885 | | - | |
9886 | 9933 | | |
9887 | | - | |
9888 | 9934 | | |
| 9935 | + | |
9889 | 9936 | | |
9890 | 9937 | | |
9891 | 9938 | | |
| |||
0 commit comments