sched: Factor out cgroup weight conversion functions
authorTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:16 +0000 (10:09 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:16 +0000 (10:09 -1000)
commit4f9c7ca851044273df5d67e00ca0b4d0476a48f6
tree620e032c07f9da491e17e71cb044aeaceea90c15
parentd8c7bc2e209170ff78b88b85258546aa6e337af9
sched: Factor out cgroup weight conversion functions

Factor out sched_weight_from/to_cgroup() which convert between scheduler
shares and cgroup weight. No functional change. The factored out functions
will be used by a new BPF extensible sched_class so that the weights can be
exposed to the BPF programs in a way which is consistent cgroup weights and
easier to interpret.

The weight conversions will be used regardless of cgroup usage. It's just
borrowing the cgroup weight range as it's more intuitive.
CGROUP_WEIGHT_MIN/DFL/MAX constants are moved outside CONFIG_CGROUPS so that
the conversion helpers can always be defined.

v2: The helpers are now defined regardless of COFNIG_CGROUPS.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>
include/linux/cgroup.h
kernel/sched/core.c
kernel/sched/sched.h