In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
PATCH RESEND 1/1 In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
For example:
# cat /proc/sys/kernel/sched_rt_runtime_us 950000 # echo 940000 > /proc/sys/kernel/sched_rt_runtime_us -bash: echo: write error: Invalid argument
This occurs because when the global RT quota is reduced while the root cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up exceeding the global RT ratio. This is unreasonable: the root cgroup’s ratio should be updated when the global RT ratio changes.
This patch ensures the root cgroup’s RT quota is adjusted whenever the global RT quota is modified.
--- kernel/sched/rt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/sched/rt.c +11 -1
@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)static int sched_rt_global_constraints (void ) {int ret =0 ; +u64 period =global_rt_period (); +u64 runtime =global_rt_runtime ();mutex_lock (&rt_constraints_mutex); - ret =__rt_schedulable (NULL ,0 ,0 ); + ret =__rt_schedulable (&root_task_group, period, runtime);mutex_unlock (&rt_constraints_mutex);return ret;
@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)static void sched_rt_do_global (void ) { +#ifdef CONFIG_RT_GROUP_SCHED +if (!rt_group_sched_enabled ()) +return ; + +WARN_ON_ONCE (tg_set_rt_bandwidth (&root_task_group, +global_rt_period (), +global_rt_runtime ())); +#endif } static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
Signature · 1 line
2.34.1
Quoted 44 lines · Chen Jinghuang
For example:
# cat /proc/sys/kernel/sched_rt_runtime_us 950000 # echo 940000 > /proc/sys/kernel/sched_rt_runtime_us -bash: echo: write error: Invalid argumentThis occurs because when the global RT quota is reduced while the root cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up exceeding the global RT ratio. This is unreasonable: the root cgroup’s ratio should be updated when the global RT ratio changes.
This patch ensures the root cgroup’s RT quota is adjusted whenever the global RT quota is modified.
Signed-off-by Chen Ridong <[email protected]>Tested-by Madadi Vineeth Reddy <[email protected]>Reviewed-by Chen Jinghuang <[email protected]>--- kernel/sched/rt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)kernel/sched/rt.c +4
-1@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)static int sched_rt_global_constraints (void ) {int ret =0 ; +u64 period =global_rt_period (); +u64 runtime =global_rt_runtime ();mutex_lock (&rt_constraints_mutex); - ret =__rt_schedulable (NULL ,0 ,0 ); + ret =__rt_schedulable (&root_task_group, period, runtime);mutex_unlock (&rt_constraints_mutex);return ret;@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)static void sched_rt_do_global (void ) { +#ifdef CONFIG_RT_GROUP_SCHED
kernel/sched/rt.c static int sched_rt_global_validate(void) · line 2871
Quoted 10 lines
kernel/sched/rt.c +7
-0+if (!rt_group_sched_enabled ()) +return ; + +WARN_ON_ONCE (tg_set_rt_bandwidth (&root_task_group, +global_rt_period (), +global_rt_runtime ())); +#endif } static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
ping
Quoted 54 lines · chenjinghuang
Quoted 53 lines · Chen Jinghuang
For example:
# cat /proc/sys/kernel/sched_rt_runtime_us 950000 # echo 940000 > /proc/sys/kernel/sched_rt_runtime_us -bash: echo: write error: Invalid argumentThis occurs because when the global RT quota is reduced while the root cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up exceeding the global RT ratio. This is unreasonable: the root cgroup’s ratio should be updated when the global RT ratio changes.
This patch ensures the root cgroup’s RT quota is adjusted whenever the global RT quota is modified.
Signed-off-by Chen Jinghuang <[email protected]>Tested-by Madadi Vineeth Reddy <[email protected]>Reviewed-by Chen Ridong <[email protected]>--- kernel/sched/rt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)kernel/sched/rt.c +11
-1@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)static int sched_rt_global_constraints (void ) {int ret =0 ; +u64 period =global_rt_period (); +u64 runtime =global_rt_runtime ();mutex_lock (&rt_constraints_mutex); - ret =__rt_schedulable (NULL ,0 ,0 ); + ret =__rt_schedulable (&root_task_group, period, runtime);mutex_unlock (&rt_constraints_mutex);return ret;@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)static void sched_rt_do_global (void ) { +#ifdef CONFIG_RT_GROUP_SCHED +if (!rt_group_sched_enabled ()) +return ; + +WARN_ON_ONCE (tg_set_rt_bandwidth (&root_task_group, +global_rt_period (), +global_rt_runtime ())); +#endif }
Quoted 2 lines
kernel/sched/rt.c static int sched_rt_global_validate(void) · line 2871
Quoted 1 line
kernel/sched/rt.c +0
-0static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,ping
Hi,
Gentle ping on this patch.
I'd appreciate any feedback whenever you get time, or let me know if I should resend/rework anything.
Regards,
Chen Jinghuang