Re: [PATCH] sched: cgroup SCHED_IDLE support
From: Peter Zijlstra
Date: Fri Jun 25 2021 - 04:15:42 EST
On Tue, Jun 08, 2021 at 04:11:32PM -0700, Josh Don wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 8ab69d01dab4..a82f5d3b85d3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -10234,6 +10234,18 @@ static int cpu_weight_nice_write_s64(struct cgroup_subsys_state *css,
>
> return sched_group_set_shares(css_tg(css), scale_load(weight));
> }
> +
> +static s64 cpu_idle_read_s64(struct cgroup_subsys_state *css,
> + struct cftype *cft)
> +{
> + return css_tg(css)->idle;
> +}
> +
> +static int cpu_idle_write_s64(struct cgroup_subsys_state *css,
> + struct cftype *cft, s64 idle)
> +{
> + return sched_group_set_idle(css_tg(css), idle);
> +}
> #endif
>
> static void __maybe_unused cpu_period_quota_print(struct seq_file *sf,
> @@ -10306,6 +10318,12 @@ static struct cftype cpu_files[] = {
> .read_s64 = cpu_weight_nice_read_s64,
> .write_s64 = cpu_weight_nice_write_s64,
> },
> + {
> + .name = "idle",
> + .flags = CFTYPE_NOT_ON_ROOT,
> + .read_s64 = cpu_idle_read_s64,
> + .write_s64 = cpu_idle_write_s64,
> + },
> #endif
> #ifdef CONFIG_CFS_BANDWIDTH
> {
You should probably also make cpu_weight_*write_?64() return -EINVAL when
IDLE. Similar to how SCHED_IDLE doesn't do nice.